/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 5rem;
    right: 1rem;
    z-index: 3000;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.toast {
    position: relative;
    padding: 0;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    animation: premiumToastIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    pointer-events: auto;
    overflow: hidden;
    min-width: 320px;
    max-width: 450px;
    width: fit-content;
    backdrop-filter: blur(15px);
    border-left: none;
    /* Removed old style */
}

.toast-content-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    color: white;
}

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.toast-message {
    font-size: 0.95rem;
    font-weight: 500;
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    background: rgba(255, 255, 255, 0.3);
    animation: toastProgress 5s linear forwards;
}

.toast.success {
    background: linear-gradient(135deg, #2e7d32 0%, #1b5e20 100%);
    box-shadow: 0 8px 20px rgba(46, 125, 50, 0.3);
}

.toast.error {
    background: linear-gradient(135deg, #d32f2f 0%, #b71c1c 100%);
    box-shadow: 0 8px 20px rgba(211, 47, 47, 0.3);
}

.toast.info {
    background: linear-gradient(135deg, #1976d2 0%, #0d47a1 100%);
    box-shadow: 0 8px 20px rgba(25, 118, 210, 0.3);
}

.toast.warning {
    background: linear-gradient(135deg, #f57c00 0%, #e65100 100%);
    box-shadow: 0 8px 20px rgba(245, 124, 0, 0.3);
}

@keyframes premiumToastIn {
    from {
        transform: translateX(50px) scale(0.9);
        opacity: 0;
    }

    to {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

@keyframes toastProgress {
    from {
        width: 100%;
    }

    to {
        width: 0%;
    }
}

@keyframes slideInFromRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutToRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Mobile-first responsive */
@media (max-width: 480px) {
    .card {
        padding: 1.25rem;
        margin-bottom: 0.75rem;
        border-radius: 10px;
    }

    .card h4 {
        font-size: 1.2rem;
        margin-bottom: 0.5rem;
    }

    .card p {
        font-size: 1.1rem;
        line-height: 1.5;
    }

    .list-item {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
        min-height: 70px;
    }

    .list-item .actions {
        align-self: stretch;
        justify-content: flex-end;
        gap: 0.5rem;
    }

    #toast-container {
        top: 4.5rem;
        left: 0.75rem;
        right: 0.75rem;
    }

    .toast {
        padding: 1rem;
        font-size: 1.1rem;
        border-radius: 10px;
        min-width: auto;
        width: calc(100% - 1.5rem);
    }
}

/* ===============================
   Attendance Section Styles
   =============================== */

/* Child Selector */
.attendance-child-selector {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    flex-wrap: wrap;
}

.attendance-child-selector label {
    font-weight: 600;
    color: #2e7d32;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.attendance-child-selector select {
    flex: 1;
    min-width: 200px;
    padding: 0.75rem 1rem;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 1rem;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.attendance-child-selector select:focus {
    outline: none;
    border-color: #2e7d32;
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.15);
}

/* Summary Stats */
.attendance-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1rem;
    margin-bottom: 0.5rem;
    margin: 1rem 0;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s, box-shadow 0.2s;
    border-left: 4px solid #dee2e6;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* Icon and value side by side */
.stat-card-top {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.stat-card i {
    font-size: 1.75rem;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
}

.stat-card label {
    font-size: 0.85rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Stat card color variants */
.stat-card.present {
    border-left-color: #2e7d32;
}

.stat-card.present i,
.stat-card.present .stat-value {
    color: #2e7d32;
}

.stat-card.absent {
    border-left-color: #d32f2f;
}

.stat-card.absent i,
.stat-card.absent .stat-value {
    color: #d32f2f;
}

.stat-card.rate {
    border-left-color: #1976d2;
}

.stat-card.rate i,
.stat-card.rate .stat-value {
    color: #1976d2;
}

/* Attendance Container */
#attendance-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Attendance Record Cards */
.attendance-card {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border-left: 4px solid #2e7d32;
}

.attendance-card h4 {
    color: #2e7d32;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.attendance-record {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.attendance-record:last-child {
    margin-bottom: 0;
}

.attendance-record-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.attendance-record-teacher {
    font-weight: 600;
    color: #343a40;
}

.attendance-record-time {
    font-size: 0.85rem;
    color: #6c757d;
}

.attendance-status {
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
}

.attendance-status.present {
    background-color: #e8f5e9;
    color: #2e7d32;
}

.attendance-status.absent {
    background-color: #ffebee;
    color: #c62828;
}

.attendance-status.late {
    background-color: #fff3e0;
    color: #e65100;
}

/* Empty State */
.attendance-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: #6c757d;
}

.attendance-empty i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.attendance-empty p {
    font-size: 1.1rem;
}

/* Attendance Filters */
.attendance-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 12px;
}

.attendance-filters .filter-group {
    flex: 1;
    min-width: 150px;
}

.attendance-filters label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.35rem;
}

.attendance-filters input,
.attendance-filters select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-size: 0.9rem;
    background: white;
}

.attendance-filters input:focus,
.attendance-filters select:focus {
    outline: none;
    border-color: #2e7d32;
    box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.15);
}

.attendance-filters .filter-actions {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
}

.attendance-filters .btn-filter {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
}

.attendance-filters .btn-filter.primary {
    background: #2e7d32;
    color: white;
}

.attendance-filters .btn-filter.primary:hover {
    background: #1b5e20;
}

.attendance-filters .btn-filter.secondary {
    background: #dee2e6;
    color: #495057;
}

.attendance-filters .btn-filter.secondary:hover {
    background: #ced4da;
}

/* Responsive - Mobile */
@media (max-width: 480px) {
    .attendance-child-selector {
        flex-direction: column;
        align-items: stretch;
        padding: 0.5rem;
        margin-bottom: 0.5rem;
        gap: 0.5rem;
    }

    .attendance-child-selector label {
        font-size: 0.7rem;
    }

    .attendance-child-selector select {
        min-width: 100%;
        padding: 0.4rem;
        font-size: 0.7rem;
    }

    /* Keep all stat cards side by side on mobile */
    .attendance-summary {
        grid-template-columns: repeat(4, 1fr);
        gap: 0.25rem;
        margin: 0.5rem 0;
    }

    .stat-card {
        padding: 0.2rem 0.35rem;
        border-radius: 8px;
        border-left-width: 3px;
        gap: 0.1rem;
    }

    .stat-card-top {
        flex-direction: row;
        gap: 0.15rem;
        margin-bottom: 0;
    }

    .stat-card i {
        font-size: 0.7rem;
    }

    .stat-card .stat-value {
        font-size: 0.7rem;
    }

    .stat-card label {
        font-size: 0.5rem;
        letter-spacing: 0;
        margin-top: 0;
    }

    /* Filters compact - side by side */
    .attendance-filters {
        padding: 0.4rem;
        gap: 0.35rem;
        margin-bottom: 0.5rem;
        flex-wrap: wrap;
    }

    .attendance-filters .filter-group {
        flex: 1;
        min-width: 30%;
    }

    .attendance-filters label {
        font-size: 0.65rem;
        margin-bottom: 0.15rem;
    }

    .attendance-filters input,
    .attendance-filters select {
        padding: 0.3rem 0.4rem;
        font-size: 0.7rem;
    }

    .attendance-filters .btn-filter {
        padding: 0.3rem 0.5rem;
        font-size: 0.7rem;
    }

    /* Attendance cards compact */
    #attendance-container {
        gap: 0.5rem;
    }

    .attendance-card {
        padding: 0.75rem;
        border-radius: 8px;
        border-left-width: 3px;
    }

    .attendance-card h4 {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
    }

    .attendance-record {
        flex-direction: column;
        align-items: flex-start;
        padding: 0.5rem;
        gap: 0.35rem;
        margin-bottom: 0.35rem;
    }

    .attendance-record-teacher {
        font-size: 0.85rem;
    }

    .attendance-record-time {
        font-size: 0.75rem;
    }

    .attendance-status {
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
    }

    .attendance-empty {
        padding: 1.5rem 0.5rem;
    }

    .attendance-empty i {
        font-size: 2rem;
    }

    .attendance-empty p {
        font-size: 0.9rem;
    }
}

/* General Filters Bar */
.filters-bar {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #e9ecef;
}

.filter-group {
    flex: 1;
    min-width: 180px;
}

.filter-input,
.filter-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #dee2e6;
    border-radius: 10px;
    font-size: 0.95rem;
    background-color: white;
    transition: all 0.3s ease;
    color: var(--text-primary);
}

.filter-input:focus,
.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1);
}

.filter-input::placeholder {
    color: #adb5bd;
}

.close-modal:hover {
    color: #000;
}

.dashboard-actions {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
    z-index: 100;
}

.dashboard-action-btn {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Printing / PDF Export Optimizations */
@media print {
    .no-print {
        display: none !important;
    }

    .dashboard-modal-content {
        box-shadow: none !important;
        border: none !important;
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
    }

    .dashboard-body-grid {
        max-height: none !important;
        overflow: visible !important;
    }
}

/* Specific to E-Notes Grid */
.enotes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.4rem;
    margin-top: 0.75rem;
}

.enote-card {
    background: white;
    border-radius: 12px;
    border: 1px solid #eee;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    padding: 12px 16px;
    margin-bottom: 0px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 110px;
    border-left: 4px solid var(--primary-color);
}

.enote-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}



@media (max-width: 480px) {
    .filters-bar {
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .filter-group {
        min-width: 100%;
    }

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

/* AI Tutor Styles */
.ai-fab {
    display: none;
    position: fixed;
    bottom: 5.5rem;
    right: 2rem;
    width: 52px;
    height: 52px;
    background: #2e7d32;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    cursor: grab;
    z-index: 2000;
    transition: all 0.2s ease;
}

.ai-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.ai-fab:active {
    cursor: grabbing;
    transform: scale(0.95);
}



/* Home Glowing Bulb Styles */
.glowing-bulb {
    display: none;
    /* Hidden by default, shown only in Home section */
    position: fixed;
    bottom: 5.5rem;
    right: 2rem;
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, #f5a623 0%, #f7931e 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 0 15px rgba(245, 166, 35, 0.6), 0 0 30px rgba(245, 166, 35, 0.4);
    cursor: pointer;
    z-index: 2000;
    transition: transform 0.2s;
    animation: glow-pulse 2s infinite;
}

.glowing-bulb:hover {
    transform: scale(1.1);
    box-shadow: 0 0 25px rgba(245, 166, 35, 0.8), 0 0 40px rgba(245, 166, 35, 0.6);
}

.glowing-bulb:active {
    cursor: grabbing;
    transform: scale(0.95);
}

@keyframes glow-pulse {
    0% {
        box-shadow: 0 0 15px rgba(245, 166, 35, 0.6), 0 0 30px rgba(245, 166, 35, 0.4);
    }

    50% {
        box-shadow: 0 0 25px rgba(245, 166, 35, 0.8), 0 0 50px rgba(245, 166, 35, 0.6);
    }

    100% {
        box-shadow: 0 0 15px rgba(245, 166, 35, 0.6), 0 0 30px rgba(245, 166, 35, 0.4);
    }
}

@media (max-width: 480px) {
    #ai-tutor-fab {
        bottom: 6rem;
    }

    #home-glowing-bulb {
        bottom: 6rem;
    }
}

/* Extra Small Mobile View (e.g., 364px) */
@media (max-width: 364px) {
    #ai-tutor-fab {
        width: 30px;
        height: 30px;
        font-size: 1rem;
        bottom: 9rem !important;
    }

    #home-glowing-bulb {
        width: 30px;
        height: 30px;
        font-size: 1rem;
        bottom: 9rem !important;
    }

    .ai-modal-content {
        height: 85vh;
        max-width: 98%;
        margin: 0 auto;
    }

    .ai-input-wrapper {
        padding: 0.4rem 0.5rem;
    }
    
    .ai-upload-inside {
        left: 0.85rem;
        bottom: 0.5rem;
        font-size: 0.9rem;
    }
    
    .ai-input-wrapper textarea {
        padding: 0.45rem 2.25rem 0.45rem 0.75rem;
        font-size: 0.85rem;
    }
}

.ai-modal-content {
    max-width: 480px;
    width: 100%;
    height: 75vh;
    max-height: 650px;
    display: flex;
    flex-direction: column;
    padding: 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    background: white;
}

.ai-modal-header {
    background: #2e7d32;
    color: white;
    padding: 0.85rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.ai-modal-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.05rem;
    font-weight: 600;
}

.ai-modal-header h3 i {
    font-size: 1.3rem;
    color: #ffd700;
}

.ai-modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
    overflow: hidden;
}

.ai-chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ai-message {
    max-width: 85%;
    padding: 0.6rem 0.85rem;
    border-radius: 8px;
    font-size: 0.875rem;
    line-height: 1.4;
    position: relative;
}

.ai-message .message-time {
    font-size: 0.65rem;
    opacity: 0.6;
    margin-top: 0.25rem;
    display: block;
    text-align: right;
}

.ai-message.bot {
    align-self: flex-start;
    background: white;
    color: #1a1a1a;
    border-radius: 8px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.ai-message.user {
    align-self: flex-end;
    background: #2e7d32;
    color: white;
    border-radius: 8px;
}

/* Markdown Support within AI Bot messages */
.ai-message.bot p {
    margin-bottom: 0.75rem;
}

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

.ai-message.bot ul,
.ai-message.bot ol {
    margin: 0.5rem 0 0.75rem 1.25rem;
}

.ai-message.bot li {
    margin-bottom: 0.25rem;
}

.ai-message.bot h1,
.ai-message.bot h2,
.ai-message.bot h3 {
    font-size: 1rem;
    margin: 0.5rem 0 0.35rem 0;
    color: #2e7d32;
}

.ai-message.bot strong {
    font-weight: 700;
    color: #1b5e20;
}

.ai-message.bot code {
    background: #e1e4e8;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
}

.ai-message.bot pre {
    background: #24292e;
    color: #e6edf3;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.75rem 0;
}

.ai-message.bot blockquote {
    border-left: 4px solid #ced4da;
    padding-left: 1rem;
    margin: 0.75rem 0;
    color: #6a737d;
    font-style: italic;
}

/* Client-side formatted elements (Zero Token Cost) - Modern Design */
.grade-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.85em;
    margin: 0.15rem 0.25rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
    letter-spacing: 0.3px;
}

.grade-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

.grade-badge.grade-high {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}

.grade-badge.grade-medium {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
}

.grade-badge.grade-low {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: white;
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
}

.subject-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #1e40af;
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.88em;
    border: 1.5px solid #93c5fd;
    margin: 0.15rem 0.2rem;
    box-shadow: 0 1px 3px rgba(59, 130, 246, 0.15);
    transition: all 0.2s ease;
}

.subject-tag:hover {
    background: linear-gradient(135deg, #bfdbfe 0%, #93c5fd 100%);
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(59, 130, 246, 0.25);
}

/* Enhanced markdown styling - Modern & Clean */
.ai-message.bot em {
    color: #7c3aed;
    font-style: italic;
    font-weight: 500;
}

.ai-message.bot a {
    color: #059669;
    text-decoration: none;
    border-bottom: 2px solid #6ee7b7;
    transition: all 0.2s ease;
    font-weight: 500;
}

.ai-message.bot a:hover {
    border-bottom-color: #059669;
    background: rgba(5, 150, 105, 0.05);
}

.ai-message.bot hr {
    border: none;
    height: 2px;
    background: linear-gradient(to right, transparent, #e5e7eb, transparent);
    margin: 1.25rem 0;
}

.ai-message.bot table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
    font-size: 0.85em;
}

.ai-message.bot table th,
.ai-message.bot table td {
    padding: 0.5rem 0.75rem;
    border: 1px solid #e5e7eb;
    text-align: left;
}

.ai-message.bot table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.ai-message.bot table tr:hover {
    background: #f9fafb;
}

.ai-message.bot img {
    max-width: 100%;
    border-radius: 8px;
    margin: 0.5rem 0;
}

/* Better list styling */
.ai-message.bot ul,
.ai-message.bot ol {
    margin: 0.5rem 0 0.75rem 1.5rem;
    padding-left: 0.5rem;
}

.ai-message.bot li {
    margin-bottom: 0.35rem;
    line-height: 1.6;
}

.ai-message.bot li::marker {
    color: #059669;
}

/* Better heading hierarchy */
.ai-message.bot h1 {
    font-size: 1.25rem;
    margin: 1rem 0 0.5rem 0;
    color: #059669;
    font-weight: 700;
    border-bottom: 2px solid #d1fae5;
    padding-bottom: 0.35rem;
}

.ai-message.bot h2 {
    font-size: 1.1rem;
    margin: 0.85rem 0 0.45rem 0;
    color: #047857;
    font-weight: 600;
}

.ai-message.bot h3 {
    font-size: 1rem;
    margin: 0.75rem 0 0.4rem 0;
    color: #065f46;
    font-weight: 600;
}

/* Better code blocks */
.ai-message.bot code {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 0.88em;
    color: #dc2626;
    border: 1px solid #d1d5db;
}

.ai-message.bot pre {
    background: linear-gradient(135deg, #1f2937 0%, #111827 100%);
    color: #f9fafb;
    padding: 1rem 1.25rem;
    border-radius: 10px;
    overflow-x: auto;
    margin: 0.85rem 0;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
    border: 1px solid #374151;
}

.ai-message.bot pre code {
    background: transparent;
    padding: 0;
    border: none;
    color: inherit;
    font-size: 0.9em;
}

/* Better blockquote */
.ai-message.bot blockquote {
    border-left: 4px solid #3b82f6;
    padding-left: 1rem;
    margin: 0.85rem 0;
    color: #4b5563;
    font-style: italic;
    background: linear-gradient(to right, #eff6ff, transparent);
    padding: 0.75rem 1rem;
    border-radius: 0 8px 8px 0;
}

.ai-selected-notes-chips {
    padding: 0.5rem 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    background: #f8f9fa;
    border-top: 1px solid #eee;
}

.note-chip {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 0.25rem 0.65rem;
    border-radius: 16px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid #c8e6c9;
}

.note-chip i {
    cursor: pointer;
}

.ai-input-wrapper {
    padding: 0.65rem 0.75rem;
    background: white;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 0;
    align-items: flex-end;
    position: relative;
}

.ai-input-wrapper textarea {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 0.5rem 2.5rem 0.5rem 0.85rem;
    resize: none;
    min-height: 36px;
    max-height: 120px;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.4;
    overflow-y: auto;
}

.ai-input-wrapper textarea:focus {
    outline: none;
    border-color: #2e7d32;
}

/* Upload button inside textarea */
.ai-upload-inside {
    position: absolute;
    left: 1.25rem;
    bottom: 0.85rem;
    background: none;
    border: none;
    color: #757575;
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    z-index: 1;
}

.ai-upload-inside:hover {
    color: #2e7d32;
}

.ai-note-dropdown {
    position: absolute;
    bottom: 100%;
    left: 1rem;
    right: 1rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    z-index: 10;
}

.ai-note-option {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.2s;
}

.ai-note-option:hover {
    background: #f8f9fa;
}

.ai-note-option:last-child {
    border-bottom: none;
}

@media (max-width: 480px) {
    .ai-modal-content {
        width: 100%;
        height: 100%;
        max-width: none;
        border-radius: 0;
    }

    .ai-input-wrapper {
        padding: 0.5rem 0.65rem;
    }
    
    #ai-send-btn {
        width: 34px !important;
        height: 34px !important;
    }
    
    .ai-upload-inside {
        left: 1rem;
        bottom: 0.65rem;
    }
}

/* Typing Indicator Animation */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 0.85rem;
    background: white;
    border-radius: 8px;
    align-self: flex-start;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
    width: fit-content;
}

.typing-indicator .dots {
    display: flex;
    gap: 0.25rem;
}

.typing-indicator .dot {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite;
}

.typing-indicator .dot:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator .dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing-bounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* AI Input Buttons */
#ai-send-btn {
    background: #2e7d32;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    font-size: 0.95rem;
    flex-shrink: 0;
    transition: background 0.2s;
    margin-left: 0.5rem;
}

#ai-send-btn:hover {
    background: #1b5e20;
}

/* Empty State */
.ai-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1.5rem;
    text-align: center;
    color: #999;
}

.ai-empty-state i {
    font-size: 3rem;
    color: #2e7d32;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.ai-empty-state h4 {
    font-size: 1.1rem;
    color: #666;
    margin-bottom: 0.35rem;
}

.ai-empty-state p {
    font-size: 0.85rem;
    line-height: 1.5;
    max-width: 280px;
}

/* Academic Results Overhaul */
.results-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.4rem;
    margin-top: 0.4rem;
}

.result-summary-card {
    background: white;
    border-radius: 12px;
    border: 1px solid #eee;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    padding: 12px 16px;
    margin-bottom: 0px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 110px;
}

.result-summary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: var(--primary-color);
}

.card-row-1 {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.session-text {
    font-size: 14px;
    color: #888;
    font-weight: 500;
}

.view-indicator {
    font-size: 14px;
    color: #ccc;
}

.card-row-2 {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
}

.term-name {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.class-badge {
    font-size: 13px;
    color: #666;
    display: flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.class-badge i {
    font-size: 14px;
    color: #999;
}

/* Modal Table Styles */
.result-table-wrapper {
    overflow-x: auto;
    margin-top: 1rem;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.result-detail-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: white;
}

.result-detail-table th {
    background: #f8f9fa;
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 2px solid #eee;
}

.result-detail-table td {
    padding: 1rem;
    border-bottom: 1px solid #eee;
    color: var(--text-primary);
}

.result-detail-table .bold {
    font-weight: 700;
}

.grade-a,
.grade-a\+ {
    color: #2e7d32;
    font-weight: 700;
}

.grade-b {
    color: #1976d2;
    font-weight: 700;
}

.grade-c {
    color: #f57c00;
    font-weight: 700;
}

.grade-f {
    color: #d32f2f;
    font-weight: 700;
}

.result-modal {
    max-width: 800px !important;
}

/* ===============================
   Result Summary Dashboard (Brief)
   =============================== */

.dashboard-modal-content {
    max-width: none !important;
    width: 99% !important;
    min-height: 99vh;
    height: auto !important;
    /* Flexible height for PDF generation */
    background-color: #f0faf4 !important;
    /* Light mint background */
    padding: 0 !important;
    overflow: visible !important;
    /* Ensure content isn't clipped */
    border-radius: 16px;
    color: #333;
    display: flex;
    flex-direction: column;
    margin: 0.5rem auto !important;
}

.dashboard-header {
    background: white;
    padding: 0.2rem 0.5rem;
    text-align: center;
    border-bottom: 2px solid #1b5e20;
    position: relative;
    min-height: 110px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.dashboard-header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    margin-bottom: 0.25rem;
    position: relative;
}

.school-crest {
    width: 95px;
    height: 95px;
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    overflow: hidden;
}

.student-photo {
    width: 90px;
    height: 90px;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    border: 2px solid #1b5e20;
    border-radius: 50%;
    overflow: hidden;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.student-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.student-photo i {
    font-size: 2.5rem;
    color: #ccc;
}

.school-info h1 {
    font-family: 'Georgia', serif;
    font-size: 1.2rem;
    color: #1b5e20;
    margin: 0;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.school-motto {
    font-style: italic;
    color: #444;
    margin: 0;
    font-size: 0.9rem;
}

.school-contact {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.5rem;
}

.dashboard-title-bar {
    background: white;
    padding: 0.2rem;
    text-align: center;
    border-bottom: 4px solid #1b5e20;
}

.dashboard-title-bar h2 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 800;
    color: #1b5e20;
    text-transform: uppercase;
}

.student-info-row {
    background: white;
    padding: 0.25rem 1rem;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #eee;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.info-item {
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}

.info-label {
    font-weight: 600;
    color: #2e7d32;
    font-size: 0.9rem;
}

.info-value {
    font-weight: 700;
    color: #1b5e20;
    font-size: 1rem;
}

.dashboard-body-grid {
    display: grid;
    grid-template-columns: 140px 450px 1fr;
    gap: 0.75rem;
    padding: 0.5rem;
    flex: 1;
    overflow: visible !important;
    /* Allow grid to expand parent */
    height: auto !important;
}

.dashboard-card {
    background: white;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0e0e0;
}

.card-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #444;
    margin-bottom: 1rem;
    text-align: center;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 0.5rem;
}

/* Left Column Stats */
.stats-column {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.stats-column .dashboard-card {
    padding: 0.5rem;
}

.stats-column .card-title {
    font-size: 0.7rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
}

.stat-metric {
    text-align: center;
}

.metric-label {
    font-size: 0.6rem;
    text-transform: uppercase;
    color: #666;
    display: block;
    margin-bottom: 0.15rem;
}

.metric-value-large {
    font-size: 1.2rem;
    font-weight: 800;
    color: #1b5e20;
    line-height: 1;
}

.metric-value-xlarge {
    font-size: 2.5rem;
    font-weight: 900;
    color: #1b5e20;
    line-height: 1;
    margin: 0.25rem 0;
}

.metric-subtitle {
    font-size: 0.7rem;
    font-weight: 700;
    color: #2e7d32;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.senior-grade-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 2px solid #e8f5e9;
    background: linear-gradient(to bottom, #ffffff, #f1f8e9) !important;
}

.progress-circle-container {
    width: 75px;
    height: 75px;
    margin: 4px auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.circle-content {
    position: absolute;
    font-weight: 700;
    font-size: 0.75rem;
    color: #1b5e20;
}

/* Center Column Charts */
.charts-column {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chart-container-large {
    height: 140px;
    width: 100%;
}

.chart-container-medium {
    height: 110px;
    width: 100%;
}

/* Right Column Subjects */
/* Right Column Subjects */
.subjects-column {
    display: block;
}

.subjects-column .dashboard-card {
    height: 100%;
    min-height: 520px;
}

.bar-chart-scroll {
    max-height: 550px;
    overflow-y: auto;
    padding-right: 0.5rem;
}

/* Mobile Adjustments */
@media (max-width: 1024px) {
    .dashboard-body-grid {
        grid-template-columns: 1fr;
        max-height: none;
        overflow-y: visible;
    }

    .subjects-column {
        grid-template-columns: 1fr;
    }

    .dashboard-modal-content {
        height: auto;
        border-radius: 0;
        width: 100vw !important;
    }

    .dashboard-header-top {
        gap: 1rem;
    }
}

/* Score Breakdown Table */
.table-responsive-dense {
    overflow-x: auto;
    max-height: 450px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.score-breakdown-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.6rem;
    text-align: center;
}

.score-breakdown-table th,
.score-breakdown-table td {
    padding: 2px 4px;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
}

.score-breakdown-table th {
    background-color: #f9f9f9;
    font-weight: 600;
    color: #1b5e20;
    position: sticky;
    top: 0;
    z-index: 1;
}

.score-breakdown-table td.text-left {
    text-align: left;
}

.score-breakdown-table td.font-bold {
    font-weight: 700;
    color: #333;
}

.col-subject {
    width: 25% !important; /* Reduced width */
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.grade-cell {
    background-color: rgba(27, 94, 32, 0.05);
    min-width: 40px;
}

/* Specific Grade Colors & Styles */
.grade-color-a1 { color: #006400 !important; font-weight: 700; } /* Excellent - Dark Green */
.grade-color-b2 { color: #1B5E20 !important; font-weight: 700; } /* Very Good - Strong Green */
.grade-color-b3 { color: #2F4F4F !important; font-weight: 700; } /* Very Good - Deep Teal-Green */
.grade-color-c4 { color: #556B2F !important; font-weight: 600; } /* Credit - Dark Olive */
.grade-color-c5 { color: #8B7500 !important; font-weight: 600; } /* Credit - Dark Goldenrod */
.grade-color-c6 { color: #6B4423 !important; font-weight: 400; } /* Credit - Brown */
.grade-color-d7 { color: #8B4000 !important; font-weight: 400; } /* Pass - Dark Orange */
.grade-color-e8 { color: #7B241C !important; font-weight: 700; } /* Pass - Brick Red */
.grade-color-f9 { color: #8B0000 !important; font-weight: 800; } /* Fail - Deep Red */

.mb-3 {
    margin-bottom: 1rem;
}

/* Utilities */
/* .no-print class is used to exclude elements from PDF/Print */

@media print {
    .no-print {
        display: none !important;
    }
}

.school-info h1 {
    font-size: 1.5rem;
}

/* Insight Bubble Styles */
.insight-bubble {
    position: fixed;
    bottom: 150px;
    right: 32px;
    width: 280px;
    background: white;
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    z-index: 2100;
    display: none;
    flex-direction: column;
    gap: 12px;
    border: 1px solid #f0f0f0;
    animation: bubble-up 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    transform-origin: bottom right;
}

.insight-bubble::after {
    content: '';
    position: absolute;
    bottom: -10px;
    right: 20px;
    width: 20px;
    height: 20px;
    background: white;
    transform: rotate(45deg);
    border-right: 1px solid #f0f0f0;
    border-bottom: 1px solid #f0f0f0;
}

.insight-bubble-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f5f5f5;
    padding-bottom: 8px;
}

.insight-bubble-header h4 {
    margin: 0;
    color: #2e7d32;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 6px;
}

.insight-bubble-content {
    font-size: 0.85rem;
    line-height: 1.5;
    color: #444;
    max-height: 350px;
    overflow-y: auto;
    padding-right: 4px;
}

.insight-bubble-content h3,
.insight-bubble-content h4,
.insight-bubble-content strong {
    color: #2e7d32;
    margin-top: 12px;
    margin-bottom: 4px;
    display: block;
}

.insight-bubble-content p {
    margin-bottom: 8px;
}

.insight-bubble-content ul {
    padding-left: 18px;
    margin-bottom: 8px;
}

.insight-bubble-content li {
    margin-bottom: 4px;
}

/* Scrollbar styling for the bubble */
.insight-bubble-content::-webkit-scrollbar {
    width: 4px;
}

.insight-bubble-content::-webkit-scrollbar-thumb {
    background: #e0e0e0;
    border-radius: 10px;
}

.insight-close-btn {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    transition: color 0.2s;
}

.insight-close-btn:hover {
    color: #666;
}

@keyframes bubble-up {
    from {
        opacity: 0;
        transform: scale(0.5) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@media (max-width: 480px) {
    .insight-bubble {
        bottom: 120px;
        right: 16px;
        left: 16px;
        width: auto;
        max-width: none;
    }

    .insight-bubble::after {
        right: 40px;
    }
}

@media (max-width: 364px) {
    .insight-bubble {
        bottom: 150px;
    }
}

/* Premium Locked Result Cards */
.result-summary-card.locked {
    opacity: 0.85;
    background: linear-gradient(135deg, #ffffff 0%, #f1f1f1 100%);
    border-left: 4px solid #bdae93;
    /* Desaturated gold */
    cursor: not-allowed;
    position: relative;
    overflow: hidden;
}

.result-summary-card.locked .view-indicator {
    color: #bdae93;
}

.result-summary-card.locked::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    pointer-events: none;
}

/* Premium Lock Tooltip (Glassmorphism) */
.premium-lock-tooltip {
    position: fixed;
    z-index: 5000;
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1), 0 5px 15px rgba(0, 0, 0, 0.05);
    padding: 1.25rem;
    border-radius: 16px;
    width: 320px;
    animation: premiumTooltipIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    pointer-events: auto;
}

.premium-lock-tooltip .tooltip-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #e65100;
    font-weight: 700;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

.premium-lock-tooltip .tooltip-header i {
    font-size: 1.1rem;
}

.premium-lock-tooltip .tooltip-body {
    color: #333;
    font-size: 0.9rem;
    line-height: 1.5;
}

.premium-lock-tooltip .debt-highlight {
    color: #d32f2f;
    font-weight: 700;
    background: rgba(211, 47, 47, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
}

.premium-lock-tooltip .tooltip-footer {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
    font-size: 0.75rem;
    color: #666;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

@keyframes premiumTooltipIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Tooltip Arrow */
.premium-lock-tooltip::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid rgba(255, 255, 255, 0.6);
}