/* ============================================================
   Everkonnect Dashboard — Design System
   Brand: Indigo Blue · Pink/Coral · Purple · White
   ============================================================ */

:root {
  /* Brand palette (from logo) */
  --brand-blue: #2A2D8C;
  --brand-blue-600: #232578;
  --brand-blue-700: #1c1e63;
  --brand-pink: #EC5B6E;
  --brand-pink-600: #d94658;
  --brand-purple: #6C63FF;
  --brand-purple-600: #5B52E8;

  /* Gradients */
  --grad-primary: linear-gradient(135deg, #2A2D8C 0%, #6C63FF 55%, #EC5B6E 100%);
  --grad-soft:    linear-gradient(135deg, #eef0ff 0%, #fce7ec 100%);
  --grad-sidebar: linear-gradient(180deg, #2A2D8C 0%, #1c1e63 100%);

  /* Neutrals */
  --white: #ffffff;
  --bg: #f6f7fb;
  --bg-elev: #ffffff;
  --border: #e5e7ef;
  --border-strong: #d1d5e0;
  --text: #1c1f2a;
  --text-muted: #6b7086;
  --text-faint: #9aa0b4;

  /* Semantic */
  --success: #22c55e;
  --warning: #f59e0b;
  --danger:  #ef4444;
  --info:    #3b82f6;

  /* Layers */
  --shadow-sm: 0 1px 2px rgba(16, 18, 45, 0.06);
  --shadow-md: 0 4px 14px rgba(16, 18, 45, 0.08);
  --shadow-lg: 0 20px 40px rgba(16, 18, 45, 0.12);

  /* Radius & spacing */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  /* Layout */
  --sidebar-w: 260px;
  --topbar-h: 64px;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0 0 8px; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 12px; color: var(--text-muted); }

.hidden { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* ============================================================
   AUTH / LOGIN
   ============================================================ */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--grad-primary);
  position: relative;
  overflow: hidden;
}
.auth-shell::before, .auth-shell::after {
  content: '';
  position: absolute; border-radius: 50%;
  filter: blur(80px); opacity: 0.45; pointer-events: none;
}
.auth-shell::before { width: 500px; height: 500px; background: var(--brand-pink); top: -150px; right: -100px; }
.auth-shell::after  { width: 600px; height: 600px; background: var(--brand-purple); bottom: -200px; left: -150px; }

.auth-card {
  position: relative;
  z-index: 1;
  background: var(--white);
  width: min(420px, calc(100% - 32px));
  margin: auto;
  padding: 36px 32px;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  margin-bottom: 20px;
}
.auth-logo img { width: 64px; height: 64px; }
.auth-logo .brand {
  font-size: 1.35rem; font-weight: 800;
  background: var(--grad-primary); -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.auth-title { text-align: center; margin-bottom: 6px; }
.auth-subtitle { text-align: center; color: var(--text-muted); margin-bottom: 24px; }

/* ============================================================
   FORMS
   ============================================================ */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 0.82rem; font-weight: 600;
  color: var(--text); margin-bottom: 6px;
}
.input, .select, .textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--white);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand-purple);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.15);
}
.textarea { min-height: 96px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .field-row { grid-template-columns: 1fr; } }

.input-icon {
  position: relative;
}
.input-icon .input { padding-left: 40px; }
.input-icon svg {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); width: 18px; height: 18px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  background: var(--white);
  color: var(--text);
  border-radius: var(--radius);
  cursor: pointer; font-weight: 600;
  transition: transform .05s ease, box-shadow .15s, background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn:focus-visible { outline: 3px solid rgba(108,99,255,.3); outline-offset: 1px; }

.btn-primary {
  background: var(--grad-primary);
  color: var(--white); border-color: transparent;
  box-shadow: 0 4px 12px rgba(108, 99, 255, 0.25);
}
.btn-primary:hover { filter: brightness(1.05); box-shadow: 0 6px 16px rgba(108, 99, 255, 0.35); }

.btn-secondary {
  background: var(--white); color: var(--brand-blue);
  border-color: var(--brand-blue);
}
.btn-secondary:hover { background: #eef0ff; }

.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; }
.btn-ghost:hover { background: rgba(0,0,0,0.05); color: var(--text); }

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #dc2626; }

.btn-sm { padding: 6px 12px; font-size: 0.82rem; border-radius: 8px; }
.btn-block { width: 100%; }

.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   DASHBOARD SHELL
   ============================================================ */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--grad-sidebar);
  color: var(--white);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 50;
}
.sidebar-header {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar-header img { width: 36px; height: 36px; border-radius: 8px; background: white; padding: 2px; }
.sidebar-header .brand { font-weight: 800; font-size: 1.05rem; letter-spacing: -0.01em; }
.sidebar-nav {
  flex: 1; overflow-y: auto;
  padding: 16px 10px;
  display: flex; flex-direction: column; gap: 4px;
}
.sidebar-section {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: rgba(255,255,255,0.55);
  padding: 12px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  color: rgba(255,255,255,0.82);
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s, color .15s;
  font-size: 0.92rem;
  font-weight: 500;
}
.nav-item:hover { background: rgba(255,255,255,0.08); color: #fff; text-decoration: none; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(236,91,110,0.25), rgba(108,99,255,0.25));
  color: #fff;
  box-shadow: inset 3px 0 0 var(--brand-pink);
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto; background: var(--brand-pink); color: #fff;
  font-size: 0.7rem; padding: 2px 7px; border-radius: 10px; font-weight: 700;
}
.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-footer .avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--grad-primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff;
}
.sidebar-footer .meta { flex: 1; min-width: 0; }
.sidebar-footer .name { font-weight: 600; font-size: 0.9rem; color: #fff; }
.sidebar-footer .role { font-size: 0.75rem; color: rgba(255,255,255,0.6); text-transform: capitalize; }
.sidebar-footer .logout-btn {
  background: rgba(255,255,255,0.08); color: #fff; border: 0;
  width: 34px; height: 34px; border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-footer .logout-btn:hover { background: var(--brand-pink); }

/* Backdrop for mobile sidebar */
.sidebar-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(16,18,45,0.5);
  z-index: 49;
}

/* Main */
.main { display: flex; flex-direction: column; min-width: 0; }

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 40;
}
.topbar .menu-btn {
  display: none;
  background: transparent; border: 0; cursor: pointer;
  width: 40px; height: 40px; border-radius: 8px;
  align-items: center; justify-content: center;
  color: var(--text);
}
.topbar .menu-btn:hover { background: var(--bg); }
.topbar .page-title {
  font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em;
  color: var(--text);
}
.topbar-spacer { flex: 1; }
.topbar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg);
}
.topbar-user .avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--grad-primary);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 0.82rem;
}
.topbar-user .info { line-height: 1.2; }
.topbar-user .name { font-weight: 600; font-size: 0.85rem; }
.topbar-user .role { font-size: 0.72rem; color: var(--text-muted); text-transform: capitalize; }

/* Content */
.content {
  padding: 24px;
  flex: 1;
}
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 20px;
}
.page-header .title { font-size: 1.5rem; font-weight: 800; margin: 0 0 4px; }
.page-header .subtitle { color: var(--text-muted); margin: 0; }

/* ============================================================
   CARDS, KPIs
   ============================================================ */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: 1rem; font-weight: 700; margin: 0 0 4px;
  display: flex; align-items: center; gap: 8px;
}
.card-subtitle { color: var(--text-muted); font-size: 0.85rem; margin: 0 0 14px; }

.kpi-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.kpi {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-icon {
  width: 44px; height: 44px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--grad-soft); color: var(--brand-blue);
  flex-shrink: 0;
}
.kpi-icon svg { width: 22px; height: 22px; }
.kpi-icon.pink   { background: #fde7eb; color: var(--brand-pink); }
.kpi-icon.purple { background: #ece9ff; color: var(--brand-purple); }
.kpi-icon.green  { background: #dcfce7; color: #16a34a; }
.kpi-icon.amber  { background: #fef3c7; color: #b45309; }
.kpi-icon.red    { background: #fee2e2; color: var(--danger); }
.kpi-icon.blue   { background: #dbeafe; color: #2563eb; }
.kpi-label { font-size: 0.8rem; color: var(--text-muted); margin: 0 0 2px; font-weight: 500; }
.kpi-value { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; margin: 0; }
.kpi-sub { font-size: 0.75rem; color: var(--text-faint); margin: 2px 0 0; }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.table-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafbff;
}
.table-toolbar .grow { flex: 1; min-width: 180px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}
table.data th, table.data td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 0.88rem;
}
table.data th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: #fafbff;
  position: sticky; top: 0;
}
table.data tbody tr:hover { background: #f8f9ff; }
table.data tbody tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-top: 1px solid var(--border);
  background: #fafbff; flex-wrap: wrap; gap: 8px;
}
.pagination .info { color: var(--text-muted); font-size: 0.82rem; }
.pagination .controls { display: flex; gap: 6px; align-items: center; }

/* Badges & pills */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #eef0ff;
  color: var(--brand-blue);
  text-transform: capitalize;
  white-space: nowrap;
}
.badge.green  { background: #dcfce7; color: #166534; }
.badge.red    { background: #fee2e2; color: #991b1b; }
.badge.amber  { background: #fef3c7; color: #92400e; }
.badge.blue   { background: #dbeafe; color: #1e40af; }
.badge.pink   { background: #fce7ec; color: #9d174d; }
.badge.purple { background: #ece9ff; color: #4338ca; }
.badge.gray   { background: #eef0f4; color: #475569; }

/* ============================================================
   TICKETS / MESSAGES / THREAD
   ============================================================ */
.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  align-items: start;
}
@media (max-width: 960px) { .two-col { grid-template-columns: 1fr; } }

.thread { display: flex; flex-direction: column; gap: 12px; }
.message {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
}
.message.staff { border-color: #c7d2fe; background: #eef2ff; }
.message.internal { border-color: #fde68a; background: #fffbeb; }
.message .meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 0.78rem; color: var(--text-muted); margin-bottom: 4px;
}
.message .content { white-space: pre-wrap; color: var(--text); }

.composer {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  position: sticky; bottom: 16px;
}
.composer .toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.composer .toggle {
  display: inline-flex; align-items: center; gap: 6px; font-size: 0.85rem;
  color: var(--text-muted); cursor: pointer;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(16,18,45,0.6);
  z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--white);
  width: min(560px, 100%);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh; overflow-y: auto;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 12px;
}
.modal-header h3 { margin: 0; }
.modal-close {
  background: transparent; border: 0; cursor: pointer; width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); border-radius: 8px;
}
.modal-close:hover { background: var(--bg); }
.modal-footer {
  margin-top: 16px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
  position: fixed; top: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 200;
  max-width: calc(100% - 40px);
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  display: flex; align-items: center; gap: 10px;
  animation: slideIn .25s ease-out;
  min-width: 240px;
  max-width: 400px;
}
.toast.success { background: #16a34a; }
.toast.error { background: var(--danger); }
.toast.info { background: var(--brand-blue); }
.toast.warning { background: #d97706; }
@keyframes slideIn {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ============================================================
   MISC
   ============================================================ */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.spinner.dark {
  border-color: rgba(108,99,255,0.2);
  border-top-color: var(--brand-purple);
}
@keyframes spin { to { transform: rotate(360deg); } }

.center-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}
.center-state .emoji { font-size: 2.5rem; margin-bottom: 8px; }
.center-state .title { font-weight: 700; color: var(--text); margin-bottom: 4px; }

.skeleton {
  background: linear-gradient(90deg, #eef0f4 25%, #f6f7fb 50%, #eef0f4 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 8px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.tight { gap: 6px; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack.tight { gap: 6px; }

.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; font-size: 0.88rem; }
.kv dt { color: var(--text-muted); font-weight: 500; }
.kv dd { margin: 0; color: var(--text); font-weight: 500; }
@media (max-width: 480px) {
  .kv { grid-template-columns: 1fr; }
  .kv dd { margin-bottom: 6px; }
}

.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid .full { grid-column: 1 / -1; }

/* Segmented tabs */
.tabs {
  display: inline-flex; padding: 4px; background: var(--bg);
  border-radius: 12px; gap: 2px; flex-wrap: wrap;
}
.tabs .tab {
  padding: 8px 14px; border-radius: 8px; cursor: pointer;
  font-weight: 600; font-size: 0.86rem; color: var(--text-muted);
  background: transparent; border: 0;
}
.tabs .tab.active { background: var(--white); color: var(--brand-blue); box-shadow: var(--shadow-sm); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: 280px; transform: translateX(-100%);
    transition: transform .22s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar.open + .sidebar-backdrop { display: block; }
  .topbar .menu-btn { display: inline-flex; }
  .content { padding: 16px; }
}
@media (max-width: 560px) {
  .page-header .title { font-size: 1.25rem; }
  .kpi-value { font-size: 1.3rem; }
  .topbar-user .info { display: none; }
}
