/* ═══════════════════════════════════════════════════════════════════════════
   WACFL — WhatsApp-inspired design system
   Palette: #075E54 (dark), #128C7E (primary), #25D366 (accent), #dcf8c6 (msg)
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
    --wa-dark: #075E54;
    --wa-primary: #128C7E;
    --wa-accent: #25D366;
    --wa-msg: #dcf8c6;
    --wa-bg: #eae6df;
    --wa-sidebar: #111b21;
    --wa-sidebar-hover: #202c33;
    --wa-chat-bg: #efeae2;
    --wa-panel: #f0f2f5;
    --wa-danger: #e74c3c;
    --wa-warning: #f39c12;
    --sidebar-width: 260px;
    --topbar-height: 64px;
    --radius: 12px;
    --radius-sm: 8px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--wa-panel);
    min-height: 100vh;
    color: #303030;
    letter-spacing: -0.01em;
}

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--wa-sidebar);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar .brand {
    padding: 24px 20px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #e9edef;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.02em;
}

.sidebar .brand .dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--wa-accent);
    box-shadow: 0 0 0 4px rgba(37,211,102,0.2);
}

.sidebar .nav-section {
    padding: 8px 0;
    flex: 1;
}

.sidebar .nav-section .title {
    padding: 16px 20px 6px;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #8696a0;
    font-weight: 600;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    margin: 0 8px;
    border-radius: var(--radius-sm);
    color: #aebac1;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.12s;
    font-weight: 500;
}

.sidebar .nav-link:hover {
    background: var(--wa-sidebar-hover);
    color: #e9edef;
}

.sidebar .nav-link.active {
    background: rgba(18,140,126,0.25);
    color: #00a884;
    font-weight: 600;
}

.sidebar .nav-link i { font-size: 1.1rem; width: 22px; text-align: center; }

.sidebar .nav-section.bottom {
    border-top: 1px solid rgba(255,255,255,0.06);
    padding-top: 8px;
    margin-top: auto;
}

/* ── Main ─────────────────────────────────────────────────────────────── */
.main {
    margin-left: var(--sidebar-width);
    padding: 0;
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    background: #fff;
    border-bottom: 1px solid #e9edef;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
}

.topbar h1 {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    color: #111b21;
    letter-spacing: -0.02em;
}

.topbar .user-info {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.88rem;
    color: #667781;
}

.topbar .user-info .pwd-btn {
    color: #8696a0;
    cursor: pointer;
    transition: color 0.15s;
    font-size: 1rem;
}

.topbar .user-info .pwd-btn:hover { color: var(--wa-primary); }

.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--wa-primary), var(--wa-dark));
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
}

.content-area { padding: 24px 32px; }

/* ── Cards ────────────────────────────────────────────────────────────── */
.stat-card {
    background: #fff;
    border: none;
    border-radius: var(--radius);
    padding: 20px 24px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.04);
    transition: box-shadow 0.2s, transform 0.2s;
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}

.stat-card .stat-icon {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    opacity: 0.08;
}

.stat-card .stat-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #667781;
    font-weight: 600;
    margin-bottom: 4px;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    color: #111b21;
    letter-spacing: -0.03em;
}

.stat-card.accent .stat-value { color: var(--wa-primary); }
.stat-card.success .stat-value { color: var(--wa-accent); }

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.04);
    overflow: hidden;
}

.table-card .table-header {
    padding: 18px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #f0f2f5;
}

.table-card .table-header h5 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: #111b21;
    letter-spacing: -0.01em;
}

.table-card table { margin-bottom: 0; }

.table-card table thead th {
    background: #f8fafb;
    border-bottom: 1px solid #e9edef;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #667781;
    font-weight: 700;
    padding: 10px 24px;
}

.table-card table tbody td {
    padding: 12px 24px;
    border-bottom: 1px solid #f5f6f8;
    vertical-align: middle;
    font-size: 0.9rem;
}

.table-card table tbody tr:hover { background: #f8fafb; }
.table-card table tbody tr:last-child td { border-bottom: none; }

/* ── Buttons ──────────────────────────────────────────────────────────── */
.btn-wa {
    background: var(--wa-primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    padding: 8px 20px;
    font-weight: 600;
    font-size: 0.88rem;
    transition: all 0.15s;
}

.btn-wa:hover { background: var(--wa-dark); color: #fff; }

.btn-wa-outline {
    background: transparent;
    color: var(--wa-primary);
    border: 1.5px solid var(--wa-primary);
    border-radius: var(--radius-sm);
    padding: 7px 18px;
    font-weight: 600;
    font-size: 0.88rem;
    transition: all 0.15s;
}

.btn-wa-outline:hover {
    background: var(--wa-primary);
    color: #fff;
}

.btn-wa-sm {
    padding: 5px 14px;
    font-size: 0.8rem;
    border-radius: 6px;
}

.btn-wa-danger {
    background: transparent;
    color: var(--wa-danger);
    border: 1.5px solid var(--wa-danger);
    border-radius: var(--radius-sm);
    padding: 7px 18px;
    font-weight: 600;
    font-size: 0.88rem;
}

.btn-wa-danger:hover { background: var(--wa-danger); color: #fff; }

/* ── Badges ───────────────────────────────────────────────────────────── */
.badge-wa {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    letter-spacing: 0.02em;
}

.badge-wa.online { background: #e6f9f1; color: #008069; }
.badge-wa.offline { background: #f5f6f8; color: #8696a0; }
.badge-wa.sent { background: #dcf8c6; color: #075e54; }
.badge-wa.failed { background: #fde8e8; color: #c0392b; }
.badge-wa.active { background: #e6f9f1; color: #008069; }
.badge-wa.inactive { background: #f5f6f8; color: #8696a0; }

/* ── Status dot ───────────────────────────────────────────────────────── */
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.dot.online { background: var(--wa-accent); box-shadow: 0 0 0 3px rgba(37,211,102,0.18); }
.dot.offline { background: #becbd3; }

/* ── Modals ───────────────────────────────────────────────────────────── */
.modal-content {
    border: none;
    border-radius: var(--radius);
    box-shadow: 0 20px 60px rgba(0,0,0,0.18);
}

.modal-header {
    border-bottom: 1px solid #f0f2f5;
    padding: 18px 24px;
}

.modal-header .modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: #111b21;
}

.modal-body { padding: 24px; }

.modal-footer {
    border-top: 1px solid #f0f2f5;
    padding: 16px 24px;
}

.modal-footer .btn {
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.88rem;
}

.form-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: #3b4a54;
    margin-bottom: 4px;
}

.form-control, .form-select {
    border: 1.5px solid #e9edef;
    border-radius: var(--radius-sm);
    padding: 9px 14px;
    font-size: 0.9rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--wa-primary);
    box-shadow: 0 0 0 3px rgba(18,140,126,0.12);
    outline: none;
}

.form-control-sm, .form-select-sm {
    padding: 6px 10px;
    font-size: 0.82rem;
    border-radius: 6px;
}

/* ── QR Section ───────────────────────────────────────────────────────── */
.qr-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
}

.qr-card img {
    border: 3px solid #e9edef;
    border-radius: var(--radius);
    padding: 8px;
    background: #fff;
}

/* ── Key reveal ───────────────────────────────────────────────────────── */
.key-reveal {
    background: linear-gradient(135deg, #1e2d29, #0b1f1a);
    color: #00e676;
    padding: 20px;
    border-radius: var(--radius-sm);
    font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.82rem;
    word-break: break-all;
    text-align: center;
    margin: 16px 0;
    border: 1px solid rgba(0,230,118,0.25);
}

/* ── Login ────────────────────────────────────────────────────────────── */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #0b1f1a 0%, #075E54 40%, #128C7E 100%);
    position: relative;
    overflow: hidden;
}

.login-wrapper::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 800px;
    height: 800px;
    background: radial-gradient(circle, rgba(37,211,102,0.12) 0%, transparent 70%);
    border-radius: 50%;
}

.login-wrapper::after {
    content: '';
    position: absolute;
    bottom: -40%;
    left: -20%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(255,255,255,0.04) 0%, transparent 70%);
    border-radius: 50%;
}

.login-card {
    width: 400px;
    padding: 44px 36px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 80px rgba(0,0,0,0.35);
    position: relative;
    z-index: 1;
}

.login-card .brand {
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 32px;
    color: #111b21;
    letter-spacing: -0.02em;
}

.login-card .brand .icon {
    display: inline-block;
    width: 48px; height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--wa-accent), var(--wa-primary));
    color: #fff;
    font-size: 1.3rem;
    line-height: 48px;
    margin-bottom: 12px;
}

.login-card .form-control {
    padding: 12px 14px;
}

.login-card .btn {
    padding: 12px;
    font-weight: 700;
    font-size: 0.95rem;
    border-radius: var(--radius-sm);
    background: var(--wa-primary);
    border: none;
    color: #fff;
    transition: all 0.15s;
}

.login-card .btn:hover { background: var(--wa-dark); }

/* ── Toast ────────────────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

/* ── Pagination ───────────────────────────────────────────────────────── */
.pagination .page-link {
    border: 1.5px solid #e9edef;
    color: #3b4a54;
    border-radius: 6px;
    margin: 0 2px;
    font-weight: 500;
    font-size: 0.85rem;
}

.pagination .page-item.active .page-link {
    background: var(--wa-primary);
    border-color: var(--wa-primary);
    color: #fff;
}

/* ── Empty state ──────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: #8696a0;
}

.empty-state i { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 0.9rem; margin: 0; }

/* ── Filter row ───────────────────────────────────────────────────────── */
.filter-row {
    padding: 14px 24px;
    background: #f8fafb;
    border-bottom: 1px solid #f0f2f5;
}

/* ── Send form ────────────────────────────────────────────────────────── */
.send-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.send-card .card-header {
    padding: 18px 24px;
    border-bottom: 1px solid #f0f2f5;
    font-weight: 700;
    font-size: 0.95rem;
    color: #111b21;
}

.send-card .card-body { padding: 24px; }

/* ── Hamburger ────────────────────────────────────────────────────────── */
.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: #3b4a54;
    cursor: pointer;
    padding: 4px 8px;
}

/* ── Sidebar overlay (mobile) ─────────────────────────────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 260px;
    }

    .hamburger { display: block; }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0,0,0,0.3);
    }

    .sidebar-overlay.show { display: block; }

    .main {
        margin-left: 0 !important;
        overflow-x: hidden;
    }

    .topbar {
        padding: 0 12px;
        position: sticky;
        top: 0;
    }

    .topbar h1 {
        font-size: 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .content-area {
        padding: 12px 8px;
        overflow-x: hidden;
    }

    /* Stats cards: full width on mobile */
    .content-area > .row {
        flex-wrap: wrap;
    }

    .content-area .row > .col,
    .content-area .row > [class*="col-"] {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        padding: 4px !important;
    }

    .stat-card {
        padding: 12px 14px;
        border-radius: var(--radius-sm);
    }

    .stat-card .stat-value {
        font-size: 1.25rem;
    }

    .stat-card .stat-label {
        font-size: 0.68rem;
    }

    .stat-card .stat-icon {
        font-size: 1.4rem;
        right: 10px;
    }

    /* Tables scroll within their container only */
    .table-card {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }

    .table-card table {
        width: 100%;
        font-size: 0.8rem;
    }

    .table-card .table-header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 14px;
    }

    .table-card .filter-row {
        padding: 8px 14px;
    }

    .table-card table thead th,
    .table-card table tbody td {
        padding: 8px 10px;
    }

    /* Full-width stacking for sections */
    .content-area .table-card + .table-card {
        margin-top: 12px;
    }

    /* Modals near fullscreen */
    .modal-dialog {
        margin: 4px;
        max-width: calc(100vw - 8px);
    }

    .modal-body {
        padding: 14px;
    }

    .modal-header, .modal-footer {
        padding: 10px 14px;
    }

    /* Forms */
    .form-control, .form-select {
        padding: 10px 12px;
        font-size: 16px;
    }

    /* QR */
    .qr-card {
        padding: 12px;
    }

    .qr-card img {
        max-width: 160px !important;
    }

    /* Login */
    .login-card {
        width: calc(100vw - 32px);
        padding: 28px 20px;
    }

    .login-card img {
        max-width: 200px !important;
    }

    /* Buttons */
    .btn-wa-sm, .btn-wa-outline.btn-wa-sm {
        padding: 8px 14px;
        font-size: 0.82rem;
    }

    /* Pagination */
    .pagination .page-link {
        padding: 4px 7px;
        font-size: 0.75rem;
    }

    /* User info */
    .topbar .user-info {
        gap: 6px;
        font-size: 0.78rem;
    }

    .topbar .user-info #user-email {
        display: none;
    }

    /* Empty state */
    .empty-state {
        padding: 28px 14px;
    }

    .empty-state i { font-size: 1.6rem; }

    /* Send message form */
    .send-card .card-body {
        padding: 14px;
    }

    #send-form .row > [class*="col-"] {
        flex: 0 0 100% !important;
        max-width: 100% !important;
    }
}
