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

:root {
    --primary: #1a73e8;
    --primary-dark: #1558b0;
    --primary-light: #e8f0fe;
    --danger: #dc3545;
    --danger-light: #f8d7da;
    --success: #28a745;
    --success-light: #d4edda;
    --warning: #f59e0b;
    --warning-light: #fff3cd;
    --info: #0dcaf0;
    --info-light: #d1ecf1;
    --gray-50: #f8f9fa;
    --gray-100: #e9ecef;
    --gray-200: #dee2e6;
    --gray-400: #adb5bd;
    --gray-600: #6c757d;
    --gray-800: #343a40;
    --gray-900: #212529;
    --white: #ffffff;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --transition: 0.15s ease;
}

body {
    font-family: var(--font);
    background: var(--gray-50);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

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

/* ---------- Navbar ---------- */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--white);
    padding: 0 1.5rem;
    height: 56px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--primary);
    text-decoration: none;
    flex-shrink: 0;
}

.nav-brand:hover { color: var(--primary-dark); }
.nav-logo { height: 32px; width: 32px; }

.nav-links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    height: 100%;
}

.nav-links > a, .nav-dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    text-decoration: none;
    color: var(--gray-600);
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    transition: color var(--transition), background var(--transition);
    white-space: nowrap;
}

.nav-links > a:hover, .nav-dropdown-toggle:hover { color: var(--gray-900); background: var(--gray-50); }
.nav-links > a.active { color: var(--primary); background: var(--primary-light); }
.admin-link { color: var(--danger) !important; }
.admin-link:hover { background: var(--danger-light) !important; }

/* Nav dropdown */
.nav-dropdown { position: relative; height: 100%; display: flex; align-items: center; }

.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 180px;
    padding: 0.5rem 0;
    z-index: 200;
    border: 1px solid var(--gray-100);
}

.nav-dropdown-menu.open { display: block; }

.nav-dropdown-menu a {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--gray-800);
    font-size: 0.9rem;
    transition: background var(--transition);
}

.nav-dropdown-menu a:hover { background: var(--gray-50); color: var(--primary); }

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: 0.75rem;
    padding-left: 0.75rem;
    border-left: 1px solid var(--gray-200);
}

.nav-avatar { width: 28px; height: 28px; border-radius: 50%; }

.nav-avatar-placeholder {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
}

.nav-username { font-size: 0.85rem; color: var(--gray-600); max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-800);
    padding: 0.25rem;
}

/* ---------- Container ---------- */
.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* ---------- Page Header ---------- */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.page-header h1 { font-size: 1.5rem; color: var(--gray-900); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.6rem 1.15rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition), transform 0.1s, box-shadow var(--transition);
    line-height: 1.4;
}

.btn:active { transform: scale(0.97); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 2px 8px rgba(26,115,232,0.3); }

.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #c82333; }

.btn-success { background: var(--success); color: var(--white); }
.btn-success:hover { background: #218838; }

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--gray-200);
    color: var(--gray-800);
}

.btn-outline:hover { border-color: var(--primary); color: var(--primary); }

.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }
.btn-icon { flex-shrink: 0; }

.btn-google {
    background: var(--white);
    color: var(--gray-800);
    border: 1.5px solid var(--gray-200);
    width: 100%;
}
.btn-google:hover { background: var(--gray-50); border-color: #4285F4; }

.btn-facebook { background: #1877F2; color: var(--white); width: 100%; }
.btn-facebook:hover { background: #166fe0; }

/* ---------- Badge ---------- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: #92400e; }
.badge-info { background: var(--info-light); color: #0c5460; }

/* ---------- Login Page ---------- */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}

.login-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-header { margin-bottom: 2rem; }
.login-logo { width: 72px; height: 72px; margin-bottom: 1rem; }
.login-header h1 { font-size: 1.4rem; color: var(--gray-900); margin-bottom: 0.25rem; }
.login-subtitle { color: var(--gray-600); font-size: 0.95rem; }
.login-buttons { display: flex; flex-direction: column; gap: 0.75rem; }

/* ---------- Flash Messages ---------- */
.flash-messages { margin-bottom: 1rem; }

.flash {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    animation: flashIn 0.2s ease;
}

.flash-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.6;
    padding: 0 0.25rem;
    line-height: 1;
    color: inherit;
}

.flash-close:hover { opacity: 1; }

.flash-info { background: var(--info-light); color: #0c5460; }
.flash-success { background: var(--success-light); color: #155724; }
.flash-danger { background: var(--danger-light); color: #721c24; }
.flash-warning { background: var(--warning-light); color: #856404; }

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

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

.stat-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    text-decoration: none;
    color: inherit;
    transition: box-shadow var(--transition), transform var(--transition);
}

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

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-primary { background: var(--primary-light); color: var(--primary); }
.stat-icon-success { background: var(--success-light); color: var(--success); }
.stat-icon-warning { background: var(--warning-light); color: var(--warning); }

.stat-info { display: flex; flex-direction: column; }
.stat-number { font-size: 1.6rem; font-weight: 700; line-height: 1.2; color: var(--gray-900); }
.stat-label { font-size: 0.85rem; color: var(--gray-600); }

/* ---------- Sections ---------- */
.section { margin-bottom: 2rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.section-header h2 { font-size: 1.15rem; color: var(--gray-900); }

.quick-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }

/* ---------- Tabs ---------- */
.tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid var(--gray-100);
    margin-bottom: 1.25rem;
}

.tab {
    padding: 0.6rem 1rem;
    background: none;
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color var(--transition), border-color var(--transition);
}

.tab:hover { color: var(--gray-900); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---------- Cards / List ---------- */
.card-list { display: flex; flex-direction: column; gap: 0.75rem; }

.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    transition: box-shadow var(--transition);
}

.card:hover { box-shadow: var(--shadow-lg); }

.card-body { flex: 1; min-width: 0; }
.card-title { font-weight: 600; font-size: 1rem; color: var(--gray-900); margin-bottom: 0.15rem; }
.card-subtitle { font-size: 0.85rem; color: var(--gray-600); }
.card-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--gray-600);
}

.empty-state svg { margin-bottom: 1rem; }
.empty-state p { margin-bottom: 0.25rem; }

/* ---------- Tables ---------- */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); }

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--white);
    font-size: 0.9rem;
}

.table th, .table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--gray-100);
}

.table th {
    background: var(--gray-50);
    font-weight: 600;
    color: var(--gray-600);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--gray-50); }

.text-center { text-align: center; }
.text-muted { color: var(--gray-600); }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 0.35rem; color: var(--gray-800); }

.form-control {
    width: 100%;
    padding: 0.6rem 0.85rem;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: var(--font);
    color: var(--gray-900);
    background: var(--white);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,115,232,0.15); }

textarea.form-control { resize: vertical; }

/* ---------- SQL Console ---------- */
.sql-console { max-width: 100%; }

.sql-input {
    font-family: "Cascadia Code", "Fira Code", "Consolas", monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

.sql-actions { display: flex; gap: 0.5rem; margin-bottom: 1rem; }

.sql-result {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1rem;
    overflow-x: auto;
}

.sql-result h3 { font-size: 0.95rem; margin-bottom: 0.75rem; }

/* ---------- Modal ---------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 500;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay.open { display: flex; }

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}

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

.modal-header h2 { font-size: 1.1rem; }

.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--gray-600);
    padding: 0.25rem;
    line-height: 1;
}

.modal-close:hover { color: var(--gray-900); }

.modal-body { padding: 1.25rem; }
.modal-footer { display: flex; justify-content: flex-end; gap: 0.5rem; padding: 1rem 1.25rem; border-top: 1px solid var(--gray-100); }

@keyframes modalIn { from { opacity: 0; transform: scale(0.95); } to { opacity: 1; transform: scale(1); } }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
    .navbar { padding: 0 1rem; }
    .nav-toggle { display: block; }

    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        background: var(--white);
        box-shadow: var(--shadow-lg);
        padding: 0.75rem;
        gap: 0.25rem;
        max-height: calc(100vh - 56px);
        overflow-y: auto;
    }

    .nav-links.open { display: flex; }

    .nav-links > a, .nav-dropdown-toggle {
        padding: 0.65rem 0.75rem;
        width: 100%;
    }

    .nav-dropdown { width: 100%; flex-direction: column; align-items: stretch; }
    .nav-dropdown-menu { position: static; box-shadow: none; border: none; padding-left: 1.5rem; }
    .nav-dropdown-menu.open { display: block; }

    .nav-user {
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        padding-top: 0.5rem;
        border-top: 1px solid var(--gray-100);
    }

    .container { padding: 1rem 0.75rem; }
    .page-header h1 { font-size: 1.25rem; }
    .login-card { padding: 2rem 1.25rem; }
    .stats-grid { grid-template-columns: 1fr; }

    .table th, .table td { padding: 0.5rem 0.65rem; font-size: 0.8rem; }
}
