:root {
    --primary: #1e3a8a;
    --primary-light: #3b82f6;
    --accent: #10b981;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
}

/* --- Responsive Login Page --- */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 50%, #172554 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 440px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-brand {
    text-align: center;
    margin-bottom: 24px;
    color: white;
}

.brand-icon {
    font-size: 42px;
    margin-bottom: 8px;
    background: rgba(255, 255, 255, 0.1);
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    margin-left: auto;
    margin-right: auto;
    backdrop-filter: blur(10px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}

.login-brand h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 6px;
}

.login-brand p {
    font-size: 13px;
    color: #94a3b8;
}

.login-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    padding: 36px 30px;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    text-align: center;
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.login-card h2 {
    color: var(--primary);
    font-size: 20px;
    margin-bottom: 8px;
}

.login-card p {
    color: var(--text-muted);
    margin-bottom: 28px;
    font-size: 13.5px;
    line-height: 1.5;
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: #ffffff;
    border: 1.5px solid var(--border);
    padding: 14px 20px;
    border-radius: 10px;
    text-decoration: none;
    color: #334155;
    font-weight: 600;
    font-size: 14.5px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transition: all 0.25s ease;
    width: 100%;
}

.btn-google:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    box-shadow: 0 6px 16px rgba(0,0,0,0.08);
    transform: translateY(-1px);
}

.btn-google:active {
    transform: translateY(0);
}

.login-footer {
    margin-top: 24px;
    font-size: 12px;
    color: #64748b;
    text-align: center;
}

/* --- Responsive App Layout --- */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 260px;
    background: var(--primary);
    color: white;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px;
    background: #172554;
}

.sidebar-header h2 {
    font-size: 20px;
    margin-bottom: 4px;
}

.sidebar-header p {
    font-size: 12px;
    color: #93c5fd;
}

.sidebar-menu {
    list-style: none;
    padding: 20px 0;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-menu li a {
    display: block;
    padding: 12px 24px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
}

.sidebar-menu li a:hover, .sidebar-menu li a.active {
    background: rgba(255,255,255,0.1);
    color: white;
    border-left: 4px solid var(--accent);
}

.sidebar-menu li a.text-danger {
    color: #fca5a5;
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 30px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.topbar h1 {
    font-size: 24px;
    color: var(--primary);
}

.badge-role {
    background: var(--primary-light);
    color: white;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-role.user {
    background: #64748b;
}

.badge-role.assistant {
    background: var(--accent);
}

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

.card-metric {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    border-top: 4px solid var(--primary-light);
}

.card-metric h3 {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.metric-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.chat-section {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    max-height: 550px;
}

.chat-section h2 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--primary);
}

.chat-box {
    flex-grow: 1;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    overflow-y: auto;
    background: #fafaf9;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-msg {
    padding: 10px 14px;
    border-radius: 8px;
    max-width: 80%;
    font-size: 14px;
    line-height: 1.4;
}

.chat-msg.user {
    background: #e0f2fe;
    align-self: flex-end;
    color: #0369a1;
}

.chat-msg.assistant {
    background: white;
    border: 1px solid var(--border);
    align-self: flex-start;
    color: var(--text-main);
}

.chat-msg.error {
    background: #fee2e2;
    color: var(--danger);
    align-self: center;
}

.chat-form {
    display: flex;
    gap: 10px;
}

.chat-form input, .settings-form input, .search-form input, .form-control {
    flex-grow: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #172554;
}

.btn-secondary {
    background: var(--text-muted);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.table-container {
    background: var(--bg-card);
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    overflow-x: auto;
    margin-top: 15px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 14px;
    min-width: 600px;
}

.data-table th, .data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: #f1f5f9;
    color: var(--primary);
    font-weight: 600;
}

.data-table tr:hover {
    background: #f8fafc;
}

.pagination {
    display: flex;
    gap: 6px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.pagination a {
    padding: 6px 12px;
    border: 1px solid var(--border);
    background: white;
    color: var(--primary);
    text-decoration: none;
    border-radius: 4px;
    font-size: 13px;
}

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

.upload-card, .settings-card {
    background: var(--bg-card);
    padding: 20px;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    margin-bottom: 25px;
}

.upload-form {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    align-items: center;
    flex-wrap: wrap;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
}

.btn-danger-sm {
    background: var(--danger);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 12px;
}

.role-select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.search-form {
    display: flex;
    gap: 10px;
    width: 100%;
    max-width: 350px;
}

.model-details {
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* --- Mobile Media Queries --- */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--primary);
    cursor: pointer;
    padding: 4px 8px;
    margin-right: 12px;
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
        height: auto;
        overflow-y: auto;
    }
    
    .hamburger-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar {
        width: 100%;
        height: auto;
        display: none;
    }

    .sidebar.mobile-open {
        display: flex;
    }
    
    .sidebar-menu {
        display: flex;
        flex-wrap: wrap;
        padding: 10px;
        gap: 5px;
    }
    
    .sidebar-menu li a {
        padding: 8px 12px;
        border-radius: 6px;
        border-left: none !important;
        font-size: 13px;
    }
    
    .main-content {
        padding: 15px;
        overflow-y: visible;
    }
    
    .topbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }

    .topbar h1 {
        font-size: 18px;
    }
    
    .search-form {
        max-width: 100%;
    }
}
