:root {
    --background: 0 0% 100%;
    --foreground: 240 10% 3.9%;
    --card: 0 0% 100%;
    --card-foreground: 240 10% 3.9%;
    --popover: 0 0% 100%;
    --popover-foreground: 240 10% 3.9%;
    --primary: 217 91% 60%;
    --primary-foreground: 0 0% 98%;
    --secondary: 240 4.8% 95.9%;
    --secondary-foreground: 240 5.9% 10%;
    --muted: 240 4.8% 95.9%;
    --muted-foreground: 240 3.8% 46.1%;
    --accent: 240 4.8% 95.9%;
    --accent-foreground: 240 5.9% 10%;
    --destructive: 0 84.2% 60.2%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 5.9% 90%;
    --input: 240 5.9% 90%;
    --ring: 217 91% 60%;
    --radius: 0.625rem;
    --sidebar-background: 0 0% 98%;
    --sidebar-foreground: 240 5.3% 26.1%;
    --sidebar-primary: 217 91% 60%;
    --sidebar-primary-foreground: 0 0% 100%;
    --sidebar-accent: 240 4.8% 95.9%;
    --sidebar-accent-foreground: 240 5.9% 10%;
    --sidebar-border: 220 13% 91%;
    --sidebar-ring: 217 91% 60%;
}

.dark {
    --background: 240 10% 3.9%;
    --foreground: 0 0% 98%;
    --card: 240 10% 3.9%;
    --card-foreground: 0 0% 98%;
    --popover: 240 10% 3.9%;
    --popover-foreground: 0 0% 98%;
    --primary: 217 91% 60%;
    --primary-foreground: 0 0% 100%;
    --secondary: 240 3.7% 15.9%;
    --secondary-foreground: 0 0% 98%;
    --muted: 240 3.7% 15.9%;
    --muted-foreground: 240 5% 64.9%;
    --accent: 240 3.7% 15.9%;
    --accent-foreground: 0 0% 98%;
    --destructive: 0 62.8% 30.6%;
    --destructive-foreground: 0 0% 98%;
    --border: 240 3.7% 15.9%;
    --input: 240 3.7% 15.9%;
    --ring: 217 91% 60%;
    --sidebar-background: 240 5.9% 10%;
    --sidebar-foreground: 240 4.8% 95.9%;
    --sidebar-primary: 217 91% 60%;
    --sidebar-primary-foreground: 0 0% 100%;
    --sidebar-accent: 240 3.7% 15.9%;
    --sidebar-accent-foreground: 240 4.8% 95.9%;
    --sidebar-border: 240 3.7% 15.9%;
    --sidebar-ring: 217 91% 60%;
}

* {
    border-color: hsl(var(--border));
}

body {
    background-color: hsl(var(--background));
    color: hsl(var(--foreground));
    font-family: 'Inter', system-ui, sans-serif;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Analytics specific containers */
.analytics-container {
    max-width: 100%;
    overflow-x: hidden;
}
.analytics-card {
    overflow: hidden;
    min-width: 0;
}
.chart-container {
    position: relative;
    width: 100%;
    height: 200px;           /* Fixed height prevents canvas stretching */
    max-width: 100%;
}
.chart-container canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}
@media (max-width: 640px) {
    .chart-container {
        height: 180px;
    }
    .analytics-card {
        padding: 1rem;
    }
}

/* Animations */
.animate-fade-in {
    animation: fadeIn 0.3s ease-out;
}
.animate-slide-in {
    animation: slideIn 0.3s ease-out;
}
.animate-slide-up {
    animation: slideUp 0.3s ease-out;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(100%); }
    to { opacity: 1; transform: translateY(0); }
}

/* Card Hover Effects */
.card-hover {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
}

/* Global Search */
#global-search {
    position: relative;
}
#search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    max-height: 400px;
    overflow-y: auto;
    background: hsl(var(--popover));
    border: 1px solid hsl(var(--border));
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
    margin-top: 0.25rem;
}

/* Touch Targets */
.touch-target {
    min-height: 44px;
    min-width: 44px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
@media (max-width: 640px) {
    .toast-container {
        left: 1rem;
        right: 1rem;
        top: auto;
        bottom: calc(1rem + env(safe-area-inset-bottom) + 56px);
    }
}

/* Mobile Bottom Nav */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e2e8f0;
    z-index: 40;
    padding-bottom: env(safe-area-inset-bottom);
}
.dark .mobile-bottom-nav {
    background: hsl(var(--card));
    border-color: hsl(var(--border));
}

/* Sidebar Transitions */
.sidebar-transition {
    transition: width 0.3s ease, transform 0.3s ease;
}

/* Chat Bubbles */
.chat-bubble-sent {
    background-color: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border-radius: 0.5rem;
    border-top-right-radius: 0;
    padding: 0.75rem;
    max-width: 80%;
    align-self: flex-end;
}
.chat-bubble-received {
    background-color: hsl(var(--muted));
    border-radius: 0.5rem;
    border-top-left-radius: 0;
    padding: 0.75rem;
    max-width: 80%;
    align-self: flex-start;
}

/* Student Tables */
.students-table-container {
    width: 100%;
    overflow-x: auto;
}
.students-table {
    min-width: 1000px;
    width: 100%;
}

/* Focus Visible */
.focus-visible:focus-visible {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* Safe Area Support */
.safe-area-top { padding-top: env(safe-area-inset-top); }
.safe-area-bottom { padding-bottom: calc(env(safe-area-inset-bottom) + 16px); }
.safe-area-left { padding-left: env(safe-area-inset-left); }
.safe-area-right { padding-right: env(safe-area-inset-right); }
