/* Kairos CRM — Shared Styles */

:root {
  --navy:       #0D1F3C;
  --navy-light: #132947;
  --navy-mid:   #1A3558;
  --blue:       #1B6CA8;
  --blue-mid:   #4A8FC0;
  --gold:       #C8960C;
  --gold-dim:   #A07808;
  --gold-light: #E8B020;
  --text:       #E2E8F0;
  --text-dim:   #94A3B8;
  --text-muted: #64748B;
  --danger:     #E53E3E;
  --success:    #38A169;
  --border:     rgba(200, 150, 12, 0.18);
  --card-bg:    rgba(19, 41, 71, 0.7);
  --radius:     6px;
  --radius-lg:  10px;
  --shadow:     0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-sm:  0 2px 8px rgba(0, 0, 0, 0.3);
  --sidebar-w:  240px;
  --header-h:   60px;
  --transition: 0.18s ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--navy);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ─── Typography ───────────────────────────────────── */

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
h4 { font-size: 0.95rem; }

p { color: var(--text-dim); }

a {
  color: var(--blue-mid);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover { color: var(--gold-light); }

/* ─── Buttons ──────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.btn-primary {
  background: var(--blue);
  color: #fff;
  border: 1px solid transparent;
}

.btn-primary:hover {
  background: #1a5c8f;
  border-color: var(--gold-dim);
  box-shadow: 0 0 12px rgba(200, 150, 12, 0.2);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--navy-mid);
  color: var(--text);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(229, 62, 62, 0.3);
}

.btn-danger:hover {
  background: rgba(229, 62, 62, 0.1);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-full { width: 100%; justify-content: center; }

/* ─── Forms ────────────────────────────────────────── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
textarea,
select {
  width: 100%;
  background: var(--navy-mid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.95rem;
  padding: 10px 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 3px rgba(200, 150, 12, 0.12);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

/* ─── Cards ────────────────────────────────────────── */

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(8px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ─── Badge ────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.badge-gold  { background: rgba(200, 150, 12, 0.15); color: var(--gold-light); border: 1px solid rgba(200, 150, 12, 0.3); }
.badge-blue  { background: rgba(27, 108, 168, 0.2);  color: var(--blue-mid);   border: 1px solid rgba(74, 143, 192, 0.3); }
.badge-green { background: rgba(56, 161, 105, 0.15); color: #68D391;           border: 1px solid rgba(56, 161, 105, 0.3); }
.badge-red   { background: rgba(229, 62, 62, 0.15);  color: #FC8181;           border: 1px solid rgba(229, 62, 62, 0.3); }

/* ─── Sidebar ──────────────────────────────────────── */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--navy);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-logo-mark svg {
  width: 32px;
  height: 32px;
  display: block;
}

.sidebar-logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.sidebar-logo-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.04em;
}

.sidebar-logo-sub {
  font-size: 0.68rem;
  color: var(--gold);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 12px 0;
  flex: 1;
}

.nav-section-label {
  padding: 12px 20px 4px;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--text-dim);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  text-decoration: none;
  position: relative;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border-left-color: var(--navy-mid);
}

.nav-item.active {
  color: var(--gold-light);
  background: rgba(200, 150, 12, 0.08);
  border-left-color: var(--gold);
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.7;
}

.nav-item.active svg,
.nav-item:hover svg {
  opacity: 1;
}

.nav-item .badge {
  margin-left: auto;
  font-size: 0.65rem;
  padding: 1px 6px;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius);
  transition: background var(--transition);
  cursor: pointer;
}

.user-info:hover { background: rgba(255,255,255,0.04); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  border: 2px solid var(--gold-dim);
}

.user-details { flex: 1; min-width: 0; }

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.7rem;
  color: var(--gold-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── App Layout ───────────────────────────────────── */

.app-layout {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.top-bar {
  height: var(--header-h);
  background: var(--navy-light);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.page-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-content {
  flex: 1;
  padding: 28px;
}

/* ─── Grid Utilities ───────────────────────────────── */

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.grid-5 { display: grid; grid-template-columns: repeat(5, 1fr); gap: 20px; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
}

/* ─── Stat Card ────────────────────────────────────── */

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  backdrop-filter: blur(8px);
  transition: border-color var(--transition);
}

.stat-card:hover { border-color: rgba(200, 150, 12, 0.35); }

.stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(200, 150, 12, 0.12);
  border: 1px solid rgba(200, 150, 12, 0.2);
  flex-shrink: 0;
}

.stat-icon svg {
  width: 18px;
  height: 18px;
  stroke: var(--gold);
}

/* ─── Table ────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: var(--navy-light);
  padding: 11px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid rgba(200, 150, 12, 0.07);
  transition: background var(--transition);
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.03); }

tbody td {
  padding: 12px 16px;
  color: var(--text-dim);
  vertical-align: middle;
}

tbody td:first-child { color: var(--text); }

/* ─── Alert / Notice ───────────────────────────────── */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  border: 1px solid;
  margin-bottom: 16px;
}

.alert-error {
  background: rgba(229, 62, 62, 0.1);
  border-color: rgba(229, 62, 62, 0.3);
  color: #FC8181;
}

.alert-success {
  background: rgba(56, 161, 105, 0.1);
  border-color: rgba(56, 161, 105, 0.3);
  color: #68D391;
}

.alert-info {
  background: rgba(27, 108, 168, 0.12);
  border-color: rgba(74, 143, 192, 0.3);
  color: var(--blue-mid);
}

/* ─── Empty State ──────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
  gap: 12px;
}

.empty-state svg {
  width: 40px;
  height: 40px;
  stroke: var(--text-muted);
  opacity: 0.5;
}

.empty-state h3 { color: var(--text-dim); font-size: 1rem; }

/* ─── Divider ──────────────────────────────────────── */

.divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* ─── Gold accent line ─────────────────────────────── */

.gold-rule {
  height: 2px;
  background: linear-gradient(90deg, var(--gold) 0%, transparent 100%);
  border: none;
  margin: 0;
}

/* ─── Spinner ──────────────────────────────────────── */

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── Scrollbar ────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--navy-mid); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Utility ──────────────────────────────────────── */

.flex        { display: flex; }
.flex-col    { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.gap-16      { gap: 16px; }
.gap-20      { gap: 20px; }
.mb-4        { margin-bottom: 4px; }
.mb-8        { margin-bottom: 8px; }
.mb-16       { margin-bottom: 16px; }
.mb-24       { margin-bottom: 24px; }
.mt-16       { margin-top: 16px; }
.mt-24       { margin-top: 24px; }
.text-sm     { font-size: 0.825rem; }
.text-xs     { font-size: 0.75rem; }
.text-muted  { color: var(--text-muted); }
.text-dim    { color: var(--text-dim); }
.text-gold   { color: var(--gold); }
.text-right  { text-align: right; }
.hidden      { display: none !important; }
.w-full      { width: 100%; }

/* ─── Tag picker ──────────────────────────────────────────── */

.tag-picker {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tp-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 36px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-items: center;
}

.tp-empty {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.tp-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: rgba(27,108,168,0.25);
  border: 1px solid rgba(27,108,168,0.5);
  border-radius: 20px;
  font-size: 0.74rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition);
}
.tp-badge:hover { background: rgba(27,108,168,0.4); }

.tp-groups {
  max-height: 260px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--navy-mid) transparent;
}

.tp-group-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-bottom: 5px;
}

.tp-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tp-chip {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 400;
  border: 1px solid rgba(200,150,12,0.25);
  background: rgba(200,150,12,0.06);
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.tp-chip:hover { border-color: var(--gold-dim); color: var(--text); }
.tp-chip.selected {
  background: rgba(27,108,168,0.3);
  border-color: var(--blue-mid);
  color: var(--text);
  font-weight: 500;
}

/* ─── Profile tag display ─────────────────────────────────── */

.profile-tags {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.profile-tag-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.profile-tag-category {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-right: 2px;
  flex-shrink: 0;
}

.tag-freetext {
  border-color: rgba(200,150,12,0.2) !important;
  background: rgba(200,150,12,0.05) !important;
  color: var(--text-muted) !important;
}

/* ─── Tag filter select ───────────────────────────────────── */

.filter-tag-select {
  height: 34px;
  padding: 0 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.82rem;
  cursor: pointer;
  min-width: 160px;
}
