/* ==============================================
   AGLore — Premium Dark Theme
   Design System with Glassmorphism & Micro-animations
   ============================================== */

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
    /* Colors */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: rgba(17, 24, 39, 0.8);
    --bg-card-hover: rgba(31, 41, 55, 0.9);
    --bg-glass: rgba(255, 255, 255, 0.03);
    --bg-glass-border: rgba(255, 255, 255, 0.08);
    --bg-input: rgba(17, 24, 39, 0.6);

    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --text-accent: #a78bfa;

    --accent-primary: #8b5cf6;
    --accent-primary-hover: #7c3aed;
    --accent-secondary: #06b6d4;
    --accent-gradient: linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%);
    --accent-gradient-hover: linear-gradient(135deg, #7c3aed 0%, #0891b2 100%);

    --status-pending: #f59e0b;
    --status-pending-bg: rgba(245, 158, 11, 0.1);
    --status-confirmed: #10b981;
    --status-confirmed-bg: rgba(16, 185, 129, 0.1);
    --status-cancelled: #ef4444;
    --status-cancelled-bg: rgba(239, 68, 68, 0.1);
    --status-info: #3b82f6;
    --status-info-bg: rgba(59, 130, 246, 0.1);

    --border-color: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(139, 92, 246, 0.15);

    /* Spacing */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

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

/* Background pattern */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 20% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(6, 182, 212, 0.06) 0%, transparent 50%),
        radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.03) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

a { color: var(--accent-primary); text-decoration: none; }
a:hover { color: var(--accent-primary-hover); }

/* --- Login Screen --- */
.login-screen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    background: var(--bg-primary);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--bg-glass-border);
    border-radius: var(--radius-xl);
    padding: 3rem 2.5rem;
    width: 100%;
    max-width: 420px;
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    animation: fadeInUp 0.6s var(--transition-slow);
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.logo-icon {
    font-size: 3rem;
    margin-bottom: 0.5rem;
    animation: float 3s ease-in-out infinite;
}

.login-logo h1 {
    font-size: 2rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-logo p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.input-text, .input-select, .input-number, .input-textarea,
input[type="email"], input[type="password"], input[type="text"],
input[type="url"], input[type="number"], textarea, select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all var(--transition-fast);
    outline: none;
}

.input-text:focus, .input-select:focus, .input-number:focus, .input-textarea:focus,
input:focus, textarea:focus, select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.input-textarea, textarea {
    resize: vertical;
    min-height: 100px;
}

.form-hint {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.form-inline {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.form-inline label {
    margin-bottom: 0;
    white-space: nowrap;
}

.form-inline input {
    width: 100px;
}

.error-msg {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: var(--status-cancelled-bg);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-sm);
    color: var(--status-cancelled);
    font-size: 0.85rem;
    text-align: center;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.65rem 1.25rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    background: var(--accent-gradient-hover);
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-glass);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--border-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
}

.btn-ghost:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

.btn-full { width: 100%; }

/* --- Layout --- */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

/* --- Sidebar --- */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: width var(--transition-slow);
    backdrop-filter: blur(20px);
}

.sidebar-header {
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-emoji {
    font-size: 1.5rem;
}

.logo-text {
    font-size: 1.3rem;
    font-weight: 800;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: none;
}

.sidebar-toggle:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all var(--transition-fast);
    position: relative;
}

.nav-item:hover {
    background: var(--bg-glass);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(139, 92, 246, 0.12);
    color: var(--accent-primary);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: -0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: var(--accent-primary);
    border-radius: 0 4px 4px 0;
}

.nav-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.user-avatar {
    font-size: 1.2rem;
}

.user-email {
    font-size: 0.8rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    min-height: 100vh;
    transition: margin-left var(--transition-slow);
}

/* --- Pages --- */
.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active { display: block; }

.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

/* --- Stats Grid --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all var(--transition-base);
    backdrop-filter: blur(10px);
}

.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-today { border-left: 3px solid var(--status-info); }
.stat-pending { border-left: 3px solid var(--status-pending); }
.stat-confirmed { border-left: 3px solid var(--status-confirmed); }
.stat-cancelled { border-left: 3px solid var(--status-cancelled); }

.stat-icon {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    background: var(--bg-glass);
}

.stat-value {
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.25rem;
}

/* --- Cards --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 1.5rem;
    backdrop-filter: blur(10px);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

/* --- Tables --- */
.table-container {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

tbody td {
    padding: 0.75rem 1rem;
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

tbody tr {
    transition: background var(--transition-fast);
}

tbody tr:hover {
    background: var(--bg-glass);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* --- Status Badges --- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-pending {
    background: var(--status-pending-bg);
    color: var(--status-pending);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-confirmed {
    background: var(--status-confirmed-bg);
    color: var(--status-confirmed);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-cancelled {
    background: var(--status-cancelled-bg);
    color: var(--status-cancelled);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-info {
    background: var(--status-info-bg);
    color: var(--status-info);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

/* --- Sync Controls --- */
.sync-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    margin-top: 1rem;
}

.sync-results {
    margin-top: 1.5rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
}

.sync-results h4 {
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}

.sync-results ul {
    list-style: none;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.sync-results ul li {
    padding: 0.25rem 0;
}

.sync-results ul li::before {
    content: '→ ';
    color: var(--text-muted);
}

/* --- Settings --- */
.settings-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.integration-health {
    padding: 1rem 1.5rem;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.health-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.health-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.health-dot.ok { background: var(--status-confirmed); box-shadow: 0 0 6px var(--status-confirmed); }
.health-dot.error { background: var(--status-cancelled); box-shadow: 0 0 6px var(--status-cancelled); }

/* --- Info Box --- */
.info-box {
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.info-box h3 {
    margin-bottom: 0.75rem;
    font-size: 1rem;
}

.info-box p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.info-box pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin-bottom: 0.75rem;
}

.info-box code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    color: var(--accent-secondary);
}

.info-box ul {
    padding-left: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.info-box ul li {
    margin-bottom: 0.3rem;
}

.info-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

.info-text code {
    background: rgba(139, 92, 246, 0.15);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    color: var(--accent-primary);
}

/* --- Empty State --- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem;
}

.pagination button {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border-color);
    background: var(--bg-glass);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all var(--transition-fast);
}

.pagination button:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.pagination button.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

/* --- Toast Notifications --- */
.toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    min-width: 300px;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideInRight 0.4s var(--transition-slow);
}

.toast.toast-success { border-left: 3px solid var(--status-confirmed); }
.toast.toast-error { border-left: 3px solid var(--status-cancelled); }
.toast.toast-info { border-left: 3px solid var(--status-info); }
.toast.toast-warning { border-left: 3px solid var(--status-pending); }

.toast-icon { font-size: 1.2rem; }
.toast-message {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.toast.removing {
    animation: slideOutRight 0.3s ease forwards;
}

/* --- Utility --- */
.hidden { display: none !important; }

.filters-row {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideOutRight {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(100px); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .main-content {
        padding: 1.5rem;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: var(--sidebar-collapsed);
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
        width: var(--sidebar-width);
    }

    .sidebar-toggle {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
    }

    .nav-label,
    .logo-text,
    .user-email {
        display: none;
    }

    .sidebar.open .nav-label,
    .sidebar.open .logo-text,
    .sidebar.open .user-email {
        display: inline;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .sync-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .settings-actions {
        flex-direction: column;
    }

    .filters-row {
        flex-direction: column;
        width: 100%;
    }

    .card-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Selection --- */
::selection {
    background: rgba(139, 92, 246, 0.3);
    color: var(--text-primary);
}

/* WhatsApp Settings */
.whatsapp-status-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.status-text {
    font-weight: 500;
}

.qrcode-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem;
    background-color: var(--bg-color);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.qrcode-image {
    max-width: 300px;
    width: 100%;
    height: auto;
    border: 10px solid white;
    border-radius: 8px;
    background: white;
}

.whatsapp-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background-color: rgba(34, 197, 94, 0.1); color: rgb(21, 128, 61); }
.badge-warning { background-color: rgba(234, 179, 8, 0.1); color: rgb(161, 98, 7); }
.badge-error { background-color: rgba(239, 68, 68, 0.1); color: rgb(185, 28, 28); }
.badge-info { background-color: rgba(59, 130, 246, 0.1); color: rgb(29, 78, 216); }

.mt-4 { margin-top: 1rem; }
