/* ===== RIGA CRM — DESIGN SYSTEM v2 ===== */
/* Inter via head.ejs · Lucide icons via head.ejs · No @apply (Tailwind CDN) */

:root {
  --bg:            #09090b;
  --bg-elevated:   #111113;
  --surface:       #18181b;
  --surface-hover: #1e1e22;
  --border:        #27272a;
  --border-subtle: #1c1c1f;
  --text-1: #fafafa;
  --text-2: #a1a1aa;
  --text-3: #52525b;
  --accent:      #3b82f6;
  --accent-hover:#2563eb;
  --accent-dim:  rgba(59,130,246,0.12);
  --green:       #22c55e;
  --green-dim:   rgba(34,197,94,0.1);
  --yellow:      #eab308;
  --yellow-dim:  rgba(234,179,8,0.1);
  --red:         #ef4444;
  --red-dim:     rgba(239,68,68,0.1);
  --purple:      #a855f7;
  --purple-dim:  rgba(168,85,247,0.1);
  --orange:      #f97316;
  --orange-dim:  rgba(249,115,22,0.1);
  --sidebar-w:   240px;
  --radius-sm:   6px;
  --radius:      8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: 14px; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

@media (min-width: 1024px) {
  body.has-sidebar { padding-left: var(--sidebar-w); }
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 50;
  overflow-y: auto;
  overflow-x: hidden;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.4,0,0.2,1);
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }
@media (min-width: 1024px) { .sidebar { transform: translateX(0); } }
.sidebar.open { transform: translateX(0); }

.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 49;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { opacity: 1; pointer-events: auto; }

.sidebar-header {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.sidebar-nav { padding: 10px 8px; flex: 1; }
.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.sidebar-group { margin-bottom: 4px; }
.sidebar-group + .sidebar-group { margin-top: 16px; }
.sidebar-group-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 8px 6px;
}

/* Nav items */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 8px;
  border-radius: var(--radius);
  color: var(--text-2);
  text-decoration: none;
  font-size: 14px;
  font-weight: 400;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  min-height: 36px;
  border: none;
  background: transparent;
  font-family: inherit;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text-1); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); font-weight: 500; }
.nav-item [data-lucide], .nav-item svg {
  width: 16px; height: 16px; flex-shrink: 0; stroke-width: 1.5;
}
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 11px; font-weight: 500;
  border-radius: 9999px;
  padding: 1px 7px;
  min-width: 20px; text-align: center;
}
.nav-badge.amber { background: var(--yellow); color: #000; }

/* Mobile topbar */
.mobile-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 52px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky; top: 0; z-index: 40;
}
@media (min-width: 1024px) { .mobile-topbar { display: none; } }

/* ── Page layout ────────────────────────────────────────────────────────── */
.page-content { max-width: 960px; margin: 0 auto; padding: 28px 24px 88px; }
@media (max-width: 640px) { .page-content { padding: 20px 16px 80px; } }

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; gap: 12px; flex-wrap: wrap;
}
.page-title { font-size: 18px; font-weight: 600; color: var(--text-1); }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card     { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.card-sm  { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; }
.contact-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; transition: border-color 0.15s; }
.contact-card:hover { border-color: #3f3f46; }

/* ── Inputs ─────────────────────────────────────────────────────────────── */
.input-field {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text-1);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  width: 100%;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 38px;
}
.input-field::placeholder { color: var(--text-3); }
.input-field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.input-field:disabled { opacity: 0.4; cursor: not-allowed; }

select.input-field {
  appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2352525b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
  padding-right: 36px;
}
textarea.input-field { min-height: 80px; resize: vertical; }
input[type="file"].input-field { cursor: pointer; }
input[type="file"].input-field::file-selector-button {
  background: var(--accent); color: #fff; border: none; border-radius: var(--radius-sm);
  padding: 4px 10px; font-size: 12px; font-weight: 500; cursor: pointer; margin-right: 10px;
  font-family: inherit;
}

.label  { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.hint   { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: #fff;
  font-size: 14px; font-weight: 500; font-family: inherit;
  border: none; border-radius: var(--radius); padding: 8px 16px;
  min-height: 36px; cursor: pointer; text-decoration: none;
  transition: background 0.15s; white-space: nowrap;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { background: #1d4ed8; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface); color: var(--text-1);
  font-size: 14px; font-weight: 500; font-family: inherit;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 16px;
  min-height: 36px; cursor: pointer; text-decoration: none;
  transition: background 0.15s, border-color 0.15s; white-space: nowrap;
}
.btn-secondary:hover { background: var(--surface-hover); border-color: #3f3f46; }

.btn-ghost {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: transparent; color: var(--text-2);
  font-size: 14px; font-weight: 400; font-family: inherit;
  border: none; border-radius: var(--radius); padding: 8px 10px;
  min-height: 36px; cursor: pointer; text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text-1); }

.btn-danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--red-dim); color: #f87171;
  font-size: 14px; font-weight: 500; font-family: inherit;
  border: 1px solid rgba(239,68,68,0.2); border-radius: var(--radius); padding: 8px 16px;
  min-height: 36px; cursor: pointer; text-decoration: none; transition: background 0.15s;
}
.btn-danger:hover { background: rgba(239,68,68,0.18); }

/* Legacy btn-sm, btn-copy, btn-sent */
.btn-sm {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface); color: var(--text-1);
  font-size: 13px; font-weight: 500; font-family: inherit;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 12px;
  min-height: 32px; cursor: pointer; text-decoration: none;
  transition: background 0.15s; white-space: nowrap;
}
.btn-sm:hover { background: var(--surface-hover); }
.btn-copy {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface); color: var(--text-1);
  font-size: 13px; font-weight: 500; font-family: inherit;
  border: 1px solid var(--border); border-radius: var(--radius); padding: 7px 14px;
  min-height: 36px; cursor: pointer; transition: background 0.15s;
}
.btn-copy:hover { background: var(--surface-hover); }
.btn-sent {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--accent); color: #fff;
  font-size: 13px; font-weight: 500; font-family: inherit;
  border: none; border-radius: var(--radius); padding: 7px 14px;
  min-height: 36px; cursor: pointer; transition: background 0.15s;
}
.btn-sent:hover { background: var(--accent-hover); }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: var(--radius-sm); white-space: nowrap; }
.badge-blue   { background: var(--accent-dim);  color: #60a5fa; }
.badge-green  { background: var(--green-dim);   color: #4ade80; }
.badge-yellow { background: var(--yellow-dim);  color: #fbbf24; }
.badge-red    { background: var(--red-dim);     color: #f87171; }
.badge-purple { background: var(--purple-dim);  color: #c084fc; }
.badge-gray   { background: rgba(113,113,122,0.1); color: var(--text-3); }
.badge-orange { background: var(--orange-dim);  color: #fb923c; }

/* Status badges (CRM) */
.status-badge { display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 500; }
.status-queue       { background: rgba(113,113,122,0.1); color: #71717a; }
.status-sent        { background: var(--accent-dim); color: #60a5fa; }
.status-interested  { background: var(--green-dim); color: #4ade80; }
.status-order       { background: var(--purple-dim); color: #c084fc; }
.status-no_response { background: rgba(113,113,122,0.08); color: #52525b; }
.status-rejected    { background: var(--red-dim); color: #f87171; }
.status-blacklist   { background: rgba(0,0,0,0.3); color: #3f3f46; }
.status-recontact   { background: var(--yellow-dim); color: #fbbf24; }

/* ── Tabs ───────────────────────────────────────────────────────────────── */
.tabs-container {
  display: flex; gap: 0; overflow-x: auto;
  scrollbar-width: none; -ms-overflow-style: none;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 20px;
}
.tabs-container::-webkit-scrollbar { display: none; }
.tab-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px; font-size: 13px; font-weight: 400; font-family: inherit;
  color: var(--text-3); border-bottom: 2px solid transparent;
  margin-bottom: -1px; cursor: pointer; border-top: none; border-left: none; border-right: none;
  background: transparent; white-space: nowrap;
  transition: color 0.12s, border-color 0.12s; border-radius: 0;
}
.tab-btn:hover { color: var(--text-2); }
.tab-btn.active { color: var(--text-1); border-bottom-color: var(--accent); font-weight: 500; }

/* ── Section title ──────────────────────────────────────────────────────── */
.section-title { font-size: 11px; font-weight: 500; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.07em; }

/* ── Divider ────────────────────────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border-subtle); margin: 16px 0; }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.65);
  z-index: 60; display: flex; align-items: flex-end; justify-content: center;
  padding: 16px; backdrop-filter: blur(4px);
}
@media (min-width: 640px) { .modal-backdrop { align-items: center; } }
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 24px;
  width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto;
}

/* ── Toast ──────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; width: calc(100% - 32px); max-width: 360px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius-lg);
  font-size: 13px; font-weight: 500; font-family: inherit;
  border: 1px solid; pointer-events: auto;
  backdrop-filter: blur(12px);
}
.toast-success { background: rgba(34,197,94,0.12); border-color: rgba(34,197,94,0.25); color: #4ade80; }
.toast-error   { background: rgba(239,68,68,0.12);  border-color: rgba(239,68,68,0.25);  color: #f87171; }
.toast-info    { background: rgba(59,130,246,0.12); border-color: rgba(59,130,246,0.25); color: #60a5fa; }
@keyframes slideUp  { from { transform: translateY(12px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes fadeOut  { from { opacity: 1; } to { opacity: 0; transform: translateY(-6px); } }
.toast-enter { animation: slideUp 0.18s ease-out; }
.toast-exit  { animation: fadeOut 0.18s ease-in forwards; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-row   { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 640px) {
  .form-row-2 { grid-template-columns: 1fr 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
}
.form-field { display: flex; flex-direction: column; }

/* ── Msg textarea ───────────────────────────────────────────────────────── */
.msg-textarea {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 10px 12px; color: var(--text-1); font-size: 13px; font-family: inherit;
  resize: vertical; min-height: 96px; width: 100%; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.msg-textarea::placeholder { color: var(--text-3); }
.msg-textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

/* ── Status action btn ──────────────────────────────────────────────────── */
.status-action-btn {
  padding: 8px 12px; border-radius: var(--radius); font-size: 13px; font-weight: 500;
  font-family: inherit; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); cursor: pointer; text-align: center; min-height: 44px;
  transition: background 0.12s, color 0.12s;
}
.status-action-btn:hover { background: var(--surface-hover); color: var(--text-1); }

/* ── Legacy nav-link ────────────────────────────────────────────────────── */
.nav-link { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--radius); color: var(--text-2); text-decoration: none; font-size: 14px; min-height: 36px; transition: background 0.12s, color 0.12s; }
.nav-link:hover { background: var(--surface-hover); color: var(--text-1); }
.nav-link.active { background: var(--accent-dim); color: var(--accent); }

/* ── Accordion ──────────────────────────────────────────────────────────── */
.accordion-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.accordion-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px; cursor: pointer; user-select: none; gap: 12px;
  transition: background 0.12s;
}
.accordion-header:hover { background: var(--surface-hover); }
.accordion-chevron {
  color: var(--text-3); stroke-width: 1.5; flex-shrink: 0;
  transition: transform 0.22s cubic-bezier(0.4,0,0.2,1);
}
.accordion-section.open > .accordion-header .accordion-chevron { transform: rotate(180deg); }
.accordion-body { border-top: 0px solid var(--border-subtle); padding: 0 16px; overflow: hidden; height: 0; transition: height 0.3s cubic-bezier(0.4,0,0.2,1), padding-top 0.3s cubic-bezier(0.4,0,0.2,1), padding-bottom 0.3s cubic-bezier(0.4,0,0.2,1), border-top-width 0.3s cubic-bezier(0.4,0,0.2,1); }
.drag-handle {
  color: var(--text-3); cursor: grab; stroke-width: 1.5; flex-shrink: 0;
  opacity: 0.4; transition: opacity 0.15s;
}
.accordion-header:hover .drag-handle { opacity: 0.8; }
.drag-handle:active { cursor: grabbing; }
.sortable-ghost { opacity: 0.28; background: var(--accent-dim) !important; border-color: rgba(59,130,246,0.3) !important; }
.sortable-chosen { box-shadow: 0 10px 40px rgba(0,0,0,0.45); z-index: 10; position: relative; }

/* ── Tooltips ───────────────────────────────────────────────────────────── */
.tooltip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 5px;
  vertical-align: middle;
}
.tooltip-icon {
  width: 14px; height: 14px;
  border-radius: 9999px;
  border: 1px solid var(--text-3);
  color: var(--text-3);
  font-size: 9px; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: default; user-select: none; line-height: 1;
  transition: border-color 0.15s, color 0.15s;
  font-family: inherit;
  flex-shrink: 0;
}
.tooltip-wrap:hover .tooltip-icon,
.tooltip-wrap.open .tooltip-icon {
  border-color: var(--accent);
  color: var(--accent);
}
.tooltip-text {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  background: #1e1e22;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 11px;
  font-size: 12px; font-weight: 400;
  color: var(--text-2);
  line-height: 1.55;
  width: 230px;
  white-space: normal;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 80;
}
.tooltip-text::after {
  content: '';
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--border);
}
.tooltip-wrap:hover .tooltip-text,
.tooltip-wrap.open .tooltip-text { opacity: 1; }

/* ── Misc ───────────────────────────────────────────────────────────────── */
input[type="date"]     { color-scheme: dark; }
input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
.touch-target { min-height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }
[data-lucide] { width: 16px; height: 16px; stroke-width: 1.5; flex-shrink: 0; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3f3f46; }
