:root {
    --wa-green: #25D366;
    --wa-dark: #128C7E;
    --wa-light: #DCF8C6;
    --wa-teal: #075E54;
    --sidebar-w: 260px;
    --radius: 12px;
    --shadow: 0 2px 15px rgba(0,0,0,0.08);
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
}

/* ===== AUTH PAGES ===== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--wa-teal) 0%, var(--wa-dark) 50%, #1a1a2e 100%);
    padding: 20px;
}

.auth-card {
    background: white;
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.auth-logo {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo .wa-icon {
    width: 70px;
    height: 70px;
    background: var(--wa-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 15px;
    font-size: 32px;
}

.auth-logo h1 { font-size: 22px; color: var(--wa-teal); }
.auth-logo p { color: #888; font-size: 13px; }

/* ===== LAYOUT ===== */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-w);
    background: var(--wa-teal);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-logo {
    padding: 25px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo .wa-icon {
    width: 42px;
    height: 42px;
    background: var(--wa-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.sidebar-logo span { font-size: 16px; font-weight: 700; }

.sidebar-nav {
    padding: 15px 0;
    flex: 1;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 13px 20px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover, .nav-item.active {
    background: rgba(255,255,255,0.12);
    color: white;
    border-left-color: var(--wa-green);
}

.nav-item .icon { font-size: 18px; width: 22px; text-align: center; }

.sidebar-footer {
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--wa-green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.6); }

/* ===== MAIN CONTENT ===== */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: white;
    padding: 15px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title { font-size: 20px; font-weight: 700; color: var(--wa-teal); }

.page-content {
    padding: 30px;
    flex: 1;
}

/* ===== CARDS ===== */
.card {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 20px 25px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 { font-size: 16px; font-weight: 700; color: var(--wa-teal); }
.card-body { padding: 25px; }

/* ===== STATS ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 25px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 18px;
}

.stat-icon {
    width: 55px;
    height: 55px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

.stat-icon.green { background: #e8f8ee; }
.stat-icon.blue { background: #e8f0fe; }
.stat-icon.orange { background: #fff3e0; }
.stat-icon.red { background: #fde8e8; }

.stat-num { font-size: 28px; font-weight: 800; color: #222; }
.stat-label { font-size: 13px; color: #888; margin-top: 2px; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #555; margin-bottom: 6px; }

.form-control {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
    background: #fafafa;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--wa-green);
    background: white;
    box-shadow: 0 0 0 3px rgba(37,211,102,0.1);
}

textarea.form-control { resize: vertical; min-height: 100px; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary { background: var(--wa-green); color: white; }
.btn-primary:hover { background: var(--wa-dark); }
.btn-secondary { background: #f0f0f0; color: #555; }
.btn-secondary:hover { background: #e0e0e0; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-info { background: #3b82f6; color: white; }
.btn-info:hover { background: #2563eb; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; }
.btn-lg { padding: 13px 28px; font-size: 15px; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
    padding: 12px 16px;
    background: #f8f9fa;
    font-weight: 600;
    color: #555;
    text-align: left;
    border-bottom: 2px solid #eee;
    white-space: nowrap;
}
tbody td { padding: 13px 16px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
tbody tr:hover { background: #fafffe; }

/* ===== BADGES ===== */
.badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f3f4f6; color: #374151; }

/* ===== API KEY BOX ===== */
.api-key-box {
    background: #0f172a;
    color: #22d3ee;
    padding: 16px 20px;
    border-radius: 10px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    word-break: break-all;
    margin: 12px 0;
}

.api-url-box {
    background: #1e293b;
    color: #94a3b8;
    padding: 14px 18px;
    border-radius: 10px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    word-break: break-all;
    line-height: 1.6;
    margin: 8px 0;
}

.api-url-box .highlight { color: #22d3ee; }
.api-url-box .param { color: #f59e0b; }

/* ===== QR CODE AREA ===== */
.qr-container {
    text-align: center;
    padding: 30px;
}

.qr-box {
    display: inline-block;
    padding: 20px;
    background: white;
    border: 3px solid var(--wa-green);
    border-radius: 16px;
    margin: 20px 0;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}
.status-indicator.connected { background: #d1fae5; color: #065f46; }
.status-indicator.disconnected { background: #fee2e2; color: #991b1b; }
.status-indicator .dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}
.status-indicator.connected .dot { background: #10b981; }
.status-indicator.disconnected .dot { background: #ef4444; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

/* ===== SEARCH BAR ===== */
.search-bar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.search-input { flex: 1; min-width: 200px; }

/* ===== ALERTS ===== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success { background: #d1fae5; color: #065f46; border-left: 4px solid #10b981; }
.alert-error { background: #fee2e2; color: #991b1b; border-left: 4px solid #ef4444; }
.alert-info { background: #dbeafe; color: #1e40af; border-left: 4px solid #3b82f6; }

/* ===== MOBILE TOGGLE ===== */
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--wa-teal);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .main-content { margin-left: 0; }
    .mobile-toggle { display: block; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .page-content { padding: 15px; }
    .topbar { padding: 12px 15px; }
}

.text-muted { color: #888; font-size: 13px; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.flex { display: flex; }
.gap-10 { gap: 10px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }

/* Pagination */
.pagination { display: flex; gap: 5px; align-items: center; justify-content: center; margin-top: 20px; }
.page-btn {
    width: 36px; height: 36px; border: 1.5px solid #e0e0e0;
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
    font-size: 13px; cursor: pointer; background: white; text-decoration: none; color: #333; transition: all 0.2s;
}
.page-btn:hover, .page-btn.active { background: var(--wa-green); color: white; border-color: var(--wa-green); }
