/* ═══════════════════════════════════════
   Shronix WA Panel — Main Stylesheet
   Dark / Light Theme Support
═══════════════════════════════════════ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── CSS Variables ── */
:root {
    --bg:          #0a0f1e;
    --surface:     #111827;
    --surface2:    #1a2236;
    --border:      #1e2d45;
    --green:       #25D366;
    --green-dark:  #128C7E;
    --accent:      #00e5a0;
    --text:        #e2e8f0;
    --text-muted:  #64748b;
    --danger:      #ef4444;
    --warning:     #f59e0b;
    --info:        #3b82f6;
    --radius:      12px;
    --shadow:      0 4px 24px rgba(0,0,0,0.4);
    --sidebar-w:   240px;
}

[data-theme="light"] {
    --bg:         #f0f4f8;
    --surface:    #ffffff;
    --surface2:   #f8fafc;
    --border:     #e2e8f0;
    --text:       #1e293b;
    --text-muted: #94a3b8;
    --shadow:     0 4px 24px rgba(0,0,0,0.08);
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    transition: background 0.3s, color 0.3s;
}

/* ── Background Glow ── */
body::before {
    content: '';
    position: fixed; inset: 0;
    background:
        radial-gradient(ellipse 600px 400px at 15% 15%, rgba(37,211,102,0.06) 0%, transparent 70%),
        radial-gradient(ellipse 400px 300px at 85% 85%, rgba(0,229,160,0.04) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

[data-theme="light"] body::before { display:none; }

/* ════════════════════════════════════
   AUTH PAGES
════════════════════════════════════ */
.auth-body { display:flex; flex-direction:column; align-items:center; justify-content:center; min-height:100vh; padding:20px; }

.auth-wrap { width:100%; max-width:420px; position:relative; z-index:1; }

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px 36px;
    box-shadow: var(--shadow);
    animation: slideUp 0.4s ease;
}

@keyframes slideUp {
    from { opacity:0; transform:translateY(24px); }
    to   { opacity:1; transform:translateY(0); }
}

.auth-logo {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 28px;
}
.logo-icon {
    width: 48px; height: 48px;
    background: linear-gradient(135deg, var(--green), var(--accent));
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; flex-shrink: 0;
}
.logo-title { font-size: 18px; font-weight: 700; }
.logo-sub   { font-size: 12px; color: var(--text-muted); }

.step-dots { display:flex; gap:6px; margin-bottom:20px; }
.dot { flex:1; height:4px; border-radius:2px; background:var(--border); transition:background 0.3s; }
.dot.active { background:var(--accent); }
.dot.done   { background:var(--green); }

.auth-title { font-size:22px; font-weight:700; margin-bottom:4px; }
.auth-sub   { font-size:13px; color:var(--text-muted); margin-bottom:24px; }

.field { margin-bottom:14px; }
.field label { display:block; font-size:12px; font-weight:600; color:var(--text-muted); margin-bottom:6px; text-transform:uppercase; letter-spacing:0.04em; }

.input-icon-wrap { position:relative; }
.iico { position:absolute; left:12px; top:50%; transform:translateY(-50%); font-size:15px; }

input[type="text"], input[type="tel"], input[type="password"], input[type="email"],
input[type="number"], input[type="url"], select, textarea {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    padding: 11px 14px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.input-icon-wrap input { padding-left: 40px; }
input:focus, select:focus, textarea:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(37,211,102,0.1);
}
select option { background: var(--surface2); }
textarea { resize: vertical; min-height: 80px; }

.otp-field {
    text-align: center; font-size: 22px;
    font-family: 'JetBrains Mono', monospace;
    letter-spacing: 8px; font-weight: 500;
}

.btn-auth {
    width: 100%; padding: 13px;
    border: none; border-radius: 10px;
    background: linear-gradient(135deg, var(--green), #1db954);
    color: #fff; font-family: inherit; font-size: 15px; font-weight: 600;
    cursor: pointer; transition: all 0.2s; margin-top: 6px;
}
.btn-auth:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn-auth:active { transform: translateY(0); }

.btn-auth-outline {
    width: 100%; padding: 11px;
    border: 1px solid var(--border); border-radius: 10px;
    background: transparent; color: var(--text-muted);
    font-family: inherit; font-size: 13px; font-weight: 500;
    cursor: pointer; transition: all 0.2s;
}
.btn-auth-outline:hover { border-color: var(--green); color: var(--green); }

.btn-auth-link {
    background: none; border: none; color: var(--text-muted);
    font-size: 13px; cursor: pointer; padding: 8px;
    transition: color 0.2s; font-family: inherit; width: 100%;
}
.btn-auth-link:hover { color: var(--green); }

.auth-footer { text-align:center; color:var(--text-muted); font-size:12px; margin-top:20px; }

/* ════════════════════════════════════
   APP LAYOUT
════════════════════════════════════ */
.app-layout { display:flex; min-height:100vh; position:relative; z-index:1; }

/* ── Sidebar ── */
.sidebar {
    width: var(--sidebar-w);
    min-height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    padding: 20px 14px;
    position: fixed; top:0; left:0; bottom:0;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-logo {
    display: flex; align-items: center; gap: 10px;
    padding: 4px 8px; margin-bottom: 28px;
}
.sidebar-logo .logo-icon { width:34px; height:34px; font-size:15px; border-radius:8px; }
.sidebar-logo span { font-size:15px; font-weight:700; }

.nav-section {
    font-size: 10px; font-weight: 700; letter-spacing: 0.1em;
    text-transform: uppercase; color: var(--text-muted);
    padding: 0 8px; margin: 18px 0 6px;
}

.nav-item {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 12px; border-radius: 8px;
    cursor: pointer; font-size: 13px; font-weight: 500;
    color: var(--text-muted);
    transition: all 0.15s; margin-bottom: 1px;
    text-decoration: none;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(37,211,102,0.12); color: var(--green); }
.nav-item .ni { font-size:15px; width:18px; text-align:center; }

.sidebar-bottom { margin-top: auto; }

.user-chip {
    display: flex; align-items: center; gap: 9px;
    padding: 10px 12px; background: var(--surface2);
    border-radius: 10px; margin-bottom: 8px;
}
.user-avatar {
    width: 30px; height: 30px;
    background: linear-gradient(135deg, var(--green), var(--accent));
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #fff; flex-shrink:0;
}
.user-info { flex:1; min-width:0; }
.user-name  { font-size:12px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.user-role  { font-size:10px; color:var(--text-muted); }

.theme-toggle {
    display: flex; align-items: center; gap: 9px;
    padding: 9px 12px; border-radius: 8px;
    cursor: pointer; font-size: 13px; font-weight: 500;
    color: var(--text-muted); transition: all 0.15s;
    background: none; border: none; width: 100%; font-family: inherit;
    margin-bottom: 2px;
}
.theme-toggle:hover { background: var(--surface2); color: var(--text); }

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

.page-header { margin-bottom: 24px; }
.page-title  { font-size: 22px; font-weight: 700; }
.page-sub    { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ── Cards ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    margin-bottom: 18px;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 18px;
}
.card-title { font-size: 14px; font-weight: 600; }

/* ── Stats Grid ── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 20px; }

.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px;
}
.stat-icon  { font-size: 22px; margin-bottom: 10px; }
.stat-value { font-size: 26px; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 3px; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-green { color: var(--green); }
.stat-red   { color: var(--danger); }
.stat-blue  { color: var(--info); }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left; padding: 9px 14px;
    font-size: 11px; font-weight: 700; color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    text-transform: uppercase; letter-spacing: 0.06em;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13px; }
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(255,255,255,0.02); }
[data-theme="light"] tbody tr:hover td { background: rgba(0,0,0,0.02); }

.empty-row td { text-align:center; color:var(--text-muted); padding:32px; }

/* ── Badges ── */
.badge {
    display: inline-flex; align-items: center;
    padding: 3px 10px; border-radius: 20px;
    font-size: 11px; font-weight: 600; white-space:nowrap;
}
.badge-green  { background: rgba(37,211,102,0.15); color: var(--green); }
.badge-red    { background: rgba(239,68,68,0.15);  color: var(--danger); }
.badge-yellow { background: rgba(245,158,11,0.15); color: var(--warning); }
.badge-blue   { background: rgba(59,130,246,0.15); color: var(--info); }
.badge-gray   { background: rgba(100,116,139,0.15); color: var(--text-muted); }

/* ── Buttons ── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 18px; border: none; border-radius: 8px;
    font-family: inherit; font-size: 13px; font-weight: 600;
    cursor: pointer; transition: all 0.2s; text-decoration: none;
    white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, var(--green), #1db954); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger  { background: rgba(239,68,68,0.15); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-outline { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--green); color: var(--green); }
.btn-sm { padding: 6px 13px; font-size: 12px; }

/* ── Forms ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.single { grid-template-columns: 1fr; }
.form-grid.triple { grid-template-columns: 1fr 1fr 1fr; }
.field-full { grid-column: 1 / -1; }

.form-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:16px; }

/* ── Alerts ── */
.alert {
    padding: 11px 16px; border-radius: 9px;
    font-size: 13px; margin-bottom: 16px;
    display: flex; align-items: flex-start; gap: 8px;
}
.alert-error   { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.25); color: #fca5a5; }
.alert-success { background: rgba(37,211,102,0.1); border: 1px solid rgba(37,211,102,0.25); color: #6ee7b7; }
.alert-info    { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.25); color: #93c5fd; }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.25); color: #fcd34d; }

/* ── API Status ── */
.api-status {
    display: flex; align-items: center; gap: 8px;
    padding: 11px 16px; border-radius: 8px; font-size: 13px; margin-bottom: 18px;
}
.api-status.connected    { background: rgba(37,211,102,0.1); border: 1px solid rgba(37,211,102,0.2); color: var(--green); }
.api-status.disconnected { background: rgba(239,68,68,0.1);  border: 1px solid rgba(239,68,68,0.2);  color: var(--danger); }
.pulse {
    width: 8px; height: 8px; border-radius: 50%; background: currentColor;
    animation: pulse 2s infinite; flex-shrink:0;
}
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.3} }

/* ── Code Block ── */
.code-block {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 8px; padding: 14px 16px;
    font-family: 'JetBrains Mono', monospace; font-size: 12px;
    overflow-x: auto; color: var(--accent);
    line-height: 1.7;
}
.code-block .comment { color: var(--text-muted); }
.code-block .key     { color: var(--warning); }
.code-block .str     { color: #86efac; }

/* ── API Key Box ── */
.api-key-box {
    background: var(--surface2); border: 1px solid var(--border);
    border-radius: 10px; padding: 16px 18px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.api-key-val {
    font-family: 'JetBrains Mono', monospace; font-size: 13px;
    color: var(--accent); word-break: break-all; flex:1;
}

/* ── Info Row ── */
.info-row { display:flex; padding:10px 0; border-bottom:1px solid var(--border); font-size:13px; }
.info-row:last-child { border-bottom:none; }
.info-label { width:180px; color:var(--text-muted); flex-shrink:0; font-weight:500; }
.info-val   { flex:1; font-family:'JetBrains Mono',monospace; font-size:12px; word-break:break-all; }

/* ── Topbar (mobile) ── */
.topbar {
    display: none; align-items: center; justify-content: space-between;
    padding: 14px 16px; background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top:0; z-index:50;
}
.menu-btn { background:none; border:none; color:var(--text); font-size:20px; cursor:pointer; }

/* ── Modal ── */
.modal-overlay {
    position: fixed; inset:0; background: rgba(0,0,0,0.65);
    display: flex; align-items: center; justify-content: center;
    z-index: 500; opacity:0; pointer-events:none; transition:opacity 0.2s;
}
.modal-overlay.open { opacity:1; pointer-events:all; }
.modal {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 16px; padding: 26px;
    width:90%; max-width:440px;
    transform: scale(0.95); transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-title { font-size:16px; font-weight:700; margin-bottom:20px; display:flex; justify-content:space-between; align-items:center; }
.modal-close { cursor:pointer; color:var(--text-muted); font-size:18px; background:none; border:none; }

/* ── Misc ── */
.mono      { font-family:'JetBrains Mono',monospace; font-size:12px; }
.text-muted { color:var(--text-muted); }
.text-green { color:var(--green); }
.text-red   { color:var(--danger); }
.mb-0 { margin-bottom:0; }
.mt-2 { margin-top:8px; }
.divider { border:none; border-top:1px solid var(--border); margin:18px 0; }

/* ── Spinner ── */
.spinner {
    width:16px; height:16px;
    border:2px solid rgba(255,255,255,0.3);
    border-top-color:#fff; border-radius:50%;
    animation: spin 0.6s linear infinite; display:inline-block;
}
@keyframes spin { to { transform:rotate(360deg); } }

/* ── Credits Bar ── */
.credits-bar-wrap { background:var(--surface2); border-radius:6px; height:8px; overflow:hidden; margin-top:6px; }
.credits-bar { height:100%; background:linear-gradient(90deg,var(--green),var(--accent)); border-radius:6px; transition:width 0.5s; }

/* ── Pagination ── */
.pagination { display:flex; gap:4px; justify-content:flex-end; margin-top:14px; }
.page-btn {
    padding:6px 12px; border-radius:6px; border:1px solid var(--border);
    background:var(--surface2); color:var(--text-muted); font-size:12px;
    cursor:pointer; text-decoration:none; transition:all 0.2s;
}
.page-btn.active { background:var(--green); color:#fff; border-color:var(--green); }
.page-btn:hover:not(.active) { border-color:var(--green); color:var(--green); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left:0; padding:16px; }
    .topbar { display:flex; }
    .form-grid { grid-template-columns:1fr; }
    .stats-grid { grid-template-columns:1fr 1fr; }
}
