/* ══════════════════════════════════════════
   VARIABLES & RESET
══════════════════════════════════════════ */
:root {
    --purple:       #7c3aed;
    --purple-light: #8b5cf6;
    --purple-pale:  #c4b5fd;
    --bg:           #06030e;
    --bg2:          #0d0820;
    --bg3:          #120d28;
    --text:         #fff;
    --text-muted:   rgba(255,255,255,.45);
    --text-dim:     rgba(255,255,255,.25);
    --border:       rgba(124,58,237,.2);
    --green:        #22c55e;
    --red:          #ef4444;
    --amber:        #f59e0b;

    --radius-sm:    8px;
    --radius-md:    12px;
    --radius-lg:    16px;
    --radius-xl:    24px;

    --shadow:       0 4px 24px rgba(0,0,0,.3);
    --shadow-lg:    0 8px 40px rgba(0,0,0,.4);

    --sidebar-w:    240px;
    --nav-h:        64px;
}

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

html { scroll-behavior: smooth; font-size: 16px; }

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

img { max-width: 100%; display: block; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ══════════════════════════════════════════
   SCROLLBAR
══════════════════════════════════════════ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--purple); border-radius: 999px; }

/* ══════════════════════════════════════════
   TYPOGRAPHY
══════════════════════════════════════════ */
h1, h2, h3, h4 { font-family: 'Syne', sans-serif; font-weight: 700; letter-spacing: -.5px; line-height: 1.15; }
h1 { font-size: clamp(28px, 5vw, 48px); }
h2 { font-size: clamp(22px, 3.5vw, 36px); }
h3 { font-size: clamp(18px, 2.5vw, 24px); }
h4 { font-size: clamp(15px, 2vw, 18px); }
p  { line-height: 1.75; color: var(--text-muted); font-weight: 300; }

/* ══════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    border: none;
    transition: all .2s;
    white-space: nowrap;
    cursor: pointer;
}

.btn-primary   { background: var(--purple); color: #fff; }
.btn-primary:hover { background: var(--purple-light); transform: translateY(-1px); }

.btn-outline   { background: transparent; color: rgba(255,255,255,.6); border: 0.5px solid rgba(255,255,255,.15); }
.btn-outline:hover { border-color: rgba(139,92,246,.5); color: var(--purple-pale); }

.btn-danger    { background: rgba(239,68,68,.15); color: var(--red); border: 0.5px solid rgba(239,68,68,.3); }
.btn-danger:hover { background: rgba(239,68,68,.25); }

.btn-success   { background: rgba(34,197,94,.15); color: var(--green); border: 0.5px solid rgba(34,197,94,.3); }
.btn-success:hover { background: rgba(34,197,94,.25); }

.btn-sm  { padding: 7px 14px; font-size: 12px; }
.btn-lg  { padding: 14px 32px; font-size: 16px; }
.btn-full { width: 100%; }

/* ══════════════════════════════════════════
   BADGES
══════════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.badge-purple { background: rgba(124,58,237,.15); color: var(--purple-pale); border: 0.5px solid rgba(124,58,237,.3); }
.badge-green  { background: rgba(34,197,94,.12);  color: #4ade80;            border: 0.5px solid rgba(34,197,94,.3); }
.badge-red    { background: rgba(239,68,68,.12);   color: #f87171;            border: 0.5px solid rgba(239,68,68,.3); }
.badge-amber  { background: rgba(245,158,11,.12);  color: #fbbf24;            border: 0.5px solid rgba(245,158,11,.3); }
.badge-gray   { background: rgba(255,255,255,.06); color: var(--text-muted);  border: 0.5px solid rgba(255,255,255,.1); }

/* ══════════════════════════════════════════
   FORMS
══════════════════════════════════════════ */
.form-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }

.form-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.form-input {
    background: rgba(255,255,255,.04);
    border: 0.5px solid rgba(255,255,255,.12);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    font-size: 14px;
    color: #fff;
    font-weight: 300;
    transition: border .2s;
    outline: none;
    width: 100%;
}

.form-input:focus { border-color: rgba(139,92,246,.5); }
.form-input::placeholder { color: var(--text-dim); }
select.form-input option { background: var(--bg3); color: #fff; }
textarea.form-input { resize: vertical; min-height: 100px; }

.form-error { font-size: 12px; color: var(--red); margin-top: 4px; }
.form-hint  { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.col-full    { grid-column: 1 / -1; }

/* ══════════════════════════════════════════
   CARDS
══════════════════════════════════════════ */
.card {
    background: var(--bg2);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    position: relative;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 12px;
    flex-wrap: wrap;
}

.card-title { font-size: 16px; font-weight: 600; color: #fff; }
.card-sub   { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ══════════════════════════════════════════
   STAT CARDS
══════════════════════════════════════════ */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 24px; }

.stat-card {
    background: var(--bg2);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: border-color .3s;
}

.stat-card:hover { border-color: rgba(139,92,246,.4); }
.stat-card-label { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; font-weight: 400; }
.stat-card-value { font-family: 'Syne', sans-serif; font-size: 28px; font-weight: 700; color: #fff; letter-spacing: -1px; line-height: 1; }
.stat-card-sub   { font-size: 12px; color: var(--text-dim); margin-top: 6px; }

.stat-card.green  { border-color: rgba(34,197,94,.2);  }
.stat-card.green .stat-card-value { color: #4ade80; }
.stat-card.purple { border-color: rgba(124,58,237,.3); }
.stat-card.purple .stat-card-value { color: var(--purple-pale); }
.stat-card.amber  { border-color: rgba(245,158,11,.2); }
.stat-card.amber .stat-card-value { color: #fbbf24; }
.stat-card.red    { border-color: rgba(239,68,68,.2);  }
.stat-card.red .stat-card-value { color: #f87171; }

/* ══════════════════════════════════════════
   TABLES
══════════════════════════════════════════ */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { width: 100%; border-collapse: collapse; min-width: 600px; }

thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .06em;
    background: rgba(255,255,255,.02);
    border-bottom: 0.5px solid var(--border);
    white-space: nowrap;
}

tbody td {
    padding: 14px 16px;
    font-size: 13px;
    color: rgba(255,255,255,.75);
    border-bottom: 0.5px solid rgba(255,255,255,.04);
    vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,.02); }

/* ══════════════════════════════════════════
   ALERTS
══════════════════════════════════════════ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 400;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: rgba(34,197,94,.1);  color: #4ade80; border: 0.5px solid rgba(34,197,94,.2); }
.alert-error   { background: rgba(239,68,68,.1);  color: #f87171; border: 0.5px solid rgba(239,68,68,.2); }
.alert-warning { background: rgba(245,158,11,.1); color: #fbbf24; border: 0.5px solid rgba(245,158,11,.2); }
.alert-info    { background: rgba(124,58,237,.1); color: var(--purple-pale); border: 0.5px solid var(--border); }

/* ══════════════════════════════════════════
   ADMIN LAYOUT
══════════════════════════════════════════ */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: var(--sidebar-w);
    background: var(--bg2);
    border-right: 0.5px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform .3s;
    overflow-y: auto;
}

.sidebar-logo {
    padding: 24px 20px 16px;
    border-bottom: 0.5px solid var(--border);
}

.sidebar-logo a {
    font-family: 'Syne', sans-serif;
    font-size: 20px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -1px;
}

.sidebar-logo a span { color: var(--purple-light); }
.sidebar-role { font-size: 11px; color: var(--text-dim); margin-top: 4px; text-transform: uppercase; letter-spacing: .08em; }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }

.nav-group { margin-bottom: 16px; }
.nav-group-label { font-size: 10px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: .1em; padding: 0 8px; margin-bottom: 6px; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 400;
    transition: all .15s;
}

.sidebar-nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar-nav a.active { background: rgba(124,58,237,.15); color: var(--purple-pale); border: 0.5px solid rgba(124,58,237,.2); }

.sidebar-footer {
    padding: 16px 12px;
    border-top: 0.5px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: var(--radius-md);
    font-size: 13px;
    color: var(--text-muted);
    transition: all .15s;
}

.sidebar-footer a:hover { color: #fff; background: rgba(255,255,255,.05); }
.sidebar-footer a.logout { color: #f87171; }
.sidebar-footer a.logout:hover { background: rgba(239,68,68,.1); }

.admin-main {
    margin-left: var(--sidebar-w);
    flex: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.admin-topbar {
    height: var(--nav-h);
    background: var(--bg2);
    border-bottom: 0.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 16px;
}

.admin-topbar-title { font-family: 'Syne', sans-serif; font-size: 16px; font-weight: 700; }
.admin-topbar-right { display: flex; align-items: center; gap: 12px; }

.admin-content { padding: clamp(16px, 3vw, 32px); flex: 1; }

/* MOBILE SIDEBAR TOGGLE */
.sidebar-toggle {
    display: none;
    background: none;
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px;
    color: #fff;
    cursor: pointer;
}

/* ══════════════════════════════════════════
   CLIENT NAV
══════════════════════════════════════════ */
.client-nav {
    height: var(--nav-h);
    background: var(--bg2);
    border-bottom: 0.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 5%;
    position: sticky;
    top: 0;
    z-index: 100;
    gap: 16px;
}

.client-nav-logo a {
    font-family: 'Syne', sans-serif;
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    letter-spacing: -1px;
}

.client-nav-logo a span { color: var(--purple-light); }

.client-nav-links { display: flex; gap: 4px; }

.client-nav-links a {
    padding: 7px 14px;
    border-radius: 999px;
    font-size: 13px;
    color: var(--text-muted);
    transition: all .15s;
    font-weight: 400;
}

.client-nav-links a:hover { color: #fff; background: rgba(255,255,255,.05); }
.client-nav-links a.active { background: rgba(124,58,237,.15); color: var(--purple-pale); }

.client-nav-right { display: flex; align-items: center; gap: 12px; }
.client-nav-name  { font-size: 13px; color: var(--text-muted); }

.btn-logout {
    font-size: 12px;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(239,68,68,.1);
    color: #f87171;
    border: 0.5px solid rgba(239,68,68,.2);
    transition: all .15s;
}

.btn-logout:hover { background: rgba(239,68,68,.2); }

.client-content { max-width: 1100px; margin: 0 auto; padding: clamp(16px, 3vw, 40px) 5%; }

/* ══════════════════════════════════════════
   AUTH PAGES (login, register)
══════════════════════════════════════════ */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg);
}

.auth-card {
    background: var(--bg2);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-xl);
    padding: clamp(28px, 5vw, 48px);
    width: 100%;
    max-width: 420px;
    position: relative;
    overflow: hidden;
}

.auth-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--purple), transparent);
}

.auth-logo {
    font-family: 'Syne', sans-serif;
    font-size: 24px;
    font-weight: 800;
    color: #fff;
    text-align: center;
    margin-bottom: 6px;
    letter-spacing: -1px;
}

.auth-logo span { color: var(--purple-light); }
.auth-subtitle  { text-align: center; color: var(--text-muted); font-size: 13px; margin-bottom: 32px; font-weight: 300; }
.auth-title     { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.auth-link      { text-align: center; font-size: 13px; color: var(--text-muted); margin-top: 20px; }
.auth-link a    { color: var(--purple-pale); }
.auth-link a:hover { text-decoration: underline; }

/* ══════════════════════════════════════════
   CHATBOX
══════════════════════════════════════════ */
.chatbox-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999;
}

.chatbox-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--purple);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(124,58,237,.4);
    transition: all .2s;
}

.chatbox-btn:hover { background: var(--purple-light); transform: scale(1.05); }

.chatbox-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: min(360px, 90vw);
    background: var(--bg2);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    display: none;
    flex-direction: column;
}

.chatbox-panel.open { display: flex; }

.chatbox-header {
    padding: 16px 20px;
    background: var(--bg3);
    border-bottom: 0.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chatbox-header-info { display: flex; align-items: center; gap: 10px; }

.chatbox-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--purple);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.chatbox-name   { font-size: 14px; font-weight: 500; }
.chatbox-status { font-size: 11px; color: #4ade80; display: flex; align-items: center; gap: 4px; }
.chatbox-close  { background: none; border: none; color: var(--text-muted); font-size: 18px; cursor: pointer; padding: 4px; }

.chatbox-messages {
    flex: 1;
    height: 300px;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-msg { max-width: 85%; }
.chat-msg.bot  { align-self: flex-start; }
.chat-msg.user { align-self: flex-end; }

.chat-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 13px;
    line-height: 1.6;
    font-weight: 300;
}

.chat-msg.bot  .chat-bubble { background: rgba(124,58,237,.15); border: 0.5px solid rgba(124,58,237,.2); border-bottom-left-radius: 4px; color: rgba(255,255,255,.85); }
.chat-msg.user .chat-bubble { background: var(--purple); border-bottom-right-radius: 4px; color: #fff; }

.chat-time { font-size: 10px; color: var(--text-dim); margin-top: 4px; padding: 0 4px; }
.chat-msg.user .chat-time { text-align: right; }

.chatbox-input {
    padding: 12px 16px;
    border-top: 0.5px solid var(--border);
    display: flex;
    gap: 8px;
}

.chatbox-input input {
    flex: 1;
    background: rgba(255,255,255,.05);
    border: 0.5px solid rgba(255,255,255,.1);
    border-radius: 999px;
    padding: 9px 16px;
    font-size: 13px;
    color: #fff;
    outline: none;
    font-family: inherit;
}

.chatbox-input input:focus { border-color: rgba(139,92,246,.4); }
.chatbox-input input::placeholder { color: var(--text-dim); }

.chatbox-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--purple);
    border: none;
    color: #fff;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: all .15s;
}

.chatbox-send:hover { background: var(--purple-light); }

/* ══════════════════════════════════════════
   PAGINATION
══════════════════════════════════════════ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.page-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: 0.5px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all .15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.page-btn:hover  { border-color: var(--purple); color: #fff; }
.page-btn.active { background: var(--purple); border-color: var(--purple); color: #fff; }

/* ══════════════════════════════════════════
   MODAL
══════════════════════════════════════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.7);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg2);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-xl);
    padding: clamp(24px, 4vw, 40px);
    width: 100%;
    max-width: 520px;
    position: relative;
}

.modal::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--purple), transparent);
}

.modal-title  { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.modal-sub    { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }
.modal-close  { position: absolute; top: 16px; right: 16px; background: none; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; }
.modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; flex-wrap: wrap; }

/* ══════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════ */
.empty-state {
    text-align: center;
    padding: clamp(40px, 8vw, 80px) 20px;
    color: var(--text-muted);
}

.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state h3   { font-size: 18px; color: #fff; margin-bottom: 8px; }
.empty-state p    { font-size: 14px; max-width: 320px; margin: 0 auto 24px; }

/* ══════════════════════════════════════════
   ANIMATIONS
══════════════════════════════════════════ */
@keyframes fadeUp   { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn   { from { opacity:0; } to { opacity:1; } }
@keyframes slideIn  { from { transform:translateX(-100%); } to { transform:translateX(0); } }

.animate-fade-up { animation: fadeUp .5s ease both; }
.animate-fade-in { animation: fadeIn .3s ease both; }

.reveal { opacity:0; transform:translateY(20px); transition: all .6s ease; }
.reveal.visible { opacity:1; transform:translateY(0); }

/* ══════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════ */
@media (max-width: 1024px) {
    :root { --sidebar-w: 220px; }
}

@media (max-width: 768px) {
    /* ADMIN SIDEBAR MOBILE */
    .admin-sidebar {
        transform: translateX(-100%);
    }

    .admin-sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-lg);
    }

    .admin-main {
        margin-left: 0;
    }

    .sidebar-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* CLIENT NAV MOBILE */
    .client-nav-links { display: none; }
    .client-nav-links.open {
        display: flex;
        flex-direction: column;
        position: absolute;
        top: var(--nav-h);
        left: 0; right: 0;
        background: var(--bg2);
        border-bottom: 0.5px solid var(--border);
        padding: 16px 5%;
        gap: 4px;
    }

    /* FORMS */
    .form-grid-2,
    .form-grid-3 { grid-template-columns: 1fr; }

    /* TABLES */
    table { min-width: 500px; }

    /* CHATBOX */
    .chatbox-widget { bottom: 16px; right: 16px; }
    .chatbox-panel { width: calc(100vw - 32px); right: -8px; }

    /* MODAL */
    .modal { max-width: 100%; }
    .modal-footer { flex-direction: column-reverse; }
    .modal-footer .btn { width: 100%; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .admin-topbar { padding: 0 16px; }
    .admin-content { padding: 16px; }
    .chatbox-messages { height: 240px; }
}

@media (max-width: 360px) {
    .stat-grid { grid-template-columns: 1fr; }
}