/**
 * BIGKAS-AI - Application Stylesheet
 * Custom styles extending Bootstrap 5
 */

/* ============================================
   CSS VARIABLES / THEME
   ============================================ */
:root {
    --bigkas-primary: #1a73e8;
    --bigkas-primary-dark: #0d47a1;
    --bigkas-primary-light: #e8f0fe;
    --bigkas-success: #28a745;
    --bigkas-warning: #ffc107;
    --bigkas-danger: #dc3545;
    --bigkas-info: #17a2b8;
    --bigkas-gray: #6c757d;
    --bigkas-light: #f8f9fa;
    --bigkas-dark: #212529;
    --bigkas-body-bg: #f0f2f5;
    --bigkas-card-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --bigkas-card-hover-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    --bigkas-border-radius: 12px;
    --bigkas-transition: all 0.2s ease-in-out;
    --bigkas-font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* ============================================
   GLOBAL STYLES
   ============================================ */
body {
    font-family: var(--bigkas-font-family);
    background-color: var(--bigkas-body-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main {
    flex: 1;
}

/* App shell (admin/teacher/parent): navbar + sidebar stay fixed,
   only the main content area scrolls. */
body.app-shell {
    height: 100vh;
    overflow: hidden;
}

body.app-shell #wrapper {
    flex: 1 1 auto;
    min-height: 0;
}

body.app-shell #sidebar-wrapper,
body.app-shell #page-content-wrapper {
    height: 100%;
    overflow-y: auto;
}

body.app-shell #page-content-wrapper {
    min-width: 0;
}

a {
    text-decoration: none;
}

/* ============================================
   NAVBAR
   ============================================ */
.navbar {
    padding: 0.5rem 1rem;
}

.navbar-brand {
    font-size: 1.25rem;
    letter-spacing: -0.5px;
}

.navbar .nav-link {
    padding: 0.5rem 0.85rem;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    margin: 0 2px;
    transition: var(--bigkas-transition);
}

.navbar .nav-link:hover {
    background: rgba(255, 255, 255, 0.15);
}

.navbar .nav-link.active {
    background: rgba(255, 255, 255, 0.2);
    font-weight: 600;
}

.navbar .badge {
    font-size: 0.65rem;
    font-weight: 600;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    border-radius: var(--bigkas-border-radius);
    transition: var(--bigkas-transition);
}

.card.border-0 {
    box-shadow: var(--bigkas-card-shadow);
}

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

.card-header {
    border-radius: var(--bigkas-border-radius) var(--bigkas-border-radius) 0 0 !important;
}

.card-header h5 {
    font-size: 1rem;
}

/* Stat Cards */
.stat-card {
    text-align: center;
    padding: 1.5rem 1rem;
}

.stat-card .stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
    font-size: 1.5rem;
}

.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--bigkas-gray);
    margin-top: 0.25rem;
}

/* ============================================
   TABLES
   ============================================ */
.table {
    font-size: 0.9rem;
}

.table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--bigkas-gray);
    border-bottom-width: 1px;
}

.table td {
    vertical-align: middle;
    padding: 0.75rem;
}

.table-hover tbody tr:hover {
    background-color: var(--bigkas-primary-light);
}

/* ============================================
   BADGES & STATUS
   ============================================ */
.badge {
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.35em 0.65em;
    border-radius: 6px;
}

.badge-reading-level {
    padding: 0.4em 0.8em;
    font-size: 0.8rem;
}

.badge-independent {
    background-color: var(--bigkas-success) !important;
}

.badge-instructional {
    background-color: var(--bigkas-warning) !important;
    color: #212529 !important;
}

.badge-frustration {
    background-color: var(--bigkas-danger) !important;
}

/* Status badges */
.status-pending {
    background-color: #6c757d;
}
.status-recording {
    background-color: #fd7e14;
}
.status-processing {
    background-color: #17a2b8;
}
.status-completed {
    background-color: #28a745;
}
.status-failed {
    background-color: #dc3545;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    font-weight: 500;
    border-radius: 8px;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    transition: var(--bigkas-transition);
}

.btn-primary {
    background-color: var(--bigkas-primary);
    border-color: var(--bigkas-primary);
}

.btn-primary:hover {
    background-color: var(--bigkas-primary-dark);
    border-color: var(--bigkas-primary-dark);
    transform: translateY(-1px);
}

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

.btn-outline-primary:hover {
    background-color: var(--bigkas-primary);
    border-color: var(--bigkas-primary);
    transform: translateY(-1px);
}

.btn-sm {
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* Action buttons group */
.btn-group-actions .btn {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
}

/* ============================================
   FORMS
   ============================================ */
.form-control,
.form-select {
    border-radius: 8px;
    padding: 0.6rem 0.9rem;
    font-size: 0.9rem;
    border-color: #dee2e6;
    transition: var(--bigkas-transition);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--bigkas-primary);
    box-shadow: 0 0 0 0.2rem rgba(26, 115, 232, 0.2);
}

.form-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: #495057;
    margin-bottom: 0.35rem;
}

.form-text {
    font-size: 0.8rem;
}

.form-floating > .form-control:focus,
.form-floating > .form-select:focus {
    border-color: var(--bigkas-primary);
    box-shadow: 0 0 0 0.2rem rgba(26, 115, 232, 0.2);
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    border-radius: 10px;
    border: none;
    font-size: 0.9rem;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
}

/* ============================================
   BREADCRUMB
   ============================================ */
.breadcrumb {
    background: none;
    padding: 0;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}

.breadcrumb-item a {
    color: var(--bigkas-primary);
}

.breadcrumb-item.active {
    color: var(--bigkas-gray);
}

/* ============================================
   PAGE HEADER
   ============================================ */
.page-header {
    margin-bottom: 1.5rem;
}

.page-header h3 {
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.page-header .page-subtitle {
    color: var(--bigkas-gray);
    font-size: 0.9rem;
}

/* ============================================
   LEARNER CARD
   ============================================ */
.learner-card {
    border: none;
    border-radius: var(--bigkas-border-radius);
    overflow: hidden;
    transition: var(--bigkas-transition);
}

.learner-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--bigkas-card-hover-shadow);
}

.learner-card .learner-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bigkas-primary-light);
    color: var(--bigkas-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 700;
}

.learner-card .learner-info h6 {
    font-weight: 600;
    margin-bottom: 0.15rem;
}

.learner-card .learner-meta {
    font-size: 0.8rem;
    color: var(--bigkas-gray);
}

/* ============================================
   ASSESSMENT INTERFACE
   ============================================ */
.assessment-material {
    background: #fff;
    border: 2px solid #e9ecef;
    border-radius: var(--bigkas-border-radius);
    padding: 2rem;
    font-size: 1.2rem;
    line-height: 2;
    color: #333;
    max-height: 400px;
    overflow-y: auto;
}

.assessment-material.font-sm {
    font-size: 1rem;
    line-height: 1.8;
}

.assessment-material.font-lg {
    font-size: 1.5rem;
    line-height: 2.2;
}

.assessment-material.font-xl {
    font-size: 1.8rem;
    line-height: 2.4;
}

/* Recording Controls */
.recording-controls {
    text-align: center;
    padding: 1.5rem;
}

.btn-record {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    font-size: 1.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 3px solid;
    transition: var(--bigkas-transition);
}

.btn-record.recording {
    background-color: var(--bigkas-danger);
    border-color: var(--bigkas-danger);
    color: #fff;
    animation: pulse-recording 1.5s infinite;
}

@keyframes pulse-recording {
    0% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4); }
    70% { box-shadow: 0 0 0 15px rgba(220, 53, 69, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 53, 69, 0); }
}

.recording-timer {
    font-size: 1.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--bigkas-dark);
}

/* Audio Visualizer */
.audio-visualizer {
    width: 100%;
    height: 60px;
    background: var(--bigkas-light);
    border-radius: 8px;
    margin: 1rem 0;
}

/* ============================================
   RESULTS PAGE
   ============================================ */
.score-gauge {
    position: relative;
    width: 150px;
    height: 150px;
    margin: 0 auto;
}

.score-gauge .score-value {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2rem;
    font-weight: 700;
}

.result-metric {
    text-align: center;
    padding: 1rem;
}

.result-metric .metric-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.result-metric .metric-label {
    font-size: 0.8rem;
    color: var(--bigkas-gray);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Word comparison */
.word-comparison {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 1rem;
    font-size: 0.95rem;
    line-height: 2;
}

.word-comparison .word {
    padding: 2px 4px;
    border-radius: 4px;
    display: inline-block;
}

.word-comparison .word-correct {
    color: var(--bigkas-success);
}

.word-comparison .word-substituted {
    background-color: #fff3cd;
    color: #856404;
    text-decoration: line-through;
}

.word-comparison .word-omitted {
    background-color: #f8d7da;
    color: #721c24;
    text-decoration: line-through;
}

.word-comparison .word-inserted {
    background-color: #d1ecf1;
    color: #0c5460;
    border-bottom: 2px dashed var(--bigkas-info);
}

/* ============================================
   INTERVENTION CARDS
   ============================================ */
.intervention-card {
    border-left: 4px solid var(--bigkas-primary);
    border-radius: 0 var(--bigkas-border-radius) var(--bigkas-border-radius) 0;
    transition: var(--bigkas-transition);
}

.intervention-card:hover {
    transform: translateX(4px);
}

.intervention-card.priority-high {
    border-left-color: var(--bigkas-danger);
}

.intervention-card.priority-medium {
    border-left-color: var(--bigkas-warning);
}

.intervention-card.priority-low {
    border-left-color: var(--bigkas-success);
}

.intervention-card .weakness-badge {
    font-size: 0.7rem;
    padding: 0.3em 0.6em;
}

/* ============================================
   PRACTICE CENTER
   ============================================ */
.practice-card {
    border: none;
    border-radius: var(--bigkas-border-radius);
    overflow: hidden;
    cursor: pointer;
    transition: var(--bigkas-transition);
}

.practice-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--bigkas-card-hover-shadow);
}

.practice-card .practice-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 1rem;
}

.practice-card h5 {
    font-weight: 700;
    font-size: 1rem;
}

/* ============================================
   PROGRESS CHARTS
   ============================================ */
.progress-chart-container {
    position: relative;
    height: 300px;
}

.progress-timeline {
    position: relative;
    padding-left: 2rem;
}

.progress-timeline::before {
    content: '';
    position: absolute;
    left: 0.75rem;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #dee2e6;
}

.progress-timeline .timeline-item {
    position: relative;
    padding-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.progress-timeline .timeline-item::before {
    content: '';
    position: absolute;
    left: -0.55rem;
    top: 0.25rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--bigkas-primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--bigkas-primary);
}

/* ============================================
   REPORTS
   ============================================ */
.report-header {
    background: linear-gradient(135deg, var(--bigkas-primary), var(--bigkas-primary-dark));
    color: #fff;
    border-radius: var(--bigkas-border-radius);
    padding: 2rem;
    margin-bottom: 1.5rem;
}

.report-header h4 {
    font-weight: 700;
}

/* ============================================
   ADMIN PANEL
   ============================================ */
.admin-sidebar {
    background: #fff;
    border-radius: var(--bigkas-border-radius);
    box-shadow: var(--bigkas-card-shadow);
    padding: 1rem 0;
}

.admin-sidebar .nav-link {
    padding: 0.6rem 1.25rem;
    color: #495057;
    font-size: 0.9rem;
    font-weight: 500;
    border-left: 3px solid transparent;
    transition: var(--bigkas-transition);
}

.admin-sidebar .nav-link:hover {
    background: var(--bigkas-primary-light);
    color: var(--bigkas-primary);
}

.admin-sidebar .nav-link.active {
    color: var(--bigkas-primary);
    background: var(--bigkas-primary-light);
    border-left-color: var(--bigkas-primary);
    font-weight: 600;
}

/* ============================================
   LANDING PAGE
   ============================================ */
.hero-section {
    background: linear-gradient(135deg, var(--bigkas-primary) 0%, var(--bigkas-primary-dark) 100%);
    color: #fff;
    padding: 5rem 0;
    position: relative;
    overflow: hidden;
}

.hero-section::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bigkas-body-bg);
    clip-path: ellipse(55% 100% at 50% 100%);
}

.hero-section h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
}

.hero-section .lead {
    font-size: 1.15rem;
    opacity: 0.9;
    max-width: 600px;
}

.feature-card {
    text-align: center;
    padding: 2rem 1.5rem;
    border: none;
    border-radius: var(--bigkas-border-radius);
    transition: var(--bigkas-transition);
    height: 100%;
}

.feature-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--bigkas-card-hover-shadow);
}

.feature-card .feature-icon {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    margin: 0 auto 1rem;
}

/* ============================================
   FOOTER
   ============================================ */
footer {
    margin-top: auto;
}

footer small {
    font-size: 0.8rem;
}

/* ============================================
   MODAL OVERRIDES
   ============================================ */
.modal-content {
    border-radius: var(--bigkas-border-radius);
    border: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.modal-header {
    border-radius: var(--bigkas-border-radius) var(--bigkas-border-radius) 0 0;
}

/* ============================================
   PAGINATION
   ============================================ */
.pagination .page-link {
    border-radius: 8px;
    margin: 0 2px;
    border: none;
    color: var(--bigkas-primary);
    font-weight: 500;
    font-size: 0.85rem;
}

.pagination .page-item.active .page-link {
    background-color: var(--bigkas-primary);
    border-color: var(--bigkas-primary);
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
}

.empty-state .empty-icon {
    font-size: 4rem;
    color: #dee2e6;
    margin-bottom: 1rem;
}

.empty-state h5 {
    font-weight: 600;
    color: var(--bigkas-gray);
}

.empty-state p {
    color: #adb5bd;
    font-size: 0.9rem;
}

/* ============================================
   LOADING / SPINNER
   ============================================ */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    flex-direction: column;
}

.loading-overlay .spinner-border {
    width: 3rem;
    height: 3rem;
    color: var(--bigkas-primary);
}

.loading-overlay p {
    margin-top: 1rem;
    font-weight: 500;
    color: var(--bigkas-gray);
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-bigkas-primary {
    color: var(--bigkas-primary) !important;
}

.bg-bigkas-primary {
    background-color: var(--bigkas-primary) !important;
}

.bg-bigkas-light {
    background-color: var(--bigkas-primary-light) !important;
}

.rounded-bigkas {
    border-radius: var(--bigkas-border-radius) !important;
}

.shadow-bigkas {
    box-shadow: var(--bigkas-card-shadow) !important;
}

.fw-semibold {
    font-weight: 600 !important;
}

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cursor-pointer {
    cursor: pointer;
}

/* Gap utilities for older browsers */
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 1rem; }
.gap-4 { gap: 1.5rem; }

/* ============================================
   PRINT STYLES
   ============================================ */
@media print {
    .navbar,
    .btn,
    footer,
    .no-print {
        display: none !important;
    }

    .card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
    }

    body {
        background: #fff !important;
    }

    .report-header {
        background: #333 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ============================================
   RESPONSIVE OVERRIDES
   ============================================ */
@media (max-width: 768px) {
    .hero-section {
        padding: 3rem 0;
    }

    .hero-section h1 {
        font-size: 1.8rem;
    }

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

    .assessment-material {
        font-size: 1rem;
        padding: 1rem;
        line-height: 1.8;
    }

    .recording-controls .btn-record {
        width: 64px;
        height: 64px;
        font-size: 1.2rem;
    }

    .result-metric .metric-value {
        font-size: 1.3rem;
    }

    .table-responsive {
        font-size: 0.8rem;
    }
}

@media (max-width: 576px) {
    .page-header h3 {
        font-size: 1.25rem;
    }

    .card-body {
        padding: 1rem;
    }

    .btn {
        font-size: 0.85rem;
    }
}

/* ============================================
   PAGINATION (large, touch-friendly)
   ============================================ */
.bigkas-pager__list {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.bigkas-pager__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 46px;
    height: 46px;
    padding: 0 14px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--bigkas-primary);
    background: #fff;
    border: 1px solid #d0d7e2;
    border-radius: 10px;
    box-shadow: var(--bigkas-card-shadow);
    transition: var(--bigkas-transition);
}

.bigkas-pager__btn--wide {
    padding: 0 18px;
}

a.bigkas-pager__btn:hover {
    background: var(--bigkas-primary-light);
    border-color: var(--bigkas-primary);
}

.bigkas-pager__btn.is-active {
    color: #fff;
    background: var(--bigkas-primary);
    border-color: var(--bigkas-primary);
}

.bigkas-pager__btn.is-disabled {
    color: #9aa3b0;
    background: #f1f3f6;
    box-shadow: none;
    cursor: not-allowed;
}

.bigkas-pager__gap {
    color: var(--bigkas-gray);
    padding: 0 4px;
}

/* ============================================
   SIDEBAR HAMBURGER (below 992px the sidebar slides over the page)
   ============================================ */
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
    body.app-shell #sidebar-wrapper {
        position: fixed;
        top: 56px;
        bottom: 0;
        left: 0;
        height: auto !important;
        width: 270px !important;
        min-width: 0 !important;
        max-width: 85vw !important;
        z-index: 1045;
        transform: translateX(-100%);
        transition: transform .25s ease-out;
        overflow-y: auto;
    }
    body.sidebar-open #sidebar-wrapper { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop {
        display: block;
        position: fixed;
        inset: 56px 0 0 0;
        background: rgba(0, 0, 0, .45);
        z-index: 1040;
    }
    body.sidebar-open { overflow: hidden; }
    .navbar form[role="search"] { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
    body.app-shell #sidebar-wrapper { transition: none; }
}
