/* ============================================================
   TRIGYA AI — Design tokens
   Palette: deep indigo base, marigold accent (festival energy),
   teal secondary. Sora for display, Inter for body, JetBrains
   Mono for data/utility text.
   ============================================================ */
:root{
  --indigo-950:#0E1128;
  --indigo-900:#151A38;
  --indigo-800:#1B1F3B;
  --indigo-700:#242A52;
  --indigo-600:#323972;
  --indigo-100:#E7E8F5;
  --marigold-500:#FFB020;
  --marigold-600:#F09400;
  --marigold-100:#FFF1D6;
  --teal-500:#14B8A6;
  --teal-600:#0E9488;
  --teal-100:#DAFBF4;
  --red-500:#EF4444;
  --red-100:#FDE2E2;
  --green-500:#22C55E;

  --bg:#F6F7FB;
  --surface:#FFFFFF;
  --surface-2:#F0F1F8;
  --border:#E3E5F0;
  --text:#161A34;
  --text-muted:#5B6088;
  --text-faint:#8B8FB2;

  --radius-sm:10px;
  --radius-md:16px;
  --radius-lg:22px;
  --shadow-sm:0 1px 2px rgba(20,20,50,.06), 0 1px 1px rgba(20,20,50,.04);
  --shadow-md:0 8px 24px rgba(20,20,60,.08);
  --shadow-lg:0 20px 48px rgba(20,20,60,.14);

  --font-display:'Sora',sans-serif;
  --font-body:'Inter',sans-serif;
  --font-mono:'JetBrains Mono',monospace;

  --sidebar-w:264px;
}

[data-theme="dark"]{
  --bg:#0B0E22;
  --surface:#151A38;
  --surface-2:#1B1F3B;
  --border:#2A2F55;
  --text:#F1F2FA;
  --text-muted:#A6AAD4;
  --text-faint:#6E73A0;
  --shadow-md:0 8px 24px rgba(0,0,0,.35);
  --shadow-lg:0 20px 48px rgba(0,0,0,.5);
}

*{box-sizing:border-box;}
html,body{margin:0;padding:0;}
body{
  background:var(--bg);
  color:var(--text);
  font-family:var(--font-body);
  -webkit-font-smoothing:antialiased;
  transition:background .25s ease,color .25s ease;
}
h1,h2,h3,h4{font-family:var(--font-display); margin:0; letter-spacing:-0.01em;}
p{margin:0;}
button,input,select,textarea{font-family:inherit;}
a{color:inherit;}
::selection{background:var(--marigold-100); color:var(--indigo-900);}

.muted{color:var(--text-muted);}
.mono{font-family:var(--font-mono);}

/* ---------- Buttons ---------- */
.btn{
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  border:none; border-radius:12px; padding:11px 18px; font-weight:600; font-size:14.5px;
  cursor:pointer; transition:transform .15s ease, box-shadow .15s ease, background .15s ease, opacity .15s;
  white-space:nowrap;
}
.btn:active{transform:scale(0.97);}
.btn-primary{background:var(--marigold-500); color:#231400; box-shadow:0 4px 14px rgba(255,176,32,.35);}
.btn-primary:hover{background:var(--marigold-600);}
.btn-secondary{background:var(--indigo-800); color:#fff;}
.btn-secondary:hover{background:var(--indigo-700);}
[data-theme="dark"] .btn-secondary{background:var(--indigo-600);}
.btn-teal{background:var(--teal-500); color:#00332e;}
.btn-teal:hover{background:var(--teal-600);}
.btn-ghost{background:transparent; color:var(--text); border:1px solid var(--border);}
.btn-ghost:hover{background:var(--surface-2);}
.btn-danger-ghost{background:transparent; color:var(--red-500); border:1px solid var(--border);}
.btn-danger-ghost:hover{background:var(--red-100);}
.btn-sm{padding:7px 12px; font-size:13px; border-radius:9px;}
.btn-block{width:100%;}
.btn:disabled{opacity:.5; cursor:not-allowed;}
.icon-btn{
  background:transparent; border:none; font-size:20px; cursor:pointer; color:var(--text);
  width:38px; height:38px; border-radius:10px; display:flex; align-items:center; justify-content:center;
}
.icon-btn:hover{background:var(--surface-2);}

/* ---------- Login ---------- */
.login-screen{
  min-height:100vh; display:flex; align-items:center; justify-content:center;
  background:
    radial-gradient(circle at 15% 15%, rgba(255,176,32,.18), transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(20,184,166,.18), transparent 40%),
    var(--indigo-950);
  padding:24px;
}
.login-card{
  width:100%; max-width:400px; background:var(--surface); border-radius:var(--radius-lg);
  padding:36px 32px; box-shadow:var(--shadow-lg);
}
.brand-mark{display:flex; align-items:center; gap:12px; margin-bottom:26px;}
.brand-name{font-family:var(--font-display); font-weight:800; font-size:17px; letter-spacing:.02em;}
.brand-name.small{font-size:14.5px;}
.brand-tag{font-size:11.5px; color:var(--text-muted); text-transform:uppercase; letter-spacing:.06em; margin-top:1px;}
.brand-tag.small{font-size:10.5px;}
.login-card h1{font-size:23px; margin-bottom:4px;}
.login-card .muted{font-size:13.5px; display:block; margin-bottom:22px;}
#login-form label{display:block; font-size:13px; font-weight:600; color:var(--text-muted); margin-bottom:14px;}
#login-form input{
  display:block; width:100%; margin-top:6px; padding:11px 13px; border-radius:10px;
  border:1.5px solid var(--border); background:var(--bg); color:var(--text); font-size:14.5px;
}
#login-form input:focus{outline:2px solid var(--marigold-500); outline-offset:1px; border-color:var(--marigold-500);}
.form-error{background:var(--red-100); color:#8f1d1d; padding:9px 12px; border-radius:9px; font-size:13px; margin-bottom:14px;}
.login-hint{font-size:11.5px; color:var(--text-faint); text-align:center; margin-top:18px;}
.login-hint code{background:var(--surface-2); padding:2px 5px; border-radius:5px;}

/* ---------- App shell ---------- */
.app-shell{display:flex; min-height:100vh;}
.sidebar{
  width:var(--sidebar-w); flex-shrink:0; background:var(--indigo-900); color:#fff;
  display:flex; flex-direction:column; padding:22px 16px; position:sticky; top:0; height:100vh;
}
.sidebar-brand{display:flex; align-items:center; gap:11px; padding:6px 8px 22px;}
.sidebar .brand-name.small, .sidebar .brand-tag.small{color:#fff;}
.sidebar .brand-tag.small{color:var(--marigold-500); opacity:.9;}
.nav-list{display:flex; flex-direction:column; gap:2px; flex:1; overflow-y:auto;}
.nav-item{
  display:flex; align-items:center; gap:12px; padding:10.5px 12px; border-radius:11px;
  color:#C7C9E6; text-decoration:none; font-size:14px; font-weight:500; cursor:pointer;
  border:1px solid transparent;
}
.nav-item:hover{background:rgba(255,255,255,.06); color:#fff;}
.nav-item.active{background:linear-gradient(135deg, rgba(255,176,32,.18), rgba(255,176,32,.06)); color:#fff; border-color:rgba(255,176,32,.35);}
.nav-item .nav-ico{width:19px; text-align:center;}
.sidebar-footer{display:flex; flex-direction:column; gap:8px; padding-top:14px; border-top:1px solid rgba(255,255,255,.08);}
.sidebar-footer .btn-ghost{color:#fff; border-color:rgba(255,255,255,.16);}
.sidebar-footer .btn-ghost:hover{background:rgba(255,255,255,.08);}

.mobile-topbar{display:none;}
.mobile-drawer{display:none;}

.main-content{flex:1; min-width:0; padding:28px 34px 60px;}
.page-root{max-width:1180px; margin:0 auto; animation:fadeIn .25s ease;}
@keyframes fadeIn{from{opacity:0; transform:translateY(6px);} to{opacity:1; transform:none;}}

/* ---------- Page header ---------- */
.page-header{display:flex; align-items:flex-end; justify-content:space-between; gap:18px; margin-bottom:24px; flex-wrap:wrap;}
.page-header h1{font-size:26px; font-weight:700;}
.page-header .eyebrow{font-size:12px; font-weight:700; text-transform:uppercase; letter-spacing:.08em; color:var(--marigold-600); margin-bottom:5px;}
.page-header p{color:var(--text-muted); font-size:14px; margin-top:6px; max-width:560px;}

/* ---------- Cards / grids ---------- */
.grid{display:grid; gap:18px;}
.grid-4{grid-template-columns:repeat(4,1fr);}
.grid-3{grid-template-columns:repeat(3,1fr);}
.grid-2{grid-template-columns:repeat(2,1fr);}
@media(max-width:1000px){.grid-4{grid-template-columns:repeat(2,1fr);} .grid-3{grid-template-columns:repeat(2,1fr);}}
@media(max-width:640px){.grid-4,.grid-3,.grid-2{grid-template-columns:1fr;}}

.card{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-md);
  padding:20px; box-shadow:var(--shadow-sm); transition:box-shadow .18s ease, transform .18s ease;
}
.card.hoverable:hover{box-shadow:var(--shadow-md); transform:translateY(-2px);}
.stat-card{display:flex; flex-direction:column; gap:8px;}
.stat-card .stat-label{font-size:12.5px; color:var(--text-muted); font-weight:600; text-transform:uppercase; letter-spacing:.04em;}
.stat-card .stat-value{font-family:var(--font-display); font-size:30px; font-weight:800;}
.stat-card .stat-icon{width:38px; height:38px; border-radius:10px; display:flex; align-items:center; justify-content:center; font-size:18px; margin-bottom:2px;}

.quick-action{
  display:flex; align-items:center; gap:12px; padding:15px 16px; border-radius:14px;
  border:1px solid var(--border); background:var(--surface); cursor:pointer; text-align:left;
  transition:all .15s ease;
}
.quick-action:hover{border-color:var(--marigold-500); box-shadow:var(--shadow-sm); transform:translateY(-1px);}
.quick-action .qa-ico{
  width:38px; height:38px; border-radius:10px; background:var(--marigold-100); color:var(--marigold-600);
  display:flex; align-items:center; justify-content:center; font-size:17px; flex-shrink:0;
}
[data-theme="dark"] .quick-action .qa-ico{background:rgba(255,176,32,.14);}
.quick-action .qa-title{font-weight:600; font-size:14px;}
.quick-action .qa-sub{font-size:12px; color:var(--text-muted);}

/* ---------- Forms ---------- */
.form-grid{display:grid; grid-template-columns:1fr 1fr; gap:16px;}
@media(max-width:760px){.form-grid{grid-template-columns:1fr;}}
.field{display:flex; flex-direction:column; gap:6px;}
.field.full{grid-column:1/-1;}
.field label{font-size:13px; font-weight:600; color:var(--text-muted);}
.field input, .field select, .field textarea{
  padding:10px 12px; border-radius:10px; border:1.5px solid var(--border); background:var(--bg);
  color:var(--text); font-size:14px; width:100%;
}
.field textarea{resize:vertical; min-height:80px;}
.field input:focus, .field select:focus, .field textarea:focus{outline:2px solid var(--marigold-500); outline-offset:1px; border-color:var(--marigold-500);}
.field .hint{font-size:11.5px; color:var(--text-faint);}
.chip-select{display:flex; flex-wrap:wrap; gap:8px;}
.chip{
  padding:7px 13px; border-radius:999px; border:1.5px solid var(--border); background:var(--surface);
  font-size:13px; font-weight:600; cursor:pointer; color:var(--text-muted); transition:all .15s;
}
.chip.active{background:var(--indigo-800); color:#fff; border-color:var(--indigo-800);}
[data-theme="dark"] .chip.active{background:var(--marigold-500); color:#231400; border-color:var(--marigold-500);}

/* ---------- Result / output blocks ---------- */
.result-panel{background:var(--surface-2); border:1px dashed var(--border); border-radius:var(--radius-md); padding:20px; margin-top:20px;}
.result-panel h4{font-size:13px; text-transform:uppercase; letter-spacing:.05em; color:var(--text-muted); margin-bottom:6px;}
.result-block{white-space:pre-wrap; font-size:14.5px; line-height:1.65;}
.result-actions{display:flex; gap:8px; flex-wrap:wrap; margin-top:16px;}
.hashtag-row{display:flex; flex-wrap:wrap; gap:6px; margin-top:6px;}
.hashtag{background:var(--teal-100); color:var(--teal-600); font-size:12.5px; font-weight:600; padding:4px 10px; border-radius:999px;}
[data-theme="dark"] .hashtag{background:rgba(20,184,166,.16);}

/* ---------- Chat ---------- */
.chat-wrap{display:flex; flex-direction:column; height:calc(100vh - 140px); background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg); overflow:hidden;}
.chat-messages{flex:1; overflow-y:auto; padding:22px; display:flex; flex-direction:column; gap:16px;}
.msg{max-width:78%; padding:13px 16px; border-radius:16px; font-size:14.5px; line-height:1.6; white-space:pre-wrap;}
.msg.user{align-self:flex-end; background:var(--indigo-800); color:#fff; border-bottom-right-radius:4px;}
.msg.ai{align-self:flex-start; background:var(--surface-2); border:1px solid var(--border); border-bottom-left-radius:4px;}
.msg .msg-actions{display:flex; gap:6px; margin-top:10px; flex-wrap:wrap;}
.msg .msg-actions button{background:transparent; border:1px solid var(--border); color:var(--text-muted); font-size:11.5px; padding:4px 9px; border-radius:7px; cursor:pointer;}
.msg .msg-actions button:hover{color:var(--text); border-color:var(--text-muted);}
.chat-input-row{display:flex; gap:10px; padding:16px; border-top:1px solid var(--border);}
.chat-input-row textarea{flex:1; resize:none; border-radius:12px; border:1.5px solid var(--border); background:var(--bg); color:var(--text); padding:11px 14px; font-size:14.5px; max-height:120px;}
.chat-input-row textarea:focus{outline:2px solid var(--marigold-500); border-color:var(--marigold-500);}
.typing-dots span{display:inline-block; width:6px; height:6px; border-radius:50%; background:var(--text-faint); margin-right:3px; animation:bounce 1.1s infinite;}
.typing-dots span:nth-child(2){animation-delay:.15s;} .typing-dots span:nth-child(3){animation-delay:.3s;}
@keyframes bounce{0%,60%,100%{transform:translateY(0); opacity:.5;} 30%{transform:translateY(-4px); opacity:1;}}

/* ---------- Table ---------- */
.table-wrap{overflow-x:auto; border:1px solid var(--border); border-radius:var(--radius-md); background:var(--surface);}
table{width:100%; border-collapse:collapse; font-size:13.5px;}
th,td{text-align:left; padding:12px 16px; border-bottom:1px solid var(--border); white-space:nowrap;}
th{font-size:11.5px; text-transform:uppercase; letter-spacing:.04em; color:var(--text-muted); background:var(--surface-2);}
tr:last-child td{border-bottom:none;}
.avatar-circle{width:30px; height:30px; border-radius:50%; background:var(--indigo-800); color:#fff; display:inline-flex; align-items:center; justify-content:center; font-size:12px; font-weight:700; margin-right:8px;}
.badge{display:inline-block; padding:3px 9px; border-radius:999px; font-size:11px; font-weight:700;}
.badge.green{background:var(--teal-100); color:var(--teal-600);} [data-theme="dark"] .badge.green{background:rgba(20,184,166,.16);}
.badge.amber{background:var(--marigold-100); color:var(--marigold-600);} [data-theme="dark"] .badge.amber{background:rgba(255,176,32,.16);}
.badge.gray{background:var(--surface-2); color:var(--text-muted);}

/* ---------- Empty / loading / error states ---------- */
.empty-state{text-align:center; padding:60px 20px; color:var(--text-muted);}
.empty-state .es-ico{font-size:34px; margin-bottom:10px;}
.empty-state h3{font-size:16px; color:var(--text); margin-bottom:6px;}
.empty-state p{font-size:13.5px; max-width:340px; margin:0 auto;}
.skeleton{background:linear-gradient(90deg, var(--surface-2) 25%, var(--border) 37%, var(--surface-2) 63%); background-size:400% 100%; animation:shimmer 1.4s infinite; border-radius:8px;}
@keyframes shimmer{0%{background-position:100% 0;} 100%{background-position:0 0;}}

/* ---------- Modal ---------- */
.modal-backdrop{position:fixed; inset:0; background:rgba(10,12,30,.55); display:flex; align-items:center; justify-content:center; z-index:200; padding:20px; animation:fadeIn .15s ease;}
.modal{background:var(--surface); border-radius:var(--radius-lg); padding:26px; width:100%; max-width:560px; max-height:88vh; overflow-y:auto; box-shadow:var(--shadow-lg);}
.modal-head{display:flex; align-items:center; justify-content:space-between; margin-bottom:18px;}
.modal-head h3{font-size:18px;}

/* ---------- Toasts ---------- */
.toast-root{position:fixed; bottom:22px; right:22px; display:flex; flex-direction:column; gap:10px; z-index:300;}
.toast{background:var(--indigo-900); color:#fff; padding:12px 18px; border-radius:11px; font-size:13.5px; box-shadow:var(--shadow-lg); display:flex; align-items:center; gap:10px; animation:slideIn .2s ease;}
.toast.success{background:#0f5132;} .toast.error{background:#6b1414;}
@keyframes slideIn{from{opacity:0; transform:translateX(20px);} to{opacity:1; transform:none;}}

/* ---------- Section / tabs ---------- */
.tabs{display:flex; gap:6px; border-bottom:1px solid var(--border); margin-bottom:22px; flex-wrap:wrap;}
.tab{padding:10px 4px; margin-right:18px; font-size:14px; font-weight:600; color:var(--text-muted); cursor:pointer; border-bottom:2.5px solid transparent;}
.tab.active{color:var(--text); border-color:var(--marigold-500);}
.section-title{font-size:13px; font-weight:700; text-transform:uppercase; letter-spacing:.05em; color:var(--text-muted); margin:26px 0 12px;}
.section-title:first-child{margin-top:0;}

/* ---------- Responsive: mobile ---------- */
@media(max-width:900px){
  .sidebar{display:none;}
  .mobile-topbar{
    display:flex; align-items:center; justify-content:space-between; padding:12px 16px;
    background:var(--surface); border-bottom:1px solid var(--border); position:sticky; top:0; z-index:100;
  }
  .app-shell{flex-direction:column;}
  .main-content{padding:20px 16px 50px;}
  .mobile-drawer{display:block; position:fixed; inset:0; z-index:250; pointer-events:none;}
  .mobile-drawer-inner{
    position:absolute; top:0; left:0; bottom:0; width:78%; max-width:290px; background:var(--indigo-900);
    color:#fff; padding:20px 16px; transform:translateX(-100%); transition:transform .22s ease; display:flex; flex-direction:column;
  }
  .mobile-drawer-backdrop{position:absolute; inset:0; background:rgba(0,0,0,.5); opacity:0; transition:opacity .22s ease;}
  .mobile-drawer.open{pointer-events:auto;}
  .mobile-drawer.open .mobile-drawer-inner{transform:translateX(0);}
  .mobile-drawer.open .mobile-drawer-backdrop{opacity:1;}
  .mobile-drawer .nav-list{flex:1; overflow-y:auto; margin-top:10px;}
}
@media(min-width:901px){
  .mobile-drawer{display:none !important;}
}

/* Utility */
.flex{display:flex;} .items-center{align-items:center;} .justify-between{justify-content:space-between;}
.gap-8{gap:8px;} .gap-12{gap:12px;} .mt-8{margin-top:8px;} .mt-16{margin-top:16px;} .w-full{width:100%;}
.text-right{text-align:right;}
