/**
 * GarudaCBT Responsive & Accessibility Fixes
 * Enhanced responsiveness for Admin, Guru, Siswa
 * Accessible touch targets, smooth scrolling, contrast, responsive layouts
 */

/* ==========================================================================
   1. Accessibility & Focus Indicators (WCAG 2.1 AA)
   ========================================================================== */
:focus-visible {
    outline: 2.5px solid #007bff !important;
    outline-offset: 2px !important;
}

/* Ensure legible color contrasts */
.badge-warning {
    color: #212529 !important;
    background-color: #ffc107 !important;
}

.badge-info {
    color: #ffffff !important;
    background-color: #17a2b8 !important;
}

/* Screen reader only utility if missing */
.sr-only-focusable:active,
.sr-only-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ==========================================================================
   2. Touch Target Sizes & Interactive Elements (WCAG 2.5.5)
   ========================================================================== */
@media (max-width: 768px) {
    /* Touch target for buttons */
    .btn {
        min-height: 42px;
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .btn-sm {
        min-height: 36px;
        padding-top: 6px;
        padding-bottom: 6px;
    }

    /* Form controls */
    .form-control,
    .custom-select,
    select.form-control {
        min-height: 42px;
        font-size: 15px;
    }

    /* Pagination items */
    .pagination .page-link {
        min-width: 42px;
        min-height: 42px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
    }

    /* Modal dialogs on mobile */
    .modal-dialog {
        margin: 0.5rem;
        max-width: calc(100% - 1rem) !important;
    }

    /* Nav tabs scroll horizontally on small screens */
    .nav-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        border-bottom: 2px solid #dee2e6;
        padding-bottom: 2px;
    }

    .nav-tabs .nav-item {
        flex: 0 0 auto;
        white-space: nowrap;
    }

    .nav-tabs .nav-link {
        min-height: 42px;
        padding: 8px 14px;
        font-size: 14px;
    }

    /* Admin & Guru filter columns spacing */
    .card-header .row > div,
    .card-body .row > div {
        margin-bottom: 6px;
    }
}

/* ==========================================================================
   3. Responsive Tables & DataTables
   ========================================================================== */
.table-responsive {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
    max-width: 100%;
}

/* Visual cue for horizontally scrollable tables on touch devices */
@media (max-width: 768px) {
    .table-responsive {
        border-radius: 4px;
        box-shadow: inset -5px 0 8px -4px rgba(0, 0, 0, 0.15);
    }
    
    .table td, .table th {
        padding: 0.5rem 0.4rem;
        font-size: 13.5px;
    }

    .dataTables_wrapper .row {
        margin-left: 0;
        margin-right: 0;
    }

    .dataTables_wrapper .dataTables_paginate {
        margin-top: 10px;
        text-align: center !important;
    }
}

/* ==========================================================================
   4. Siswa / Student Exam UI Accessibility & Responsiveness
   ========================================================================== */
/* Question container responsive */
#konten-soal img,
.konten-soal-jawab img {
    max-width: 100% !important;
    height: auto !important;
    object-fit: contain;
}

#konten-soal table {
    max-width: 100% !important;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Multiple choice answer container */
.container-jawaban {
    min-height: 46px;
    display: flex;
    align-items: center;
    position: relative;
    padding-left: 45px;
    cursor: pointer;
    margin-bottom: 12px;
    user-select: none;
    -webkit-user-select: none;
}

/* Checkboxes and radios for question types */
.custom-checkbox.checkbox-xl .custom-control-label {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    padding-top: 4px;
    padding-bottom: 4px;
    cursor: pointer;
}

/* Menjodohkan (Matching) items touch sizing */
.jodohkan li,
.linker-list li {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 8px 12px;
    font-size: 14.5px;
    touch-action: manipulation;
}

/* Exam navigation buttons and footer */
@media (max-width: 768px) {
    .card-header {
        padding: 0.75rem 0.5rem !important;
    }

    .card-header .card-title {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }

    .card-header .card-tools {
        float: none !important;
        display: flex;
        justify-content: space-between;
        width: 100%;
        margin-top: 0.5rem;
    }

    .card-tools .btn {
        flex: 1;
        margin: 0 4px;
        min-height: 42px;
        font-size: 13px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .card-footer .bd-highlight {
        flex: 1;
    }

    .card-footer .bd-highlight .btn {
        width: 100%;
        min-height: 46px;
        font-size: 14px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .card-footer .d-flex {
        gap: 10px;
    }

    /* Modal daftar soal buttons on mobile */
    #konten-modal .btn {
        min-width: 44px;
        min-height: 44px;
        margin: 3px;
        font-size: 15px;
        font-weight: bold;
    }
}

/* ==========================================================================
   5. Alokasi Waktu & Bank Soal Bobot Mobile Enhancements
   ========================================================================== */
.table-alokasi-waktu td input[type="time"] {
    min-width: 110px;
}

.table-alokasi-waktu th,
.table-alokasi-waktu td {
    vertical-align: middle !important;
}

.input-bobot {
    min-width: 75px;
    max-width: 100px;
    text-align: center;
}

@media (max-width: 576px) {
    .input-bobot {
        width: 100% !important;
        max-width: 100% !important;
    }
}

/* ==========================================================================
   6. Super-Responsive Dashboard (Admin & Guru)
   Prefix: .dash-*
   ========================================================================== */

/* Hero Banner */
.dash-hero {
    min-height: 240px;
    background-size: cover !important;
    background-position: center bottom !important;
    background-repeat: no-repeat !important;
    display: flex;
    align-items: flex-end;
    padding: 0;
}

.dash-hero-overlay {
    background-color: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(2px);
    width: 100%;
    padding: 1.25rem 0.75rem 0.5rem 0.75rem;
}

@media (max-width: 767.98px) {
    .dash-hero {
        min-height: 140px;
    }
    .dash-hero-overlay {
        padding: 0.75rem 0.5rem 0.25rem 0.5rem;
    }
}

/* Stat Info Box */
.dash-stat-box {
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    margin-bottom: 0.75rem;
}

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

.dash-stat-box .inner {
    padding: 0.65rem 0.75rem;
}

.dash-stat-box .inner h5 {
    font-size: 1.25rem;
    margin-bottom: 0.1rem;
    line-height: 1.2;
}

.dash-stat-box .inner span {
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.dash-stat-box .icon {
    top: 6px;
    right: 10px;
    font-size: 38px;
    opacity: 0.35;
    transition: all 0.3s linear;
}

.dash-stat-box .small-box-footer {
    padding: 4px 0;
    font-size: 0.75rem;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 575.98px) {
    .dash-stat-box .inner h5 {
        font-size: 1.1rem;
    }
    .dash-stat-box .inner span {
        font-size: 0.72rem;
    }
    .dash-stat-box .icon {
        font-size: 26px;
        top: 8px;
        right: 8px;
    }
}

/* Horizontal Scrollable Tabs with Gradient Fade Indicator */
.dash-tab-wrapper {
    position: relative;
    overflow: hidden;
    border-bottom: 1px solid #e9ecef;
}

.dash-tab-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 28px;
    background: linear-gradient(to right, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.95));
    pointer-events: none;
    z-index: 2;
}

.dash-scrollable-tabs {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    padding: 6px 8px 4px 8px;
    margin: 0;
}

.dash-scrollable-tabs::-webkit-scrollbar {
    height: 4px;
}

.dash-scrollable-tabs::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

.dash-scrollable-tabs .nav-item {
    flex: 0 0 auto;
    margin-right: 6px;
}

.dash-scrollable-tabs .nav-link {
    padding: 6px 12px;
    font-size: 0.82rem;
    border-radius: 20px;
    white-space: nowrap;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
}

/* Card-List Pattern for Penilaian Table on Mobile (< 768px) */
@media (max-width: 767.98px) {
    .dash-card-table {
        border: none !important;
    }

    .dash-card-table thead {
        display: none !important;
    }

    .dash-card-table tbody,
    .dash-card-table tr {
        display: block !important;
        width: 100% !important;
    }

    .dash-card-table tr {
        background: #ffffff;
        border: 1px solid #e2e8f0 !important;
        border-radius: 8px;
        margin-bottom: 0.75rem;
        padding: 0.65rem 0.75rem;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    }

    .dash-card-table td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 0.35rem 0 !important;
        border: none !important;
        border-bottom: 1px dashed #edf2f7 !important;
        font-size: 0.85rem !important;
        text-align: right !important;
    }

    .dash-card-table td:last-child {
        border-bottom: none !important;
    }

    .dash-card-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #4a5568;
        text-align: left;
        margin-right: 0.75rem;
        font-size: 0.78rem;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .dash-card-table td[data-label="NO"] {
        display: none !important;
    }

    .dash-card-table td[data-label="PENGAWAS"] {
        flex-direction: column !important;
        align-items: flex-end !important;
    }
}

/* Token Box Styling */
.dash-token-card {
    border: 1px solid #ffccd5;
    background: #fff8f8;
    border-radius: 6px;
    padding: 6px 10px;
    min-height: 64px;
}

.dash-token-val {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: #dc3545;
}

.btn-copy-token {
    min-height: 32px;
    min-width: 32px;
    padding: 2px 8px;
    font-size: 0.78rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}
