/* ================================================================
   KOL Control System — Professional Light Theme
   Inspired by: The Moments Group dashboard aesthetic
   ================================================================ */

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

:root {
    --bg:        #f4f5f7;
    --bg2:       #ffffff;
    --bg3:       #f9fafb;
    --border:    #e5e7eb;
    --border2:   #d1d5db;
    --text:      #111827;
    --text2:     #374151;
    --muted:     #6b7280;
    --muted2:    #9ca3af;
    --accent:    #8b1c1c;
    --accent-h:  #6f1616;
    --accent-l:  #fef2f2;
    --accent-b:  #fca5a5;
    --success:   #059669;
    --success-l: #ecfdf5;
    --warning:   #d97706;
    --warning-l: #fffbeb;
    --danger:    #dc2626;
    --danger-l:  #fef2f2;
    --info:      #2563eb;
    --info-l:    #eff6ff;
    --sidebar-w: 240px;
    --radius:    8px;
    --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,.08);
}

body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    background: var(--bg); color: var(--text);
    display: flex; min-height: 100vh; font-size: 14px; line-height: 1.6;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w); background: #141414; color: #e5e7eb;
    display: flex; flex-direction: column; position: fixed; top: 0; left: 0;
    height: 100vh; z-index: 100; padding: 0 0 16px;
}

.sidebar-logo {
    padding: 22px 20px 18px; border-bottom: 1px solid rgba(255,255,255,.08);
    display: flex; align-items: center; gap: 10px;
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-size: 17px; font-weight: 800; letter-spacing: -.3px;
}
.logo-icon { width: 28px; height: 28px; background: var(--accent); border-radius: 6px;
             display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.logo-icon svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 2;
                 stroke-linecap: round; stroke-linejoin: round; }
.logo-text { color: #fff; }
.logo-text strong { color: var(--accent-b); }

.sidebar-nav { flex: 1; padding: 14px 12px; overflow-y: auto; }

.nav-section {
    display: block; font-size: 10px; font-weight: 600; letter-spacing: 1.2px;
    text-transform: uppercase; color: #4b5563; padding: 14px 8px 6px;
}

.nav-item {
    display: flex; align-items: center; gap: 10px; padding: 8px 12px;
    border-radius: 6px; color: #9ca3af; text-decoration: none;
    transition: all .15s; font-size: 13.5px; font-weight: 400; margin-bottom: 1px;
}
.nav-item svg { width: 16px; height: 16px; stroke: currentColor; fill: none;
                stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #e5e7eb; }
.nav-item.active { background: rgba(139,28,28,.25); color: #fca5a5; }
.nav-item.active svg { stroke: #fca5a5; }

.sidebar-user {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px;
    border-top: 1px solid rgba(255,255,255,.07); margin-top: auto;
}
.user-avatar {
    width: 32px; height: 32px; border-radius: 50%; background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name { display: block; font-size: 13px; font-weight: 500; color: #e5e7eb;
             white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: inline-block; font-size: 10px; padding: 1px 7px; border-radius: 20px;
             font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-top: 2px; }
.role-admin   { background: rgba(139,28,28,.3);  color: #fca5a5; }
.role-manager { background: rgba(37,99,235,.25); color: #93c5fd; }
.role-user    { background: rgba(5,150,105,.2);  color: #6ee7b7; }
.role-viewer  { background: rgba(156,163,175,.15); color: #9ca3af; }

.logout-btn { color: #4b5563; text-decoration: none; padding: 6px; border-radius: 6px;
              display: flex; transition: color .15s; }
.logout-btn:hover { color: #fca5a5; }
.logout-btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none;
                  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── Main content ────────────────────────────────────────── */
.main-content { margin-left: var(--sidebar-w); flex: 1; padding: 28px 32px; min-width: 0; }

.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--text); letter-spacing: -.3px; }
.page-header p  { color: var(--muted); margin-top: 3px; font-size: 13.5px; }

/* ── Top bar ─────────────────────────────────────────────── */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px; padding-bottom: 18px; border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 20px; font-weight: 700; color: var(--text); }
.topbar-sub   { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
    background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 22px; box-shadow: var(--shadow);
}
.card-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 16px;
              text-transform: uppercase; letter-spacing: .4px; }

/* ── Stat cards ──────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
              gap: 14px; margin-bottom: 24px; }
.stat-card {
    background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px 20px; box-shadow: var(--shadow); position: relative;
}
.stat-card .stat-label { font-size: 11px; font-weight: 600; color: var(--muted);
                          text-transform: uppercase; letter-spacing: .6px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1; }
.stat-card .stat-sub   { font-size: 12px; color: var(--muted); margin-top: 5px; }
.stat-card .stat-icon  {
    position: absolute; right: 16px; top: 16px;
    width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.stat-card .stat-icon svg { width: 18px; height: 18px; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted);
     font-weight: 600; padding: 10px 14px; border-bottom: 2px solid var(--border);
     text-align: left; white-space: nowrap; background: var(--bg3); }
th:first-child { border-radius: 6px 0 0 0; }
th:last-child  { border-radius: 0 6px 0 0; }
td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; color: var(--text2); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg3); }

/* ── Badges ──────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600;
         padding: 2px 8px; border-radius: 4px; text-transform: uppercase; letter-spacing: .3px; }
.badge-active    { background: var(--success-l); color: var(--success); }
.badge-pending   { background: var(--warning-l); color: var(--warning); }
.badge-paused    { background: #f3f4f6; color: var(--muted); }
.badge-removed   { background: var(--danger-l);  color: var(--danger); }
.badge-connected { background: var(--info-l);    color: var(--info); }
.badge-admin     { background: var(--danger-l);  color: var(--accent); }
.badge-manager   { background: var(--info-l);    color: var(--info); }
.badge-user      { background: var(--success-l); color: var(--success); }
.badge-viewer    { background: #f3f4f6;           color: var(--muted); }
.badge-dot::before { content:''; width:6px; height:6px; border-radius:50%; background:currentColor; display:inline-block; }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
    border-radius: 6px; font-size: 13px; font-weight: 500; cursor: pointer;
    border: 1px solid transparent; text-decoration: none;
    transition: all .15s; line-height: 1; font-family: inherit; white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none;
           stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-h); border-color: var(--accent-h); }
.btn-success { background: var(--success-l); color: var(--success); border-color: #a7f3d0; }
.btn-success:hover { background: #d1fae5; }
.btn-danger  { background: var(--danger-l); color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-ghost   { background: #fff; color: var(--text2); border-color: var(--border2); }
.btn-ghost:hover { background: var(--bg3); border-color: var(--border2); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-fb { background: #1877f2; color: #fff; border-color: #1877f2; font-size: 14px; padding: 11px 24px; }
.btn-fb:hover { background: #0f63d0; }
.btn-fb svg { width: 18px; height: 18px; fill: #fff; stroke: none; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text2);
              margin-bottom: 6px; }
.form-control {
    width: 100%; background: #fff; border: 1px solid var(--border2);
    border-radius: 6px; padding: 9px 12px; color: var(--text); font-size: 13.5px;
    font-family: inherit; transition: border-color .15s, box-shadow .15s; outline: none;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(139,28,28,.1); }
select.form-control { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; appearance: none; }
textarea.form-control { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 18px;
         font-size: 13.5px; border: 1px solid transparent; display: flex; gap: 10px; align-items: flex-start; }
.alert svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px;
             stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.alert-success { background: var(--success-l); border-color: #a7f3d0; color: var(--success); }
.alert-danger  { background: var(--danger-l);  border-color: #fecaca; color: var(--danger); }
.alert-info    { background: var(--info-l);    border-color: #bfdbfe; color: var(--info); }
.alert-warning { background: var(--warning-l); border-color: #fde68a; color: var(--warning); }

/* ── Login page ──────────────────────────────────────────── */
.login-wrap {
    width: 100vw; min-height: 100vh; position: fixed; inset: 0; z-index: 999;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg);
}
.login-card {
    width: 100%; max-width: 420px; background: var(--bg2); border: 1px solid var(--border);
    border-radius: 12px; padding: 40px 36px; box-shadow: var(--shadow-md);
}
.login-logo { text-align: center; margin-bottom: 28px; display: flex;
              align-items: center; justify-content: center; gap: 10px; }
.login-logo-icon { width: 36px; height: 36px; background: var(--accent); border-radius: 8px;
                   display: flex; align-items: center; justify-content: center; }
.login-logo-icon svg { width: 20px; height: 20px; stroke: #fff; fill: none; stroke-width: 2;
                        stroke-linecap: round; stroke-linejoin: round; }
.login-logo-text { font-size: 20px; font-weight: 700; color: var(--text); }
.login-logo-text span { color: var(--accent); }

/* ── Onboard page ────────────────────────────────────────── */
.onboard-wrap {
    width: 100vw; min-height: 100vh; position: fixed; inset: 0; z-index: 999;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg); padding: 24px;
}
.onboard-card { width: 100%; max-width: 520px; background: var(--bg2);
                border: 1px solid var(--border); border-radius: 12px; padding: 40px;
                box-shadow: var(--shadow-md); }
.onboard-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.onboard-logo-icon { width: 32px; height: 32px; background: var(--accent); border-radius: 6px;
                     display: flex; align-items: center; justify-content: center; }
.onboard-logo-icon svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 2;
                          stroke-linecap: round; stroke-linejoin: round; }
.onboard-logo-text { font-size: 16px; font-weight: 700; color: var(--text); }
.onboard-logo-text span { color: var(--accent); }
.perm-list { list-style: none; margin: 16px 0; }
.perm-list li { display: flex; align-items: flex-start; gap: 10px; padding: 9px 0;
                border-bottom: 1px solid var(--border); font-size: 13.5px; color: var(--text2); }
.perm-list li:last-child { border-bottom: none; }
.perm-check { width: 18px; height: 18px; background: var(--success-l); border-radius: 50%;
              display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-top: 1px; }
.perm-check svg { width: 10px; height: 10px; stroke: var(--success); fill: none;
                  stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }

/* ── Invite link box ─────────────────────────────────────── */
.invite-box { background: var(--bg3); border: 1px solid var(--border); border-radius: 6px;
              padding: 10px 12px; display: flex; align-items: center; gap: 10px; }
.invite-url { flex: 1; font-size: 12px; color: var(--muted); word-break: break-all;
              font-family: monospace; }
.copy-btn { background: var(--accent); color: #fff; border: none; border-radius: 5px;
            padding: 5px 12px; font-size: 12px; cursor: pointer; flex-shrink: 0;
            font-family: inherit; font-weight: 500; transition: background .15s; }
.copy-btn:hover { background: var(--accent-h); }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.4);
                 z-index: 200; align-items: center; justify-content: center; padding: 20px; }
.modal-box { background: #fff; border: 1px solid var(--border); border-radius: 10px;
             padding: 28px; width: 100%; max-width: 440px; box-shadow: var(--shadow-md); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-title { font-size: 15px; font-weight: 700; color: var(--text); }
.modal-close { background: none; border: none; color: var(--muted); cursor: pointer;
               font-size: 20px; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: var(--bg3); }

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

/* ── Misc utils ──────────────────────────────────────────── */
.flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 20px; }
.mt-2 { margin-top: 8px; }
.text-muted { color: var(--muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.w-full { width: 100%; }

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .main-content { margin-left: 0; padding: 20px 16px; }
    .form-row, .grid-2 { grid-template-columns: 1fr; }
    .login-card, .onboard-card { padding: 28px 20px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Logo image overrides ────────────────────────────────── */
.sidebar-logo {
    padding: 16px 20px;
    min-height: 64px;
    align-items: center;
}
.sidebar-logo img {
    max-height: 40px;
    max-width: 170px;
    object-fit: contain;
    object-position: left center;
    /* Make white logos visible on dark sidebar */
    filter: brightness(0) invert(1);
}
/* If logo already works on dark bg, remove the filter above */
