/* ═══════════════════════════════════════════════════
   WA AUTO — Admin Dashboard Styles
   ═══════════════════════════════════════════════════ */

:root {
    --bg-primary: #0a0f1a;
    --bg-secondary: #111827;
    --bg-card: #1a2236;
    --bg-card-hover: #1f2a40;
    --bg-input: #0d1321;
    --border: #2a3650;
    --border-focus: #25d366;

    --text-primary: #f0f4f8;
    --text-secondary: #8b9dc3;
    --text-muted: #5a6f8c;

    --green: #25d366;
    --green-glow: rgba(37, 211, 102, 0.15);
    --green-dark: #1da851;
    --blue: #3b82f6;
    --blue-glow: rgba(59, 130, 246, 0.15);
    --purple: #a855f7;
    --purple-glow: rgba(168, 85, 247, 0.15);
    --orange: #f97316;
    --orange-glow: rgba(249, 115, 22, 0.15);
    --red: #ef4444;
    --red-glow: rgba(239, 68, 68, 0.15);

    --sidebar-width: 260px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ═══════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════ */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform var(--transition);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--green), var(--green-dark));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}
.logo-icon svg { width: 22px; height: 22px; }

.logo-text {
    font-size: 1.3rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--green), #4ade80);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.5px;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
}
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-card); color: var(--text-primary); }
.nav-item.active {
    background: var(--green-glow);
    color: var(--green);
    font-weight: 600;
}
.nav-item.active svg { stroke: var(--green); }

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.status-dot.online {
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
    animation: pulse-dot 2s infinite;
}
.status-dot.offline {
    background: var(--red);
    box-shadow: 0 0 8px rgba(239,68,68,0.4);
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ─── Mobile Header ─── */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 99;
}

.hamburger {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 8px;
}
.hamburger span {
    width: 22px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
}

.mobile-logo {
    font-weight: 800;
    font-size: 1.1rem;
    color: var(--green);
}

.connection-badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--red-glow);
    color: var(--red);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.connection-badge.online {
    background: var(--green-glow);
    color: var(--green);
}

/* ═══════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════ */

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 32px;
    max-width: 1200px;
}

.page-header {
    margin-bottom: 28px;
}
.page-header h1 {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}
.page-subtitle {
    color: var(--text-secondary);
    margin-top: 4px;
    font-size: 0.95rem;
}

/* ─── Tab Content ─── */
.tab-content { display: none; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }

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

/* ═══════════════════════════════════════════════════
   STAT CARDS
   ═══════════════════════════════════════════════════ */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }

.stat-green .stat-icon { background: var(--green-glow); color: var(--green); }
.stat-green .stat-icon svg { stroke: var(--green); }
.stat-blue .stat-icon { background: var(--blue-glow); color: var(--blue); }
.stat-blue .stat-icon svg { stroke: var(--blue); }
.stat-purple .stat-icon { background: var(--purple-glow); color: var(--purple); }
.stat-purple .stat-icon svg { stroke: var(--purple); }
.stat-orange .stat-icon { background: var(--orange-glow); color: var(--orange); }
.stat-orange .stat-icon svg { stroke: var(--orange); }

.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 1.6rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: 0.8rem; color: var(--text-secondary); margin-top: 4px; }

/* ═══════════════════════════════════════════════════
   CARDS
   ═══════════════════════════════════════════════════ */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.card-header h2 { font-size: 1rem; font-weight: 700; }

.card-body { padding: 20px; }

/* ─── QR Card ─── */
.qr-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    gap: 16px;
    color: var(--text-secondary);
}

.qr-connected {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: var(--green-glow);
    border-radius: var(--radius-sm);
}

.qr-connected-icon {
    width: 56px;
    height: 56px;
    background: var(--green);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 28px;
    flex-shrink: 0;
}

.qr-connected-text h3 { color: var(--green); font-size: 1.1rem; }
.qr-connected-text p { color: var(--text-secondary); font-size: 0.9rem; margin-top: 2px; }

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════
   FORMS
   ═══════════════════════════════════════════════════ */

.form-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

input[type="text"],
input[type="password"],
textarea,
select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    transition: border-color var(--transition);
    outline: none;
    width: 100%;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 3px var(--green-glow);
}

.form-hint {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    font-family: 'Inter', sans-serif;
}

.btn-primary {
    background: linear-gradient(135deg, var(--green), var(--green-dark));
    color: white;
    box-shadow: 0 2px 12px var(--green-glow);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(37,211,102,0.3); }

.btn-ghost {
    background: transparent;
    color: var(--green);
    border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--green-glow); }

.btn-danger {
    background: var(--red-glow);
    color: var(--red);
    border: 1px solid transparent;
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }

.btn-sm { padding: 6px 12px; font-size: 0.78rem; }

/* ═══════════════════════════════════════════════════
   TABLES
   ═══════════════════════════════════════════════════ */

.table-wrapper { overflow-x: auto; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid rgba(42, 54, 80, 0.5);
    vertical-align: top;
}
tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--bg-card-hover); }

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: 0.9rem;
}

/* ─── Tag badges ─── */
.tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.tag-keyword { background: var(--purple-glow); color: var(--purple); }
.tag-ai { background: var(--orange-glow); color: var(--orange); }
.tag-no-reply { background: rgba(100,116,139,0.15); color: #94a3b8; }

/* ═══════════════════════════════════════════════════
   UPLOAD ZONE
   ═══════════════════════════════════════════════════ */

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 48px 20px;
    text-align: center;
    color: var(--text-secondary);
    transition: all var(--transition);
    cursor: pointer;
}
.upload-zone:hover, .upload-zone.dragover {
    border-color: var(--green);
    background: var(--green-glow);
}
.upload-zone svg { color: var(--text-muted); margin-bottom: 12px; }
.upload-zone p { font-size: 0.95rem; }
.upload-link { color: var(--green); font-weight: 600; cursor: pointer; text-decoration: underline; }
.upload-hint { display: block; margin-top: 8px; font-size: 0.8rem; color: var(--text-muted); }

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.media-item {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: all var(--transition);
}
.media-item:hover { border-color: var(--green); }

.media-item-icon {
    font-size: 2rem;
    text-align: center;
}

.media-item-name {
    font-size: 0.82rem;
    font-weight: 600;
    word-break: break-all;
    text-align: center;
}

.media-item-size {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

.media-item-path {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 6px 8px;
    border-radius: 4px;
    word-break: break-all;
    font-family: monospace;
    cursor: pointer;
    transition: background var(--transition);
}
.media-item-path:hover { background: var(--green-glow); }

/* ─── AI Status ─── */
.ai-status {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
}
.ai-status.connected { background: var(--green-glow); color: var(--green); }
.ai-status.disconnected { background: var(--red-glow); color: var(--red); }

/* ─── Toast ─── */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    color: var(--text-primary);
    font-size: 0.88rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    z-index: 1000;
    animation: slideInToast 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}
.toast.success { border-left: 4px solid var(--green); }
.toast.error { border-left: 4px solid var(--red); }

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

/* ─── Radio Labels ─── */
.radio-label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.85rem;
}
.radio-label:hover { border-color: var(--green); }
.radio-label input[type="radio"] {
    accent-color: var(--green);
    margin-top: 3px;
    flex-shrink: 0;
}
.radio-label span { line-height: 1.4; color: var(--text-secondary); }
.radio-label strong { color: var(--text-primary); }

/* ─── Bot Toggle ─── */
.btn-bot-on {
    background: linear-gradient(135deg, var(--green), var(--green-dark)) !important;
    color: white !important;
    border: none !important;
    box-shadow: 0 2px 12px var(--green-glow);
}
.card-bot-on {
    border-color: var(--green) !important;
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════ */

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .mobile-header { display: flex; }
    .main-content {
        margin-left: 0;
        padding: 80px 16px 24px;
    }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 1.2rem; }
    .page-header h1 { font-size: 1.4rem; }
}

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