/* =========================================================
   Biz CRM – Modern UI (Full Width)
   - Drop-in stylesheet for your custom PHP CRM
   - Light + Dark themes (toggle with body.theme-dark)
   - No fixed max-width on content/cards
   ========================================================= */

/* ---------- Theme Tokens ---------- */
:root{
  /* Light */
  --bg:           #f8fafc;
  --panel:        #ffffff;
  --border:       #e5e7eb;
  --text:         #0f172a;
  --text-weak:    #334155;
  --muted:        #64748b;

  --brand:        #4f46e5;   /* Indigo 600 */
  --brand-700:    #4338ca;
  --accent:       #0ea5e9;   /* Sky 500 */
  --success:      #16a34a;   /* Green 600 */
  --warning:      #f59e0b;   /* Amber 500 */
  --danger:       #dc2626;   /* Red 600 */

  --elev-1:       0 1px 2px rgba(0,0,0,.05);
  --elev-2:       0 6px 24px rgba(0,0,0,.06);

  --radius-sm:    8px;
  --radius:       12px;
  --radius-lg:    14px;

  --sbw:          240px;     /* sidebar width */
  --sbw-collapsed:64px;      /* collapsed width */
  --topbar-h:     56px;
}

body.theme-dark{
  --bg:           #0b1220;
  --panel:        #0f1520;
  --border:       #1e293b;
  --text:         #e6edf7;
  --text-weak:    #a9b6cc;
  --muted:        #8aa0c6;

  --brand:        #7c91ff;
  --brand-700:    #627bff;
  --accent:       #5dd2ff;

  --elev-1:       0 1px 2px rgba(0,0,0,.4);
  --elev-2:       0 10px 30px rgba(0,0,0,.35);
}

/* ---------- Base / Reset ---------- */
*{ box-sizing: border-box; }
html,body{ height:100%; }
html{ -webkit-text-size-adjust:100%; }
body{
  margin:0;
  font:14px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Noto Sans", sans-serif;
  background:var(--bg);
  color:var(--text);
}
a{ color:var(--brand); text-decoration:none; }
a:hover{ text-decoration:underline; }
img{ max-width:100%; height:auto; display:block; }

/* Scrollbars (nice but subtle) */
*{
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
*::-webkit-scrollbar{ height:10px; width:10px; }
*::-webkit-scrollbar-thumb{ background:var(--border); border-radius:999px; }
*::-webkit-scrollbar-track{ background:transparent; }

/* ---------- App Layout (Grid) ---------- */
body.app{
  display: grid;
  grid-template-columns: var(--sbw) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  min-height: 100vh;
}

/* Collapsed */
body.side-collapsed{
  grid-template-columns: var(--sbw-collapsed) 1fr;
}

/* Topbar */
.topbar{
  grid-area: topbar;
  display:flex; align-items:center; gap:12px;
  padding:8px 12px;
  background:var(--panel);
  border-bottom:1px solid var(--border);
  position: sticky; top:0; z-index:40;
}
.hamburger{
  border:1px solid var(--border);
  background:var(--panel);
  border-radius: var(--radius-sm);
  padding:6px 10px; cursor:pointer;
}
.brand{
  font-weight:700; color:inherit; text-decoration:none;
  display:flex; align-items:center; gap:8px;
}
.search{ flex:1; display:flex; }
.search input{
  width:100%;
  padding:10px 12px;
  border:1px solid var(--border);
  border-radius: 10px;
  background:#fff;
}
body.theme-dark .search input{ background:#0e141b; color:var(--text); }
.top-actions{ display:flex; align-items:center; gap:12px; }
.pill{ display:inline-block; min-width:20px; padding:0 6px; border-radius:999px; background:var(--text); color:#fff; font-size:12px; text-align:center; }

/* Sidebar */
.sidebar{
  grid-area: sidebar;
  background:var(--panel);
  border-right:1px solid var(--border);
  padding:8px;
  width:var(--sbw);
  overflow:auto;
  transition: width .2s;
}
body.side-collapsed .sidebar{ width:var(--sbw-collapsed); }
.sidebar .section{ margin:8px 0 12px; }
.sidebar .heading{ font-size:12px; color:var(--muted); margin:6px 8px; text-transform:uppercase; letter-spacing:.02em; }
.side-link{
  display:flex; align-items:center; gap:10px;
  padding:8px 10px; border-radius:10px;
  color:inherit; text-decoration:none;
}
.side-link .icon{ width:18px; text-align:center; }
.side-link:hover{ background: color-mix(in oklab, var(--border) 50%, transparent); }
.side-link.active{ background:var(--brand); color:#fff; box-shadow: var(--elev-1); }
body.side-collapsed .side-link .text{ display:none; }

/* Mobile sidebar (off-canvas) */
@media (max-width: 1024px){
  body.app{
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
    grid-template-areas: "topbar" "main";
  }
  .sidebar{
    position: fixed; top: var(--topbar-h); left:0;
    height: calc(100vh - var(--topbar-h));
    width: 280px; transform: translateX(-100%);
    box-shadow: 2px 0 12px rgba(0,0,0,.1);
    z-index:45; transition: transform .2s ease;
  }
  body.sb-open .sidebar{ transform:none; }
  body.sb-open{ overflow:hidden; }
  .backdrop{
    position:fixed; inset:0; background:rgba(0,0,0,.4);
    z-index:44; opacity:0; visibility:hidden; transition:opacity .2s;
  }
  body.sb-open .backdrop{ opacity:1; visibility:visible; }
}

/* Main area */
.main{
  grid-area: main;
  padding:16px;
  min-width:0;  /* allows tables to shrink inside */
}

/* Full-width container (no max width) */
.container{
  max-width:none; width:100%;
  margin:0; padding:16px 24px;
}

/* ---------- Common UI ---------- */
.btn{
  display:inline-flex; align-items:center; gap:8px;
  border:1px solid var(--border);
  background:var(--panel);
  color:inherit; text-decoration:none;
  padding:8px 12px; border-radius:10px; cursor:pointer;
  transition: transform .02s ease, background .15s ease;
}
.btn:hover{ background: color-mix(in oklab, var(--border) 45%, var(--panel)); }
.btn:active{ transform: translateY(1px); }
.btn.primary{ background:var(--brand); border-color:var(--brand); color:#fff; }
.btn.primary:hover{ background:var(--brand-700); }
.btn.secondary{ background:#eef2ff; border-color:#c7d2fe; color:#1f2937; }
.btn.ghost{ background:transparent; color:var(--brand); }
.btn.small{ padding:4px 8px; border-radius:8px; font-size:12px; }

.badge{
  display:inline-block; border:1px solid var(--border);
  border-radius:999px; padding:3px 9px; font-size:12px; font-weight:600;
}
.badge.muted{ background:#f3f4f6; color:#374151; }
body.theme-dark .badge.muted{ background:#101826; color:#a9b6cc; border-color:#22314b; }

.alert{
  border:1px solid var(--border); border-radius:10px;
  padding:10px; margin:8px 0; background:var(--panel);
}
.alert.success{ border-color:#22c55e55; background:#ecfdf5; color:#166534; }
.alert.error{   border-color:#ef444455; background:#fef2f2; color:#991b1b; }
body.theme-dark .alert.success{ background:#0e2217; color:#97e3aa; }
body.theme-dark .alert.error{   background:#2a1212; color:#ffb3b3; }

/* Cards & Panels */
.card, .panel{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius: var(--radius);
  padding:12px;
  width:100%;
  box-shadow: var(--elev-1);
}
.page-title{ font-size:20px; font-weight:700; margin:0; }
.page{ display:flex; flex-direction:column; gap:12px; }
.head{ display:flex; align-items:center; justify-content:space-between; gap:12px; }

/* Auth page – only here the card is narrow */
.auth{ display:grid; place-items:center; min-height:70vh; }
.auth .card{ max-width:380px; padding:20px; border-radius: var(--radius-lg); }

/* Forms */
.form label{ display:block; font-size:12px; color:var(--text-weak); margin:8px 0 4px; }
.form input, .form select, .form textarea{
  width:100%;
  border:1px solid var(--border);
  border-radius:10px;
  padding:10px 12px; background:#fff;
}
.form textarea{ min-height:110px; resize:vertical; }
.form .row{ display:flex; gap:12px; }
.form .row .col{ flex:1; }
body.theme-dark .form input, body.theme-dark .form select, body.theme-dark .form textarea{
  background:#0e141b; color:var(--text); border-color:#22314b;
}
.filterbar{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }

/* Inputs for dark/blue Leads page style */
.input{
  min-width:220px;
  background:#0e141b; color:#e7ecf2;
  border:1px solid #1f2a38; border-radius:10px; padding:10px 12px;
}
.input:focus{ outline:none; border-color:#375a9e; box-shadow:0 0 0 3px rgba(58,115,218,.25); }

/* Tables */
.table{ width:100%; overflow:auto; border-radius: var(--radius); }
.table table{
  width:100%; border-collapse:separate; border-spacing:0;
  background:var(--panel); border:1px solid var(--border); border-radius: var(--radius);
}
.table thead th{
  position:sticky; top:0; z-index:1;
  background: color-mix(in oklab, var(--panel) 60%, #f3f4f6);
  color:var(--muted); text-transform:uppercase; letter-spacing:.04em;
  font-size:12px; padding:12px; border-bottom:1px solid var(--border);
}
.table tbody td{ padding:12px; border-bottom:1px solid var(--border); }
.table tbody tr:hover{ background: color-mix(in oklab, var(--panel) 85%, var(--border)); }

/* Leads-specific table flavor (dark rows) */
.table-leads thead th{
  background:#0e141b; color:#94a3b8; border-bottom:1px solid #1f2a38;
}
.table-leads tbody td{ border-bottom:1px solid #142034; }
.table-leads tbody tr:hover{ background:#0b1220; }
.table-leads .mono{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; }

/* Responsive table: stack */
@media (max-width: 880px){
  .table thead{ display:none; }
  .table table, .table tbody, .table tr, .table td{ display:block; width:100%; }
  .table tr{ margin-bottom:10px; border:1px solid var(--border); border-radius: var(--radius); overflow:hidden; }
  .table td{
    border:none; border-bottom:1px solid var(--border);
    position:relative; padding-left:44%; min-height:44px; display:flex; align-items:center;
  }
  .table td:last-child{ border-bottom:none; }
  .table td::before{
    content: attr(data-label);
    position:absolute; left:12px; top:0; bottom:0; display:flex; align-items:center;
    color:var(--muted); font-size:12px; font-weight:600;
  }
}

/* Badges – status/type */
.badge-status.status-new{        background:#eef2ff; color:#3730a3; border-color:#c7d2fe; }
.badge-status.status-connected{  background:#e8faf5; color:#065f46; border-color:#a7f3d0; }
.badge-status.status-pipeline{   background:#efe9ff; color:#5b21b6; border-color:#ddd6fe; }
.badge-status.status-converted{  background:#ecfdf5; color:#166534; border-color:#bbf7d0; }
.badge-status.status-dead{       background:#fef2f2; color:#991b1b; border-color:#fecaca; }

.badge-type.type-prospect{   background:#eef2ff; color:#3730a3; border-color:#c7d2fe; }
.badge-type.type-existing{   background:#ecfdf5; color:#166534; border-color:#bbf7d0; }
.badge-type.type-interested{ background:#f5e9ff; color:#6b21a8; border-color:#e9d5ff; }
.badge-type.type-pipeline{   background:#efe9ff; color:#5b21b6; border-color:#ddd6fe; }

/* Pagination */
.pagination{ display:flex; align-items:center; justify-content:center; gap:8px; margin-top:12px; }
.pagination .btn{ min-width:88px; justify-content:center; }

/* Kanban */
.kanban{ display:grid; grid-template-columns:repeat(4,1fr); gap:12px; }
.kan-col{
  background: color-mix(in oklab, var(--panel) 90%, #f9fafb);
  border:1px solid var(--border);
  border-radius: var(--radius);
  display:flex; flex-direction:column; min-height:50vh;
}
.kan-head{ padding:10px 12px; border-bottom:1px solid var(--border); font-weight:600; }
.kan-list{ padding:10px; display:flex; flex-direction:column; gap:10px; }
.kan-card{ background:var(--panel); border:1px solid var(--border); border-radius:10px; padding:10px; cursor:grab; box-shadow:var(--elev-1); }
.kan-title{ font-weight:600; }
.kan-sub,.kan-meta,.kan-due{ color:var(--muted); font-size:12px; }

/* Utilities */
.row{ display:flex; }
.wrap{ flex-wrap:wrap; }
.between{ justify-content:space-between; }
.center{ align-items:center; }
.gap-6{ gap:6px; } .gap-8{ gap:8px; } .gap-12{ gap:12px; } .gap-16{ gap:16px; }

.grid-2{ display:grid; grid-template-columns:repeat(2, minmax(0,1fr)); gap:12px; }
.grid-3{ display:grid; grid-template-columns:repeat(3, minmax(0,1fr)); gap:12px; }
.grid-4{ display:grid; grid-template-columns:repeat(4, minmax(0,1fr)); gap:12px; }
.grid-5{ display:grid; grid-template-columns:repeat(5, minmax(0,1fr)); gap:12px; }
@media (max-width: 1200px){ .grid-5{ grid-template-columns:repeat(3,1fr); } }
@media (max-width: 900px){ .grid-4, .grid-5{ grid-template-columns:repeat(2,1fr); } .grid-3{ grid-template-columns:repeat(2,1fr); } }
@media (max-width: 620px){ .grid-2, .grid-3, .grid-4, .grid-5{ grid-template-columns:1fr; } }

/* Subtle text helpers */
.subtle{ color:var(--muted); font-size:12px; }
.link-strong{ color:inherit; font-weight:700; text-decoration:none; }
.link-strong:hover{ text-decoration:underline; }

/* Icons in table cells */
td a[title="Call"], td a[title="WhatsApp"]{ margin-left:6px; text-decoration:none; }
td a[title="WhatsApp"]{ font-size:18px; line-height:1; }

/* --- End --- */
