/* ==========================================================================
   CSS Reset & Base
   ========================================================================== */
:root {
    --bg-darkest: #0a0a1a;
    --bg-dark: #0f0f23;
    --bg-card: rgba(26, 26, 46, 0.7);
    --border-color: rgba(255, 255, 255, 0.06);
    --primary: #6c63ff;
    --primary-hover: #837cff;
    --secondary: #00d4ff;
    --pink: #ff6b9d;
    --success: #00c853;
    --warning: #ffd600;
    --error: #ff1744;
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0b8;
    
    --role-admin: #6c63ff;
    --role-student: #00d4ff;
    --role-counselor: #00c853;
    --role-parent: #ff9800;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-glow: 0 0 20px rgba(108, 99, 255, 0.3);
    
    color-scheme: dark;
}

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

html {
    font-size: 14px; /* Reduces overall UI scale by ~12.5% */
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-darkest);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-secondary { color: var(--text-secondary); }
.text-primary { color: var(--text-primary); }
.text-gradient {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }

.hidden { display: none !important; }
.visible { display: block !important; }
.visible-mobile { display: none; }

/* Screens */
.screen {
    display: none;
    min-height: 100vh;
    width: 100%;
}
.screen.active {
    display: flex;
}

/* ==========================================================================
   Login Screen & Animated Background
   ========================================================================== */
#login-screen {
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.login-background {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: radial-gradient(circle at 15% 50%, rgba(108, 99, 255, 0.08), transparent 25%),
                radial-gradient(circle at 85% 30%, rgba(0, 212, 255, 0.08), transparent 25%);
    animation: gradientShift 15s ease infinite alternate;
    z-index: 0;
}

.login-card {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 420px;
    padding: 3rem 2rem;
    animation: scaleIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ==========================================================================
   Glassmorphism Base
   ========================================================================== */
.glass-panel {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.glass-card {
    background: rgba(255, 255, 255, 0.02);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.glass-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

/* ==========================================================================
   Layout (Post-login)
   ========================================================================== */
#main-screen {
    flex-direction: row;
}

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

.sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
    gap: 0.75rem;
}

.sidebar-header .logo-icon {
    font-size: 1.5rem;
}

#sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.menu-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
    gap: 1rem;
    border-left: 3px solid transparent;
    cursor: pointer;
}

.menu-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.03);
}

.menu-item.active {
    color: var(--primary);
    background: rgba(108, 99, 255, 0.1);
    border-left-color: var(--primary);
}

.menu-icon {
    font-size: 1.25rem;
}

#content-area {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

#top-header {
    height: 70px;
    background: rgba(15, 15, 35, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.header-user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.container {
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
    min-width: 0; /* Crucial for preventing flex children from blowing out page width */
}

/* ==========================================================================
   Forms & Inputs
   ========================================================================== */
.form-group {
    margin-bottom: 1.5rem;
}

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

input, select, textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(108, 99, 255, 0.2);
    background: rgba(255, 255, 255, 0.05);
}

input::placeholder, textarea::placeholder {
    color: rgba(255, 255, 255, 0.2);
}

select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a0a0b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

option {
    background: var(--bg-dark);
    color: var(--text-primary);
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #8a84ff);
    color: #fff;
    box-shadow: 0 4px 15px rgba(108, 99, 255, 0.2);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 99, 255, 0.4);
}

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

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

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

.btn-danger {
    background: linear-gradient(135deg, var(--error), #ff4b69);
    color: #fff;
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #2ee677);
    color: #fff;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: var(--transition);
    display: inline-flex;
    position: relative;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* ==========================================================================
   Badges
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25em 0.75em;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.notification-btn .badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: var(--error);
    color: white;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    font-size: 0.65rem;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--background);
}

.badge-admin { background: rgba(108, 99, 255, 0.15); color: var(--primary); border: 1px solid rgba(108, 99, 255, 0.3); }
.badge-student { background: rgba(0, 212, 255, 0.15); color: var(--secondary); border: 1px solid rgba(0, 212, 255, 0.3); }
.badge-counselor { background: rgba(0, 200, 83, 0.15); color: var(--success); border: 1px solid rgba(0, 200, 83, 0.3); }
.badge-parent { background: rgba(255, 152, 0, 0.15); color: var(--warning); border: 1px solid rgba(255, 152, 0, 0.3); }

/* ==========================================================================
   Tables
   ========================================================================== */
.table-container {
    width: 100%;
    overflow-x: auto;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

th, td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: rgba(0, 0, 0, 0.2);
}

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

tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

/* ==========================================================================
   Modals
   ========================================================================== */
#modal-container {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: 1000;
    pointer-events: none;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.modal-backdrop {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(10, 10, 26, 0.8);
    backdrop-filter: blur(5px);
    pointer-events: auto;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-content {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    pointer-events: auto;
    opacity: 0;
    transform: scale(0.95) translateY(10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-active .modal-backdrop { opacity: 1; }
.modal-active .modal-content { opacity: 1; transform: scale(1) translateY(0); }

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

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

/* ==========================================================================
   Toast Notifications
   ========================================================================== */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem 1.5rem;
    min-width: 300px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
    position: relative;
    overflow: hidden;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.show {
    transform: translateX(0);
}

.toast-progress {
    position: absolute;
    bottom: 0; left: 0; height: 3px;
    background: var(--primary);
    width: 100%;
}

.toast.success .toast-progress { background: var(--success); }
.toast.error .toast-progress { background: var(--error); }
.toast.warning .toast-progress { background: var(--warning); }
.toast.info .toast-progress { background: var(--secondary); }

/* ==========================================================================
   Chronometer
   ========================================================================== */
.chronometer-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
}

.chronometer-display {
    font-size: 6rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
    margin: 2rem 0;
    letter-spacing: 2px;
}

.chronometer-display.active {
    animation: pulseGlow 2s infinite alternate;
}

.study-info-card {
    background: rgba(108, 99, 255, 0.1);
    border: 1px solid rgba(108, 99, 255, 0.3);
    padding: 1rem 2rem;
    border-radius: 999px;
    margin-bottom: 2rem;
}

/* ==========================================================================
   Dashboard Stat Cards
   ========================================================================== */
.stat-card {
    position: relative;
}
.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
}
.stat-icon {
    font-size: 2rem;
    background: rgba(255,255,255,0.05);
    width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 12px;
}
.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    margin: 0.5rem 0;
}

/* ==========================================================================
   Animations & Keyframes
   ========================================================================== */
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

@keyframes scaleIn {
    0% { opacity: 0; transform: scale(0.9) translateY(20px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes pulseGlow {
    0% { text-shadow: 0 0 10px rgba(0, 212, 255, 0.2); }
    100% { text-shadow: 0 0 30px rgba(0, 212, 255, 0.8), 0 0 50px rgba(0, 212, 255, 0.4); }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.pulse {
    animation: pulse 2s infinite;
}

.animate-in {
    animation: scaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */
@media (max-width: 1024px) {
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    
    #sidebar {
        transform: translateX(-100%);
        width: 100%;
        max-width: 300px;
    }
    
    #sidebar.mobile-open {
        transform: translateX(0);
    }
    
    #content-area {
        margin-left: 0;
    }
    
    .visible-mobile { display: inline-flex; }
    
    .container { padding: 1rem; }
    
    .chronometer-display { font-size: 4rem; }
}

/* ==========================================================================
   AI Assistant Styles
   ========================================================================== */

.ai-assistant-page {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
    max-height: calc(100vh - 80px);
    gap: 0;
}

.ai-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 0.75rem;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 1rem;
}

.ai-header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.ai-logo-pulse {
    position: relative;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-logo-icon {
    font-size: 1.6rem;
    z-index: 2;
    position: relative;
}

.ai-logo-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--primary);
    animation: ai-pulse-ring 2s ease-in-out infinite;
}

@keyframes ai-pulse-ring {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50% { transform: scale(1.2); opacity: 0.2; }
}

.ai-student-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Chat Container */
.ai-chat-container {
    flex: 1;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: linear-gradient(180deg, rgba(10, 10, 26, 0.9) 0%, rgba(15, 15, 35, 0.95) 100%);
    padding: 1.5rem;
    scroll-behavior: smooth;
}

.ai-messages {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 100%;
}

/* Welcome Screen */
.ai-welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 1rem;
    flex: 1;
    gap: 0.75rem;
}

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

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

.ai-welcome-screen h3 {
    font-size: 1.4rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Quick Prompt Buttons */
.ai-quick-prompts {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 1rem;
    max-width: 600px;
}

.ai-quick-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    background: rgba(108, 99, 255, 0.08);
    border: 1px solid rgba(108, 99, 255, 0.2);
    border-radius: 999px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.ai-quick-btn:hover {
    background: rgba(108, 99, 255, 0.2);
    border-color: rgba(108, 99, 255, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.15);
}

.ai-quick-icon {
    font-size: 1rem;
}

/* Message Bubbles */
.ai-message {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
    animation: ai-msg-in 0.3s ease-out;
}

@keyframes ai-msg-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-message-user {
    flex-direction: row-reverse;
    align-self: flex-end;
}

.ai-message-model,
.ai-message-error {
    align-self: flex-start;
}

.ai-msg-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.ai-avatar-user {
    background: linear-gradient(135deg, var(--primary), #9b59b6);
}

.ai-avatar-bot {
    background: linear-gradient(135deg, #00d4ff, #6c63ff);
}

.ai-avatar-error {
    background: rgba(255, 23, 68, 0.2);
}

.ai-msg-content {
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ai-content-user {
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.25), rgba(108, 99, 255, 0.15));
    border: 1px solid rgba(108, 99, 255, 0.2);
    border-radius: var(--radius-md) 4px var(--radius-md) var(--radius-md);
    white-space: pre-wrap;
}

.ai-content-bot {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    border-radius: 4px var(--radius-md) var(--radius-md) var(--radius-md);
}

.ai-content-error {
    background: rgba(255, 23, 68, 0.08);
    border: 1px solid rgba(255, 23, 68, 0.2);
    border-radius: 4px var(--radius-md) var(--radius-md) var(--radius-md);
    color: var(--error);
}

/* Typing Indicator */
.ai-typing {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ai-typing-dots {
    display: flex;
    gap: 4px;
}

.ai-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--primary);
    animation: ai-dot-bounce 1.4s infinite ease-in-out both;
}

.ai-typing-dots span:nth-child(1) { animation-delay: 0s; }
.ai-typing-dots span:nth-child(2) { animation-delay: 0.16s; }
.ai-typing-dots span:nth-child(3) { animation-delay: 0.32s; }

@keyframes ai-dot-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.ai-typing-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-style: italic;
}

/* Input Area */
.ai-input-area {
    padding: 0.75rem 0 0 0;
    flex-shrink: 0;
}

.ai-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.5rem 0.5rem 1rem;
    transition: border-color 0.2s;
}

.ai-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(108, 99, 255, 0.1);
}

.ai-input-field {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 0.92rem;
    font-family: 'Inter', sans-serif;
    resize: none;
    max-height: 120px;
    line-height: 1.5;
    padding: 0.4rem 0;
}

.ai-input-field::placeholder {
    color: var(--text-secondary);
}

.ai-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
}

.ai-send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.ai-send-btn:disabled {
    cursor: not-allowed;
}

.ai-disclaimer {
    text-align: center;
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-top: 0.4rem;
    opacity: 0.6;
}

/* Markdown Rendered Content */
.ai-content-bot p {
    margin-bottom: 0.5rem;
}

.ai-content-bot p:last-child {
    margin-bottom: 0;
}

.ai-content-bot strong {
    color: var(--secondary);
}

.ai-md-h2, .ai-md-h3, .ai-md-h4 {
    margin: 0.75rem 0 0.4rem 0;
    color: var(--text-primary);
}

.ai-md-h2 { font-size: 1.1rem; }
.ai-md-h3 { font-size: 1rem; }
.ai-md-h4 { font-size: 0.95rem; }

.ai-md-list {
    margin: 0.4rem 0;
    padding-left: 1.2rem;
}

.ai-md-list li {
    margin-bottom: 0.25rem;
}

.ai-table-wrapper {
    overflow-x: auto;
    margin: 0.5rem 0;
    border-radius: 6px;
}

.ai-md-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.ai-md-table th,
.ai-md-table td {
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color);
    text-align: left;
}

.ai-md-table th {
    background: rgba(108, 99, 255, 0.1);
    font-weight: 600;
}

.ai-md-table tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.02);
}

.ai-code-block {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.75rem;
    overflow-x: auto;
    margin: 0.5rem 0;
    font-size: 0.82rem;
    font-family: 'Fira Code', 'Consolas', monospace;
}

.ai-inline-code {
    background: rgba(108, 99, 255, 0.15);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    font-family: 'Fira Code', 'Consolas', monospace;
}

/* Mobile AI Responsive */
@media (max-width: 768px) {
    .ai-assistant-page {
        height: calc(100vh - 60px);
    }

    .ai-header {
        padding: 0.75rem 1rem;
    }

    .ai-chat-container {
        padding: 1rem;
    }

    .ai-message {
        max-width: 95%;
    }

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

    .ai-welcome-screen {
        padding: 2rem 0.5rem;
    }
}

/* ==========================================================================
   Modern Tabs / Segmented Control
   ========================================================================== */
.tabs {
    display: inline-flex;
    background: rgba(15, 15, 35, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.4rem;
    gap: 0.3rem;
    margin-bottom: 1.5rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    overflow-x: auto;
    max-width: 100%;
}

.tab-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    padding: 0.6rem 1.25rem;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    position: relative;
    z-index: 1;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    color: #fff;
    background: var(--primary);
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.4);
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.tab-content {
    animation: scaleIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ==========================================================================
   Mobile Layout Fixes
   ========================================================================== */
@media (max-width: 768px) {
    #content-area {
        min-width: 0 !important;
    }
    .container {
        min-width: 0 !important;
    }
    #top-header {
        padding: 0 1rem !important;
    }
    .header-actions {
        gap: 0.5rem !important;
    }
    #logout-btn {
        padding: 0.4rem 0.5rem !important;
        font-size: 0.8rem !important;
        white-space: nowrap;
    }
    .table-container, table, .table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        margin: 0 !important;
        padding: 0 !important;
    }
    .table-container table, table, .table {
        min-width: 700px !important;
    }
    .table-container th, .table-container td, table th, table td {
        white-space: nowrap;
    }
    .glass-card {
        padding: 1rem !important;
    }
}
