/*  ===== WAI Dashboard Styles ===== */

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #a5b4fc;
    --secondary: #06b6d4;
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1e293b;
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 72px;
    --bottom-nav-height: 64px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== Login Page ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
}

.login-card {
    background: white;
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-card h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 8px;
    text-align: center;
}

.login-card p {
    color: var(--gray-500);
    text-align: center;
    margin-bottom: 24px;
}

.login-card .logo {
    text-align: center;
    margin-bottom: 24px;
}

.login-card .logo span {
    font-size: 48px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-200);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

/* ===== Dashboard Layout ===== */
.dashboard {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-900);
    color: white;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: width 0.25s ease, padding 0.25s ease, transform 0.25s ease;
}

/* Collapsed Sidebar */
.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    padding: 24px 8px;
}

.sidebar.collapsed .sidebar-brand span:last-child,
.sidebar.collapsed .nav-item span:last-child,
.sidebar.collapsed .sidebar-footer .nav-item span:last-child {
    display: none;
}

.sidebar.collapsed .sidebar-brand {
    justify-content: center;
    padding: 0;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 10px 0;
}

.sidebar.collapsed .nav-item .icon {
    width: auto;
    font-size: 20px;
}

.sidebar.collapsed .sidebar-footer {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: absolute;
    top: 24px;
    right: -14px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--gray-800);
    border: 2px solid var(--gray-700);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    z-index: 101;
    transition: transform 0.25s ease, background 0.2s;
    padding: 0;
    line-height: 1;
}

.sidebar-toggle:hover {
    background: var(--primary);
    border-color: var(--primary);
}

.sidebar.collapsed .sidebar-toggle {
    transform: rotate(180deg);
}

.sidebar-brand {
    font-size: 20px;
    font-weight: 700;
    padding: 0 12px;
    margin-bottom: 32px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand span {
    font-size: 28px;
}

.sidebar-nav {
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--gray-400);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
    margin-bottom: 2px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

.nav-item .icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--gray-700);
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px 32px;
    transition: margin-left 0.25s ease;
    min-width: 0;
}

/* Main content adjusts when sidebar is collapsed */
.sidebar.collapsed ~ .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* ===== Top Bar ===== */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.top-bar h2 {
    font-size: 24px;
    font-weight: 700;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
}

/* ===== Cards ===== */
.card {
    background: white;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
}

/* ===== Stats Grid ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-card .label {
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-card .value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
    margin-top: 4px;
}

.stat-card .icon-bg {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-bottom: 12px;
}

/* ===== Tables ===== */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--gray-200);
}

td {
    padding: 12px 16px;
    font-size: 14px;
    border-bottom: 1px solid var(--gray-100);
}

tr:hover td {
    background: var(--gray-50);
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.badge-free {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-bisnis {
    background: #fef3c7;
    color: #b45309;
}

.badge-active {
    background: #dcfce7;
    color: #15803d;
}

.badge-inactive {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-online {
    background: #dcfce7;
    color: #15803d;
}

.badge-offline {
    background: #f1f5f9;
    color: #64748b;
}

/* ===== Modal ===== */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: white;
    border-radius: var(--radius);
    padding: 32px;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}

.modal h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
}

.modal-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 20px;
}

/* ===== Toast ===== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
}

.toast {
    padding: 12px 20px;
    border-radius: 8px;
    color: white;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    animation: slideIn 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

.toast-info {
    background: var(--primary);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===== Loading ===== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== QR Code ===== */
.qr-container {
    text-align: center;
    padding: 20px;
}

.qr-container img {
    max-width: 250px;
    border-radius: 8px;
}

.qr-container p {
    margin-top: 12px;
    color: var(--gray-500);
    font-size: 14px;
}

/* ===== Chat View ===== */
.chat-list {
    max-height: 400px;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--gray-100);
}

.chat-item:hover {
    background: var(--gray-50);
}

.chat-item.active {
    background: var(--primary);
    color: white;
}

.chat-item.active .preview,
.chat-item.active .chat-time {
    color: rgba(255,255,255,0.8);
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
    flex-shrink: 0;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-info .name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-info .preview {
    font-size: 12px;
    color: var(--gray-500);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.chat-time {
    font-size: 11px;
    color: var(--gray-400);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Message Bubbles */
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.message-bubble {
    max-width: 75%;
    padding: 8px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
    position: relative;
}

.message-bubble.sent {
    align-self: flex-end;
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-bubble.received {
    align-self: flex-start;
    background: var(--gray-100);
    color: var(--gray-800);
    border-bottom-left-radius: 4px;
}

.bubble-text {
    white-space: pre-wrap;
}

.bubble-time {
    font-size: 10px;
    opacity: 0.7;
    text-align: right;
    margin-top: 4px;
}

/* Chat Input Area */
.chat-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-input-area .form-control {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--gray-200);
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}

.chat-input-area .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.1);
}

/* Empty state for messages */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--gray-400);
    text-align: center;
    padding: 40px;
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 14px;
}

/* ===== Mobile Back Button ===== */
.mobile-back-btn {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    color: var(--gray-600);
    transition: background 0.2s;
}

.mobile-back-btn:hover {
    background: var(--gray-100);
}

body.dark-mode .mobile-back-btn {
    color: var(--gray-400);
}

body.dark-mode .mobile-back-btn:hover {
    background: #334155;
}

/* ===== Mobile Hamburger ===== */
.mobile-sidebar-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    color: var(--gray-700);
    transition: background 0.2s;
}

.mobile-sidebar-toggle:hover {
    background: var(--gray-100);
}

body.dark-mode .mobile-sidebar-toggle {
    color: var(--gray-300);
}

body.dark-mode .mobile-sidebar-toggle:hover {
    background: #334155;
}

/* ===== Profile Grid ===== */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
}

.profile-grid .profile-item {
    padding: 8px 0;
}

.profile-grid .profile-item strong {
    display: block;
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.profile-grid .profile-item span {
    font-size: 14px;
    color: var(--gray-800);
}

body.dark-mode .profile-grid .profile-item strong {
    color: #94a3b8;
}

body.dark-mode .profile-grid .profile-item span {
    color: #e2e8f0;
}

/* ===== WA Status Card ===== */
.wa-status-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--gray-50);
    border-radius: 8px;
    margin-top: 16px;
}

.wa-status-icon {
    font-size: 32px;
    flex-shrink: 0;
}

.wa-status-text {
    font-weight: 600;
    font-size: 16px;
}

.wa-status-detail {
    font-size: 12px;
    color: var(--gray-500);
}

body.dark-mode .wa-status-card {
    background: #334155 !important;
}

/* ===== Form Row (side-by-side fields) ===== */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* ===== Mobile Overlay for Sidebar (tablet) ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* ===== Chat List/Messages Panel visibility (global) ===== */
.chat-list-panel.active {
    display: block;
}

.chat-list-panel.hidden {
    display: none;
}

.chat-messages-panel.active {
    display: flex;
    flex-direction: column;
}

.chat-messages-panel.hidden {
    display: none;
}

/* ===== Messages Layout (Chat List + Bubble UI) ===== */
.messages-layout {
    display: flex;
    gap: 16px;
    height: calc(100vh - 140px);
    min-height: 400px;
}

.chat-list-panel {
    width: 320px;
    flex-shrink: 0;
}

.chat-messages-panel {
    flex: 1;
    min-width: 0;
}

/* ===== QR Modal ===== */
.modal-qr {
    max-width: 400px;
    text-align: center;
}

.modal-qr .qr-container {
    padding: 10px;
}

.modal-qr .qr-container img {
    max-width: 280px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.modal-qr .qr-container p {
    margin-top: 12px;
    font-size: 14px;
    color: var(--gray-500);
}

/* ===== Dark Mode ===== */
body.dark-mode {
    background: #0f172a;
    color: #e2e8f0;
}

body.dark-mode .sidebar {
    background: #1e293b;
}

body.dark-mode .card,
body.dark-mode .stat-card,
body.dark-mode .modal {
    background: #1e293b;
    color: #e2e8f0;
}

body.dark-mode .card-header h3 {
    color: #e2e8f0;
}

body.dark-mode .form-group label {
    color: #94a3b8;
}

body.dark-mode .form-group input,
body.dark-mode .form-group select,
body.dark-mode .form-group textarea {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

body.dark-mode .form-group input:focus,
body.dark-mode .form-group select:focus,
body.dark-mode .form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

body.dark-mode .table-container table th {
    color: #94a3b8;
    border-bottom-color: #334155;
}

body.dark-mode .table-container table td {
    border-bottom-color: #1e293b;
    color: #cbd5e1;
}

body.dark-mode .table-container tr:hover td {
    background: #334155;
}

body.dark-mode .chat-item:hover {
    background: #334155;
}

body.dark-mode .chat-info .name {
    color: #e2e8f0;
}

body.dark-mode .chat-info .preview {
    color: #94a3b8;
}

body.dark-mode .chat-time {
    color: #64748b;
}

body.dark-mode .stat-card .value {
    color: #e2e8f0;
}

body.dark-mode .stat-card .label {
    color: #94a3b8;
}

body.dark-mode .top-bar h2 {
    color: #e2e8f0;
}

body.dark-mode #wa-status-card {
    background: #334155 !important;
}

body.dark-mode .btn-secondary {
    background: #334155;
    color: #e2e8f0;
}

body.dark-mode .btn-secondary:hover {
    background: #475569;
}

body.dark-mode .modal-overlay {
    background: rgba(0,0,0,0.7);
}

body.dark-mode .badge-offline {
    background: #334155;
    color: #94a3b8;
}

body.dark-mode .empty-state {
    color: #64748b;
}

body.dark-mode .copy-btn {
    background: #334155;
    border-color: #475569;
    color: #94a3b8;
}

body.dark-mode .copy-btn:hover {
    background: #475569;
    border-color: #64748b;
}

/* ===== Copy Button ===== */
.copy-btn {
    display: inline-block;
    margin-top: 8px;
    padding: 6px 14px;
    background: var(--gray-100);
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--gray-700);
}

.copy-btn:hover {
    background: var(--gray-200);
    border-color: var(--gray-400);
}

/* ===== Dark Mode Toggle ===== */

.dark-mode-toggle {
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--gray-100);
    border: none;
    font-size: 16px;
    transition: all 0.2s;
}

.dark-mode-toggle:hover {
    background: var(--gray-200);
}

body.dark-mode .dark-mode-toggle {
    background: #334155;
    color: #fbbf24;
}

body.dark-mode .dark-mode-toggle:hover {
    background: #475569;
}

/* ===== Login Page Dark Mode ===== */
body.dark-mode .login-card {
    background: #1e293b;
}

body.dark-mode .login-card h1 {
    color: #e2e8f0;
}

body.dark-mode .login-card p {
    color: #94a3b8;
}

/* ===== Messages Dark Mode ===== */
body.dark-mode #chat-messages > div {
    background: #334155 !important;
    color: #e2e8f0;
}

body.dark-mode #chat-messages > div[style*="margin-left"] {
    background: #1e3a5f !important;
}

body.dark-mode .message-bubble.received {
    background: #334155;
    color: #e2e8f0;
}

body.dark-mode .message-bubble.sent {
    background: #4f46e5;
}

body.dark-mode .chat-item {
    border-bottom-color: #1e293b;
}

body.dark-mode .chat-item:hover {
    background: #1e293b;
}

body.dark-mode .chat-item.active {
    background: var(--primary);
}

body.dark-mode .chat-input-area .form-control {
    background: #334155;
    border-color: #475569;
    color: #e2e8f0;
}

body.dark-mode .chat-input-area .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

body.dark-mode ::-webkit-scrollbar-thumb {
    background: #475569;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.page {
    animation: fadeIn 0.3s ease;
}

/* ================================================================
   MOBILE — NATIVE ANDROID APP STYLE (Material Design 3 Inspired)
   ================================================================ */

/* === Small phones: < 480px — True Android App Experience === */
@media (max-width: 480px) {
    /* ---- Android Status Bar Simulation ---- */
    body {
        background: #f3f4f6;
        font-family: 'Inter', 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
        -webkit-font-smoothing: antialiased;
    }

    /* ---- Login Page — Full Screen Android Style ---- */
    .login-page {
        padding: 0;
        min-height: 100vh;
        display: flex;
        align-items: center;
        justify-content: center;
        background: linear-gradient(160deg, #6366f1 0%, #4f46e5 40%, #06b6d4 100%);
    }
    .login-card {
        padding: 32px 24px;
        max-width: 100%;
        width: 100%;
        margin: 24px;
        border-radius: 28px;
        background: rgba(255,255,255,0.98);
        box-shadow: 0 20px 60px rgba(0,0,0,0.15);
        border: none;
    }
    body.dark-mode .login-card {
        background: rgba(30,41,59,0.98);
    }
    .login-card h1 {
        font-size: 26px;
        font-weight: 800;
        letter-spacing: -0.5px;
    }
    .login-card .logo span {
        font-size: 56px;
    }
    .login-card .logo {
        margin-bottom: 24px;
    }

    /* ---- Dashboard — Full Screen Android App ---- */
    .dashboard {
        flex-direction: column;
        padding-bottom: 0;
        min-height: 100vh;
        background: #f3f4f6;
    }
    body.dark-mode .dashboard {
        background: #0f172a;
    }

    /* ---- Android Bottom Navigation Bar ---- */
    .sidebar {
        position: fixed;
        bottom: 0;
        top: auto;
        left: 0;
        right: 0;
        width: 100%;
        height: calc(64px + var(--safe-bottom));
        padding: 4px 0;
        padding-bottom: var(--safe-bottom);
        flex-direction: row;
        align-items: center;
        justify-content: space-around;
        z-index: 999;
        background: rgba(255,255,255,0.96);
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
        border-top: none;
        box-shadow: 0 -2px 24px rgba(0,0,0,0.08);
        transform: none;
        border-radius: 0;
    }
    body.dark-mode .sidebar {
        background: rgba(15,23,42,0.96);
        box-shadow: 0 -2px 24px rgba(0,0,0,0.3);
    }

    .sidebar.collapsed {
        width: 100%;
        padding: 4px 0;
        padding-bottom: var(--safe-bottom);
    }

    .sidebar-toggle {
        display: none !important;
    }

    .sidebar-brand {
        display: none;
    }

    .sidebar-nav {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-around;
        flex: 1;
        gap: 0;
        padding: 0 4px;
    }

    .nav-item {
        flex-direction: column;
        gap: 1px;
        padding: 6px 2px;
        font-size: 10px;
        margin-bottom: 0;
        min-width: 0;
        flex: 1;
        justify-content: center;
        align-items: center;
        border-radius: 16px;
        transition: all 0.2s ease;
        position: relative;
        color: var(--gray-400);
    }

    .nav-item .icon {
        font-size: 22px;
        width: auto;
        transition: transform 0.2s ease;
        line-height: 1;
    }

    .nav-item.active .icon {
        transform: scale(1.1);
    }

    .nav-item span:last-child {
        display: block;
        font-size: 10px;
        font-weight: 500;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
        letter-spacing: 0px;
        color: var(--gray-400);
    }

    .nav-item.active {
        background: rgba(99,102,241,0.12);
    }
    .nav-item.active .icon {
        color: var(--primary);
    }
    .nav-item.active span:last-child {
        color: var(--primary);
        font-weight: 600;
    }
    body.dark-mode .nav-item.active {
        background: rgba(99,102,241,0.18);
    }

    .sidebar.collapsed .nav-item span:last-child {
        display: block;
    }

    .sidebar-footer {
        display: none;
    }

    .sidebar-nav .btn-logout {
        display: flex;
    }

    /* ---- Main Content — Android App Body ---- */
    .main-content {
        margin-left: 0;
        padding: 8px 12px;
        padding-bottom: calc(72px + var(--safe-bottom));
        padding-top: 4px;
    }

    .sidebar.collapsed ~ .main-content {
        margin-left: 0;
    }

    /* ---- Android Top App Bar ---- */
    .top-bar {
        flex-direction: row;
        align-items: center;
        gap: 4px;
        margin-bottom: 12px;
        padding: 8px 4px;
        min-height: 48px;
    }
    .top-bar h2 {
        font-size: 20px;
        font-weight: 700;
        flex: 1;
        letter-spacing: -0.3px;
    }
    .user-info {
        gap: 4px;
    }
    .user-info span {
        display: none;
    }
    .user-avatar {
        width: 30px;
        height: 30px;
        font-size: 12px;
        border-radius: 50%;
    }
    .dark-mode-toggle {
        padding: 4px 8px;
        font-size: 18px;
        border-radius: 10px;
        background: transparent;
    }
    body.dark-mode .dark-mode-toggle {
        background: transparent;
    }

    .mobile-sidebar-toggle {
        display: inline-flex;
        font-size: 22px;
        padding: 4px 6px;
    }

    /* ---- Android Stats Cards ---- */
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        margin-bottom: 16px;
    }
    .stat-card {
        padding: 16px 14px;
        border-radius: 20px;
        background: white;
        box-shadow: 0 2px 16px rgba(0,0,0,0.04);
        border: 1px solid rgba(0,0,0,0.03);
    }
    body.dark-mode .stat-card {
        background: #1e293b;
        border-color: rgba(255,255,255,0.04);
    }
    .stat-card .value {
        font-size: 24px;
        font-weight: 800;
        letter-spacing: -0.5px;
    }
    .stat-card .icon-bg {
        width: 40px;
        height: 40px;
        font-size: 20px;
        margin-bottom: 10px;
        border-radius: 14px;
    }
    .stat-card .label {
        font-size: 11px;
        font-weight: 600;
        color: var(--gray-500);
        text-transform: uppercase;
        letter-spacing: 0.8px;
    }

    /* ---- Android Cards ---- */
    .card {
        padding: 16px;
        border-radius: 20px;
        background: white;
        box-shadow: 0 2px 16px rgba(0,0,0,0.04);
        border: 1px solid rgba(0,0,0,0.03);
        margin-bottom: 12px;
    }
    body.dark-mode .card {
        background: #1e293b;
        border-color: rgba(255,255,255,0.04);
    }
    .card-header {
        flex-direction: row;
        gap: 8px;
        align-items: center;
        margin-bottom: 12px;
    }
    .card-header h3 {
        font-size: 16px;
        font-weight: 700;
        flex: 1;
    }

    /* ---- Android Table Cards ---- */
    .table-container table,
    .table-container thead,
    .table-container tbody,
    .table-container th,
    .table-container td,
    .table-container tr {
        display: block;
    }
    .table-container thead {
        display: none;
    }
    .table-container tr {
        margin-bottom: 10px;
        border: none;
        border-radius: 16px;
        padding: 14px;
        background: var(--gray-50);
        box-shadow: none;
    }
    body.dark-mode .table-container tr {
        background: #0f172a;
    }
    .table-container td {
        padding: 4px 0;
        border: none;
        font-size: 13px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    .table-container td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--gray-500);
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-right: 8px;
        flex-shrink: 0;
    }
    .table-container tr:hover td {
        background: transparent;
    }

    /* ---- Android Bottom Sheet Modals ---- */
    .modal-overlay {
        align-items: flex-end;
        background: rgba(0,0,0,0.5);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
    .modal-overlay.active {
        align-items: flex-end;
    }
    .modal {
        margin: 0;
        padding: 28px 20px;
        padding-bottom: calc(28px + var(--safe-bottom));
        max-width: 100%;
        max-height: 85vh;
        border-radius: 28px 28px 0 0;
        animation: androidSheetUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
        background: white;
        box-shadow: 0 -8px 40px rgba(0,0,0,0.12);
        border: none;
    }
    body.dark-mode .modal {
        background: #1e293b;
    }
    .modal h3 {
        font-size: 20px;
        font-weight: 700;
        margin-bottom: 20px;
        letter-spacing: -0.3px;
    }
    .modal-qr {
        max-width: 100%;
    }
    .modal-actions {
        flex-direction: column;
        gap: 10px;
        margin-top: 24px;
    }
    .modal-actions .btn {
        width: 100%;
        padding: 16px;
        border-radius: 14px;
        font-size: 16px;
        font-weight: 600;
    }

    @keyframes androidSheetUp {
        from {
            transform: translateY(100%);
            opacity: 0;
        }
        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    /* ---- Android Messages Layout ---- */
    .messages-layout {
        flex-direction: column;
        height: auto;
        gap: 0;
    }
    .chat-list-panel {
        width: 100%;
        max-height: 180px;
        border-radius: 20px;
        overflow: hidden;
    }
    .chat-messages-panel {
        height: calc(100vh - 320px);
        min-height: 300px;
        border-radius: 20px;
        overflow: hidden;
    }
    .message-bubble {
        max-width: 88%;
        font-size: 14px;
        padding: 10px 16px;
        border-radius: 20px;
        line-height: 1.5;
    }
    .message-bubble.sent {
        border-bottom-right-radius: 4px;
        background: var(--primary);
    }
    .message-bubble.received {
        border-bottom-left-radius: 4px;
        background: var(--gray-100);
    }
    body.dark-mode .message-bubble.received {
        background: #334155;
    }
    .chat-item {
        padding: 12px 14px;
        border-radius: 14px;
        margin: 2px 0;
        border-bottom: none;
    }
    .chat-avatar {
        width: 40px;
        height: 40px;
        font-size: 16px;
        border-radius: 14px;
    }
    .chat-info .name {
        font-size: 14px;
        font-weight: 600;
    }
    .chat-info .preview {
        font-size: 12px;
    }
    .chat-time {
        font-size: 10px;
    }

    /* ---- Android Toast ---- */
    .toast-container {
        top: 16px;
        right: 16px;
        left: 16px;
    }
    .toast {
        font-size: 14px;
        padding: 14px 20px;
        border-radius: 16px;
        box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    }

    /* ---- Android QR Modal ---- */
    .qr-container img {
        max-width: 240px;
        border-radius: 16px;
    }
    .qr-container {
        padding: 16px;
    }

    /* ---- Android Profile Grid ---- */
    .profile-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .profile-grid .profile-item {
        padding: 12px 14px;
        background: var(--gray-50);
        border-radius: 14px;
        font-size: 13px;
    }
    body.dark-mode .profile-grid .profile-item {
        background: #0f172a;
    }

    /* ---- Android Form Row ---- */
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    /* ---- Android WA Status Card ---- */
    .wa-status-card {
        flex-direction: column;
        text-align: center;
        padding: 24px 20px;
        border-radius: 20px;
        gap: 12px;
        background: var(--gray-50) !important;
    }
    body.dark-mode .wa-status-card {
        background: #0f172a !important;
    }
    .wa-status-card > .wa-status-icon {
        font-size: 48px !important;
    }

    /* ---- Android AI Config ---- */
    #form-ai-config .form-group textarea {
        min-height: 80px;
        border-radius: 14px;
    }
    #form-ai-config .form-group label {
        font-size: 14px;
        font-weight: 600;
    }

    /* ---- Android Settings ---- */
    #form-settings .form-group {
        margin-bottom: 16px;
    }
    #form-settings .form-group label {
        font-size: 14px;
        font-weight: 600;
    }

    /* ---- Android Chat Panel Toggle ---- */
    .chat-list-panel.active {
        display: block;
    }
    .chat-list-panel.hidden {
        display: none;
    }
    .chat-messages-panel.active {
        display: flex;
        flex-direction: column;
    }
    .chat-messages-panel.hidden {
        display: none;
    }

    /* ---- Android Mobile Back Button ---- */
    .mobile-back-btn {
        display: inline-flex;
        padding: 8px 12px;
        border-radius: 12px;
        background: var(--gray-100);
        font-size: 14px;
        font-weight: 600;
        gap: 4px;
        align-items: center;
    }
    body.dark-mode .mobile-back-btn {
        background: #334155;
        color: #e2e8f0;
    }

    /* ---- Android License Result ---- */
    #license-result code {
        font-size: 12px;
        word-break: break-all;
        padding: 12px;
        border-radius: 12px;
        display: block;
        background: var(--gray-50);
    }
    body.dark-mode #license-result code {
        background: #0f172a;
    }

    /* ---- Android Form Controls ---- */
    .form-group input,
    .form-group select,
    .form-group textarea {
        border-radius: 14px;
        padding: 14px 16px;
        font-size: 15px;
        border: 1.5px solid var(--gray-200);
        background: var(--gray-50);
    }
    body.dark-mode .form-group input,
    body.dark-mode .form-group select,
    body.dark-mode .form-group textarea {
        background: #0f172a;
        border-color: #334155;
    }
    .form-group {
        margin-bottom: 16px;
    }
    .form-group label {
        font-size: 13px;
        font-weight: 600;
        margin-bottom: 6px;
        display: block;
        color: var(--gray-600);
    }

    /* ---- Android Buttons ---- */
    .btn {
        padding: 14px 24px;
        border-radius: 14px;
        font-size: 15px;
        font-weight: 600;
        letter-spacing: 0.2px;
    }
    .btn-sm {
        padding: 10px 16px;
        font-size: 13px;
        border-radius: 12px;
    }
    .btn-primary {
        background: var(--primary);
        box-shadow: 0 4px 14px rgba(99,102,241,0.3);
    }
    .btn-primary:hover {
        transform: none;
        box-shadow: 0 6px 20px rgba(99,102,241,0.4);
    }
    .btn-danger {
        box-shadow: 0 4px 14px rgba(239,68,68,0.3);
    }

    /* ---- Android Badges ---- */
    .badge {
        padding: 4px 12px;
        font-size: 11px;
        border-radius: 20px;
        font-weight: 600;
    }

    /* ---- Android Empty State ---- */
    .empty-state {
        padding: 48px 20px;
    }
    .empty-state .icon {
        font-size: 56px;
    }
    .empty-state p {
        font-size: 14px;
        color: var(--gray-400);
    }

    /* ---- Android Spinner ---- */
    .spinner {
        width: 40px;
        height: 40px;
        border-width: 3px;
    }

    /* ---- Android Chat Input ---- */
    .chat-input-area {
        padding: 10px 14px !important;
        gap: 8px;
        border-top: 1px solid var(--gray-100) !important;
    }
    body.dark-mode .chat-input-area {
        border-top-color: #334155 !important;
    }
    .chat-input-area .form-control {
        border-radius: 24px;
        padding: 12px 18px;
        font-size: 15px;
        border: 1.5px solid var(--gray-200);
        background: var(--gray-50);
    }
    body.dark-mode .chat-input-area .form-control {
        background: #0f172a;
        border-color: #334155;
    }
    .chat-input-area .btn {
        border-radius: 24px;
        padding: 12px 20px;
        font-size: 14px;
        min-width: 64px;
    }

    /* ---- Android WA Status Card inside card ---- */
    #wa-status-card {
        border-radius: 20px;
        padding: 24px !important;
    }

    /* ---- Android Chat Header ---- */
    #chat-header {
        padding: 8px 4px;
    }
    #chat-header h3 {
        font-size: 16px;
        font-weight: 700;
    }

    /* ---- Android Page Animation ---- */
    .page {
        animation: androidFadeIn 0.35s ease;
    }

    @keyframes androidFadeIn {
        from {
            opacity: 0;
            transform: translateY(8px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* ---- Android Scrollbar ---- */
    ::-webkit-scrollbar {
        width: 3px;
    }
    ::-webkit-scrollbar-thumb {
        background: var(--gray-300);
        border-radius: 2px;
    }
    body.dark-mode ::-webkit-scrollbar-thumb {
        background: #475569;
    }
}

/* === Tablets: 481px - 768px — Modern Adaptive Layout === */
@media (min-width: 481px) and (max-width: 768px) {
    .login-page {
        padding: 24px;
    }
    .login-card {
        padding: 36px;
        border-radius: 24px;
        background: rgba(255,255,255,0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        box-shadow: 0 8px 32px rgba(0,0,0,0.08);
    }
    body.dark-mode .login-card {
        background: rgba(30,41,59,0.95);
    }

    .sidebar {
        width: var(--sidebar-collapsed-width);
        padding: 20px 8px;
        background: rgba(255,255,255,0.9);
        backdrop-filter: blur(16px);
        -webkit-backdrop-filter: blur(16px);
    }
    body.dark-mode .sidebar {
        background: rgba(15,23,42,0.9);
    }
    .sidebar-brand span:last-child,
    .nav-item span:last-child {
        display: none;
    }
    .sidebar.collapsed .nav-item span:last-child {
        display: none;
    }
    .sidebar-brand {
        justify-content: center;
        padding: 0;
    }
    .nav-item {
        justify-content: center;
        padding: 10px 0;
        border-radius: 12px;
    }
    .nav-item.active {
        background: rgba(99,102,241,0.1);
    }
    body.dark-mode .nav-item.active {
        background: rgba(99,102,241,0.15);
    }
    .nav-item .icon {
        width: auto;
        font-size: 20px;
    }
    .sidebar-footer {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    .sidebar-toggle {
        display: flex;
    }

    /* Mobile-open overlay mode for tablet */
    .sidebar.mobile-open {
        width: var(--sidebar-width);
        padding: 24px;
        z-index: 1000;
        box-shadow: 4px 0 30px rgba(0,0,0,0.15);
        border-radius: 0 20px 20px 0;
    }
    .sidebar.mobile-open .sidebar-brand span:last-child,
    .sidebar.mobile-open .nav-item span:last-child {
        display: inline;
    }
    .sidebar.mobile-open .sidebar-brand {
        justify-content: flex-start;
        padding: 0 12px;
    }
    .sidebar.mobile-open .nav-item {
        justify-content: flex-start;
        padding: 12px 14px;
        border-radius: 12px;
    }
    .sidebar.mobile-open .nav-item .icon {
        width: 24px;
        font-size: 18px;
    }
    .sidebar.mobile-open .sidebar-footer {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.4);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        z-index: 999;
    }
    .sidebar-overlay.active {
        display: block;
    }

    .main-content {
        margin-left: var(--sidebar-collapsed-width);
        padding: 20px 24px;
    }
    .sidebar.collapsed ~ .main-content {
        margin-left: var(--sidebar-collapsed-width);
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 14px;
    }
    .stat-card {
        padding: 20px;
        border-radius: 18px;
        box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    }
    .stat-card .value {
        font-size: 24px;
    }

    .card {
        padding: 20px;
        border-radius: 18px;
        box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    }

    .modal {
        margin: 24px;
        padding: 28px;
        border-radius: 24px;
    }

    .top-bar h2 {
        font-size: 20px;
    }

    .messages-layout {
        flex-direction: column;
        height: auto;
        gap: 12px;
    }
    .chat-list-panel {
        width: 100%;
        max-height: 220px;
        border-radius: 16px;
    }
    .chat-messages-panel {
        height: calc(100vh - 400px);
        min-height: 350px;
        border-radius: 16px;
    }
    .message-bubble {
        max-width: 80%;
        border-radius: 18px;
    }

    /* Profile grid */
    .profile-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    /* Form row */
    .form-row {
        grid-template-columns: 1fr;
    }

    /* Buttons */
    .btn {
        border-radius: 12px;
    }
}

/* === Desktop: > 768px — keep existing styles, just minor polish === */
@media (min-width: 769px) {
    .sidebar-footer .btn-logout {
        display: flex;
    }
    .sidebar-nav .btn-logout {
        display: none;
    }
}
