/* FAMEZ CRM – Static Master Template (Chrome-ready)
   Purpose: UI skeleton only. DEV plugs logic later (Laravel/Livewire/Inertia).
*/
:root{
  --accent:#7c5cff;      /* Famez purple */
  --good:#35d07f;
  --warn:#ffcc66;
  --bad:#ff5c7a;

  /* LIGHT (default) */
  --bg:#f6f7fb;
  --surface:#ffffff;
  --surface2:#f0f2f8;
  --text:#121629;
  --muted:#5b6787;
  --line:rgba(16,24,40,.10);
  --shadow: 0 8px 24px rgba(16,24,40,.08);

  --radius:14px;
  --sidebar-w:280px;
  --pad:18px;
  --topbar-h:60px;
  --maxw:1800px;
}

html[data-theme="dark"]{
  --bg:#0b0f17;
  --surface:#0f1624;
  --surface2:#101b2e;
  --text:#e7eefc;
  --muted:#9bb0d0;
  --line:rgba(255,255,255,.08);
  --shadow: 0 10px 30px rgba(0,0,0,.35);
}

*{ box-sizing:border-box; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial;
  color:var(--text);
  background:
    radial-gradient(1200px 800px at 20% -10%, color-mix(in srgb, var(--accent) 35%, transparent), transparent 60%),
    radial-gradient(1000px 600px at 90% 10%, color-mix(in srgb, var(--good) 18%, transparent), transparent 60%),
    var(--bg);
}

/* Layout */
.app{ display:grid; grid-template-columns: var(--sidebar-w) 1fr; min-height:100vh; width:100%; }
.sidebar{
  position:sticky; top:0; height:100vh;
  padding:16px; border-right:1px solid var(--line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, transparent), color-mix(in srgb, var(--surface) 76%, transparent));
  backdrop-filter: blur(10px);
}
.main{ min-width:0; display:flex; flex-direction:column; }
.topbar{
  height:var(--topbar-h);
  display:flex; align-items:center; justify-content:space-between; gap:12px;
  padding:12px var(--pad);
  border-bottom:1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(10px);
}
.content{ padding: var(--pad); }
.shell{ width:100%; max-width: var(--maxw); margin:0 auto; }
.shell-2{ display:grid; grid-template-columns: 1fr 360px; gap:16px; }
.shell-3{ display:grid; grid-template-columns: 360px 1fr 380px; gap:16px; align-items:stretch; }

/* Basics */
.card{
  border:1px solid var(--line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 82%, transparent), color-mix(in srgb, var(--surface) 62%, transparent));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding:14px;
  min-width:0;
}
.muted{ color:var(--muted); font-size:13px; }
.hstack{ display:flex; align-items:center; gap:10px; }
.vstack{ display:flex; flex-direction:column; gap:10px; }
.spread{ display:flex; align-items:center; justify-content:space-between; gap:12px; }
.hr{ height:1px; background:var(--line); margin:12px 0; border:0; }
a{ color:inherit; }

/* Buttons / inputs */
.btn{
  border:1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 50%, transparent);
  color:var(--text);
  padding:10px 12px;
  border-radius:12px;
  cursor:pointer;
  font-size:14px;
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  user-select:none;
}
.btn:hover{ filter:brightness(1.03); }
.btn.primary{
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
}
.btn.ghost{ background:transparent; }
.input, .select, textarea{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 35%, transparent);
  color:var(--text);
  outline:none;
  font-size:14px;
}
textarea{ min-height:54px; max-height:160px; resize:vertical; }

.search{
  display:flex; align-items:center; gap:10px;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 35%, transparent);
  min-width:260px;
  flex:1;
}
.search input{ width:100%; background:transparent; border:0; outline:none; color:var(--text); font-size:14px; }

/* Chips / badges */
.badge{
  font-size:12px; color:var(--muted);
  padding:2px 8px; border-radius:999px;
  border:1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 35%, transparent);
}
.chip{
  display:inline-flex; align-items:center; gap:6px;
  font-size:12px; padding:4px 10px; border-radius:999px;
  border:1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 35%, transparent);
}
.dot{ width:8px; height:8px; border-radius:99px; background: var(--muted); display:inline-block; }
.dot.good{ background: var(--good); } .dot.warn{ background: var(--warn); } .dot.bad{ background: var(--bad); }

/* Sidebar nav */
.brand{
  display:flex; align-items:center; gap:10px;
  padding:10px 12px; border-radius:12px;
  background: color-mix(in srgb, var(--surface2) 35%, transparent);
  border:1px solid var(--line);
  margin-bottom:14px;
}
.logo{
  width:34px; height:34px; border-radius:10px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 30%, transparent));
  display:grid; place-items:center; font-weight:900;
}
.nav{ display:flex; flex-direction:column; gap:6px; margin-top:12px; }
.nav a{
  text-decoration:none; color:var(--text);
  padding:10px 12px; border-radius:12px;
  border:1px solid transparent;
  display:flex; align-items:center; justify-content:space-between;
}
.nav a:hover{ background: color-mix(in srgb, var(--surface2) 30%, transparent); border-color:var(--line); }
.nav a.active{ background: color-mix(in srgb, var(--accent) 14%, transparent); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }

/* KPI grid */
.kpis{ display:grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap:12px; }
.kpi{ padding:14px; border-radius: var(--radius); border:1px solid var(--line); background: color-mix(in srgb, var(--surface2) 30%, transparent); }
.kpi .label{ color:var(--muted); font-size:12px; }
.kpi .value{ font-size:22px; font-weight:900; margin-top:6px; }
.kpi .delta{ margin-top:6px; font-size:12px; }
.delta.good{ color:var(--good);} .delta.warn{ color:var(--warn);} .delta.bad{ color:var(--bad);}

/* Tables */
.table{ width:100%; border-collapse:collapse; font-size:13px; overflow:hidden; border-radius: 12px; }
.table th, .table td{ padding:10px 10px; border-bottom:1px solid var(--line); text-align:left; vertical-align:middle; white-space:nowrap; }
.table th{ color:var(--muted); font-weight:700; font-size:12px; }
.table tr:hover td{ background: color-mix(in srgb, var(--surface2) 20%, transparent); }

/* Mobile */
.mobile-only{ display:none; }
.desktop-only{ display:block; }

.bottom-nav{
  position:fixed; left:0; right:0; bottom:0;
  height:64px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border-top:1px solid var(--line);
  display:none;
  align-items:center; justify-content:space-around;
  gap:8px; padding:8px;
  backdrop-filter: blur(10px);
}
.bottom-nav a{
  text-decoration:none; color:var(--muted); font-size:12px;
  display:flex; flex-direction:column; align-items:center; gap:6px;
  padding:8px 10px; border-radius:12px;
}
.bottom-nav a.active{
  color:var(--text);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border:1px solid color-mix(in srgb, var(--accent) 28%, transparent);
}

/* Drawer */
.drawer{
  position:fixed; left:0; right:0; bottom:-100%;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-top:1px solid var(--line);
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow);
  transition: bottom .25s ease;
  padding:14px;
  z-index:50;
}
.drawer.open{ bottom:0; }
.drawer .handle{
  width:52px; height:5px; border-radius:99px;
  background: color-mix(in srgb, var(--muted) 40%, transparent);
  margin:0 auto 12px;
}

/* Breakpoints */
@media (max-width: 1200px){
  .shell-3{ grid-template-columns: 360px 1fr; }
  .rightcol{ display:none; }
}
@media (max-width: 980px){
  :root{ --sidebar-w: 76px; }
  .brand div:last-child{ display:none; }
  .nav a span:first-child{ display:none; }
  .nav a{ justify-content:center; }
  .search{ min-width: 180px; }
  .kpis{ grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 767px){
  .app{ grid-template-columns: 1fr; }
  .sidebar{ display:none; }
  .content{ padding: 14px; padding-bottom: 92px; }
  .bottom-nav{ display:flex; }
  .mobile-only{ display:block; }
  .desktop-only{ display:none; }
  .kpis{ grid-template-columns: 1fr 1fr; }
  .shell-2, .shell-3{ display:block; }
}


/* Utilities */
.hidden{ display:none !important; }

/* Chat states: first show inbox list only, open chat on click */
.chat-shell.inbox-only{ grid-template-columns: 1fr; }
.chat-shell.inbox-only #chatView,
.chat-shell.inbox-only #fanPanel{ display:none; }

.chat-shell.chat-open{ grid-template-columns: 360px 1fr 380px; }
@media (max-width: 1200px){
  .chat-shell.chat-open{ grid-template-columns: 360px 1fr; }
}
@media (max-width: 767px){
  .chat-shell.chat-open{ display:block; }
}

/* Chat action bar (OnlyFans-style placeholders) */
.actionbar{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.actionbar .tool{
  width:40px; height:40px; border-radius:12px;
  border:1px solid var(--line);
  background: color-mix(in srgb, var(--surface2) 35%, transparent);
  display:grid; place-items:center;
  cursor:pointer;
  user-select:none;
}
.actionbar .tool:hover{ filter:brightness(1.05); }
.actionbar .tool.primary{
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}


/* Inbox scroll + full view */
.inbox-scroll{
  overflow:auto;
  max-height: calc(100vh - var(--topbar-h) - (var(--pad) * 2) - 180px);
  padding-right:6px;
}
@media (max-width: 767px){
  .inbox-scroll{ max-height: calc(100vh - var(--topbar-h) - 140px); }
}

/* Chat fullscreen (hide inbox list when a chat is open) */
.chat-shell.chat-full{ display:block; }
.chat-shell.chat-full #inboxList{ display:none; }
.chat-shell.chat-full #chatView{ display:block; }
.chat-shell.chat-full #fanPanel{ display:block; }
@media (max-width:1200px){
  .chat-shell.chat-full #fanPanel{ display:none; }
}


/* ===========================
   Drawer System (CSP-safe)
   Append-only patch — keeps existing theme intact
   =========================== */

.drawer{
  position: fixed;
  inset: 0;
  background: rgba(20,16,40,.55);
  backdrop-filter: blur(6px);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  transition: opacity .25s ease;
}

.drawer.open{
  opacity: 1;
  pointer-events: auto;
}

.drawer .drawer-content{
  background: var(--surface);
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  padding: 16px;
  border-radius: 18px 18px 0 0;
}

@media (min-width:1024px){
  .drawer{
    justify-content: flex-end;
    align-items: stretch;
  }
  .drawer .drawer-content{
    height: 100%;
    max-width: 420px;
    border-radius: 0;
  }
}

body.drawer-open{ overflow: hidden; }
