/* ================================================================
   Progress Pulse – Responsive Stylesheet
   Mobile-first design, tested from 320px → 1400px+
   ================================================================ */

/* Reset and Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    /* Prevent iOS font size inflation on orientation change */
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: #f5f7fa;
    color: #2d3748;
    line-height: 1.6;
    min-height: 100vh;
    /* Prevent horizontal scroll on mobile */
    overflow-x: hidden;
}

/* ================================================================
   Navigation – Bootstrap 5 handles the hamburger; we just style
   ================================================================ */
.navbar {
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
}

/* Ensure toggler is easy to tap on mobile */
.navbar-toggler {
    padding: 8px 10px;
    border: 2px solid rgba(255,255,255,.4);
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 3px rgba(255,255,255,.25);
}

/* Logo text */
.navbar-brand span {
    font-weight: 700;
    letter-spacing: 0.4px;
}

/* Nav links – tappable on mobile */
.nav-link {
    padding: 10px 14px !important;
    font-weight: 600;
    border-radius: 6px;
    transition: background 0.15s;
}

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

/* Dropdown items */
.dropdown-menu {
    background-color: #ffffff !important;
    border: 1px solid rgba(0,0,0,.12);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,.12);
    min-width: 180px;
}

.dropdown-item {
    color: #212529 !important;
    padding: 10px 16px;
    font-size: 14px;
    transition: background 0.12s;
}

.dropdown-item:hover,
.dropdown-item:focus {
    color: #2c5aa0 !important;
    background-color: #f0f4f8 !important;
}

.dropdown-item.disabled {
    color: #6c757d !important;
    pointer-events: none;
}

.dropdown-divider {
    border-top: 1px solid rgba(0,0,0,.1);
}

/* Breadcrumb */
.breadcrumb-nav {
    background-color: #f8f9fa;
    padding: 10px 16px;
    border-bottom: 1px solid #dee2e6;
    margin: 0;
}

.breadcrumb {
    margin-bottom: 0;
    background-color: transparent;
    padding: 0;
    flex-wrap: wrap;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "›";
    color: #6c757d;
    padding: 0 6px;
}

.breadcrumb-item a {
    color: #2c5aa0;
    text-decoration: none;
}

.breadcrumb-item a:hover {
    text-decoration: underline;
    color: #1e3a8a;
}

.breadcrumb-item.active {
    color: #6c757d;
}

/* ================================================================
   Layout
   ================================================================ */
/* Bootstrap's .container and .container-fluid are used in the pages.
   We just tune the padding for small screens. */
.container,
.container-fluid {
    padding-left: 16px;
    padding-right: 16px;
}

@media (min-width: 576px) {
    .container,
    .container-fluid {
        padding-left: 24px;
        padding-right: 24px;
    }
}

/* ================================================================
   Typography
   ================================================================ */
h1, h2, h3, h4, h5, h6 {
    margin-top: 0;
    color: #1a202c;
}

h1 {
    font-size: clamp(22px, 5vw, 36px);
    font-weight: 700;
    margin-bottom: 16px;
    color: #2c5aa0;
}

h2 {
    font-size: clamp(18px, 4vw, 28px);
    font-weight: 600;
    margin-bottom: 16px;
    color: #2d3748;
}

h3 {
    font-size: clamp(16px, 3vw, 22px);
    font-weight: 600;
    color: #2d3748;
}

/* ================================================================
   Grid Layout
   ================================================================ */
.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 16px;
}

@media (min-width: 576px) {
    .grid {
        grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
        gap: 20px;
        margin-top: 20px;
    }
}

/* ================================================================
   Cards
   ================================================================ */
.card {
    background: #fff;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    transition: box-shadow 0.2s, transform 0.2s, border-color 0.2s;
    border: 1px solid #e5e7eb;
}
/* Allow Bootstrap's p-0 utility to override the global card padding */
.card.p-0 { padding: 0 !important; overflow: hidden; }
/* card-body padding override for tables */
.card-body[style*="padding:0"] { padding: 0 !important; }

@media (min-width: 576px) {
    .card {
        padding: 24px;
    }
}

/* Only lift cards on non-touch devices to avoid sticky hover on mobile */
@media (hover: hover) {
    .card:hover {
        box-shadow: 0 4px 16px rgba(0,0,0,.12);
        transform: translateY(-2px);
        border-color: #2c5aa0;
    }
}

.card a:not(.btn):not(button a) {
    color: #2c5aa0;
    text-decoration: none;
    font-weight: 600;
    font-size: 16px;
}

.card a:not(.btn):not(button a):hover {
    text-decoration: underline;
    color: #1e3a8a;
}

/* Force white text only on solid (non-outline) anchor buttons */
a.btn-primary,
a.btn-secondary,
a.btn-success,
a.btn-danger,
a.btn-warning,
a.btn-info,
.card a.btn-primary,
.card a.btn-secondary,
.card a.btn-success,
.card a.btn-danger,
.card a.btn-warning,
.card a.btn-info {
    color: #fff !important;
    text-decoration: none !important;
}

/* Outline anchor buttons: keep their colored text, fill on hover */
a.btn-outline-primary  { color: #2c5aa0 !important; text-decoration: none !important; }
a.btn-outline-secondary { color: #6b7280 !important; text-decoration: none !important; }
a.btn-outline-success  { color: #059669 !important; text-decoration: none !important; }
a.btn-outline-danger   { color: #ef4444 !important; text-decoration: none !important; }
a.btn-outline-warning  { color: #d97706 !important; text-decoration: none !important; }
a.btn-outline-info     { color: #0369a1 !important; text-decoration: none !important; }
a.btn-outline-primary:hover,  .card a.btn-outline-primary:hover  { color: #fff !important; }
a.btn-outline-secondary:hover,.card a.btn-outline-secondary:hover { color: #fff !important; }
a.btn-outline-success:hover,  .card a.btn-outline-success:hover  { color: #fff !important; }
a.btn-outline-danger:hover,   .card a.btn-outline-danger:hover   { color: #fff !important; }
a.btn-outline-warning:hover,  .card a.btn-outline-warning:hover  { color: #fff !important; }
a.btn-outline-info:hover,     .card a.btn-outline-info:hover     { color: #fff !important; }

/* ================================================================
   Forms
   ================================================================ */
form {
    background: #fff;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    margin-bottom: 20px;
    border: 1px solid #e5e7eb;
}

@media (min-width: 576px) {
    form {
        padding: 24px;
    }
}

/* Larger touch targets on inputs */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid #cbd5e0;
    border-radius: 8px;
    font-size: 16px; /* 16px prevents iOS zoom on focus */
    font-family: inherit;
    margin-bottom: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
    /* Remove iOS default styling */
    -webkit-appearance: none;
    appearance: none;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #2c5aa0;
    box-shadow: 0 0 0 3px rgba(44, 90, 160, 0.1);
}

/* Restore select arrow after -webkit-appearance reset */
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

/* ================================================================
   Buttons – minimum 44px tap target height on mobile
   ================================================================ */
button,
.btn {
    padding: 12px 22px;
    background: #2c5aa0;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s, box-shadow 0.2s;
    font-family: inherit;
    box-shadow: 0 2px 4px rgba(44, 90, 160, 0.2);
    min-height: 44px; /* WCAG touch target */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    /* Prevent double-tap zoom on mobile */
    touch-action: manipulation;
}

@media (hover: hover) {
    button:hover,
    .btn:hover {
        background: #1e3a8a;
        transform: translateY(-1px);
        box-shadow: 0 4px 8px rgba(44, 90, 160, 0.3);
    }
}

button:active,
.btn:active {
    transform: translateY(0);
    box-shadow: none;
}

/* ================================================================
   Tables – wrap in .table-responsive for mobile scrolling
   Bootstrap's .table-responsive is already used in several pages.
   These styles handle the custom table class too.
   ================================================================ */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 12px;
}

table {
    width: 100%;
    min-width: 480px; /* Prevent table from squishing below readable width */
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    border: 1px solid #e5e7eb;
    border-collapse: collapse;
}

th {
    background: #2c5aa0;
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    color: #fff;
    border-bottom: 2px solid #1e3a8a;
    font-size: 14px;
    white-space: nowrap;
}

/* Inline-styled th elements (modals, custom tables) override the global dark header */
th[style] {
    background: revert;
    color: revert;
    border-bottom: revert;
}

td {
    padding: 12px 14px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
    vertical-align: middle;
}

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

@media (hover: hover) {
    tr:hover {
        background: #f7fafc;
    }
}

/* Standalone table (not inside .table-responsive) auto-wraps */
table:not(.table-responsive table) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ================================================================
   Global image safety — prevents any image from ever overflowing
   ================================================================ */
img {
    max-width: 100%;
    height: auto;
}

/* ================================================================
   Login / Register
   ================================================================ */
.auth-container {
    width: calc(100% - 24px);
    max-width: 440px;
    margin: 20px auto;
    padding: 20px 16px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
    border: 1px solid #e5e7eb;
    overflow: hidden; /* Contain the logo image within the rounded box */
}

@media (min-width: 480px) {
    .auth-container {
        width: 100%;
        margin: 48px auto;
        padding: 36px 32px;
    }
}

.auth-container h2 {
    text-align: center;
    margin-bottom: 28px;
    color: #2c5aa0;
    font-size: clamp(22px, 5vw, 32px);
}

.auth-container form {
    box-shadow: none;
    padding: 0;
    border: none;
}

.auth-container button {
    width: 100%;
    padding: 14px;
    margin-top: 10px;
    font-size: 16px;
}

.auth-container p {
    text-align: center;
    margin-top: 20px;
    color: #4a5568;
    font-weight: 500;
}

.auth-container a {
    color: #2c5aa0;
    text-decoration: none;
    font-weight: 600;
}

.auth-container a:hover {
    text-decoration: underline;
}

.auth-container p a {
    color: #2c5aa0;
}

.auth-container p a:hover {
    color: #1e3a8a;
}

/* Logo inside auth box */
.auth-logo {
    text-align: center;
    margin-bottom: 10px;
    padding: 20px 16px 0;
}

.auth-logo img {
    display: block !important;
    width: auto !important;
    height: auto !important;
    max-width: 220px !important;
    max-height: 160px;
    object-fit: contain;
    margin: 0 auto;
}

@media (min-width: 480px) {
    .auth-logo {
        padding: 28px 24px 0;
    }
    .auth-logo img {
        max-width: 260px !important;
    }
}

/* ================================================================
   Assessment Testing – Teachers use this on tablets and phones.
   Large, easy-to-tap buttons. Big readable item display.
   ================================================================ */
#assessment-area {
    margin-top: 24px;
}

.assessment-item {
    background: #fff;
    padding: 32px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
    text-align: center;
    margin-bottom: 20px;
    border: 2px solid #2c5aa0;
}

@media (min-width: 576px) {
    .assessment-item {
        padding: 48px 40px;
    }
}

/* The assessment item value – teachers hold phone/tablet at arm's length */
.assessment-item h3 {
    font-size: clamp(48px, 15vw, 96px);
    margin: 16px 0;
    color: #1a202c;
    font-weight: 700;
    line-height: 1.1;
}

.assessment-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 28px;
    flex-wrap: wrap;
}

/* Correct / Incorrect buttons – need to be large and well-spaced on touch */
.btn-correct,
.btn-incorrect {
    flex: 1 1 140px;
    max-width: 220px;
    padding: 18px 24px;
    font-size: clamp(17px, 4vw, 22px);
    font-weight: 700;
    min-height: 64px;
    border-radius: 12px;
    touch-action: manipulation;
}

.btn-correct {
    background: #10b981;
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

.btn-correct:hover {
    background: #059669;
    box-shadow: 0 6px 12px rgba(16, 185, 129, 0.4);
}

.btn-incorrect {
    background: #ef4444;
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

.btn-incorrect:hover {
    background: #dc2626;
    box-shadow: 0 6px 12px rgba(239, 68, 68, 0.4);
}

.btn-correct:disabled,
.btn-incorrect:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.btn-correct:disabled:hover,
.btn-incorrect:disabled:hover,
.btn-correct:disabled:active,
.btn-incorrect:disabled:active {
    background: inherit;
    transform: none !important;
    box-shadow: none !important;
}

/* Two-machine session code display */
.session-code {
    font-size: clamp(32px, 8vw, 56px);
    font-weight: 800;
    letter-spacing: 8px;
    color: #2c5aa0;
    padding: 12px 0;
}

/* Session controls flex layout */
.session-controls-header {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.connection-status {
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}

.status-connected {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.status-waiting {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* Progress Indicators */
.progress-bar {
    width: 100%;
    height: 10px;
    background: #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 24px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}

.progress-fill {
    height: 100%;
    background: #10b981;
    transition: width 0.4s ease;
}

/* Alerts and Messages */
.alert {
    padding: 14px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
    font-size: 15px;
    border: 1px solid;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-color: #6ee7b7;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-color: #93c5fd;
}

/* ================================================================
   Alerts
   ================================================================ */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-weight: 500;
    font-size: 14px;
    border: 1px solid;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border-color: #6ee7b7;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border-color: #93c5fd;
}

/* ================================================================
   Page-level action bars (header + button row)
   ================================================================ */
.page-header {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.page-header h1 {
    margin-bottom: 0;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* ================================================================
   Dashboard stat cards
   ================================================================ */
.stat-card h2,
.card-body h2 {
    font-size: clamp(28px, 7vw, 44px);
    color: #2c5aa0;
    margin-bottom: 4px;
    line-height: 1;
}

/* ================================================================
   Class card component (teacher dashboard)
   ================================================================ */
.class-card {
    border: 1px solid #dee2e6;
    border-radius: 10px;
    padding: 16px;
    background: #f8f9fa;
    height: 100%;
}

.class-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.class-header h5 {
    margin: 0;
    font-size: 16px;
}

.class-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.class-stats .stat {
    display: flex;
    flex-direction: column;
}

.class-stats .stat strong {
    font-size: 1.5rem;
    color: #2c5aa0;
    line-height: 1;
}

.class-stats .stat span {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 2px;
}

.class-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* On very small screens, class action buttons go full-width */
@media (max-width: 400px) {
    .class-actions {
        flex-direction: column;
    }
    .class-actions .btn,
    .class-actions a {
        width: 100%;
        text-align: center;
    }
}

/* ================================================================
   Filter rows – stack vertically on mobile
   ================================================================ */
.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 20px;
}

.filter-row .filter-item {
    flex: 1 1 160px;
    min-width: 0;
}

.filter-row .filter-item label {
    display: block;
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
    color: #4a5568;
}

/* ================================================================
   Mobile-specific overrides
   ================================================================ */
@media (max-width: 575px) {
    /* Stack "d-flex justify-content-between" headers on tiny screens */
    .d-flex.justify-content-between {
        flex-wrap: wrap;
        gap: 10px;
    }

    /* Action buttons in table cells – stack them */
    td .btn,
    td button,
    td a.btn {
        margin-bottom: 4px;
        font-size: 13px;
        padding: 8px 12px;
    }

    /* Auth container tight padding */
    .auth-container {
        margin: 16px;
        padding: 20px 16px;
    }

    /* Remove excessive padding from containers */
    .container,
    .container-fluid {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* Make Bootstrap card headers stack */
    .card-header.d-flex {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Make form filter rows full-width */
    .row.g-3 .col-md-4,
    .row.g-3 .col-md-6,
    .row.g-3 .col-md-8 {
        flex: 0 0 100%;
        max-width: 100%;
    }

    /* Session code smaller on tiny phones */
    .session-code {
        letter-spacing: 4px;
    }
}

/* ================================================================
   Tablet (576px–991px) tweaks
   ================================================================ */
@media (min-width: 576px) and (max-width: 991px) {
    /* Tables that don't have table-responsive wrapper yet */
    .card table:not(.table) {
        display: block;
        overflow-x: auto;
    }

    .assessment-item h3 {
        font-size: clamp(56px, 12vw, 80px);
    }
}

/* ================================================================
   Landscape tablet / small laptop (992px+)
   ================================================================ */
@media (min-width: 992px) {
    .container {
        padding-left: 24px;
        padding-right: 24px;
    }

    .assessment-item {
        padding: 64px 48px;
    }
}

/* ================================================================
   Touch-specific: give interactive items more breathing room
   ================================================================ */
@media (pointer: coarse) {
    /* Ensure all links and buttons have min tap target */
    a,
    button,
    .btn,
    .nav-link,
    .dropdown-item {
        min-height: 44px;
    }

    /* Bigger select on touch */
    select {
        min-height: 48px;
    }

    /* Remove hover-only card lifts */
    .card:hover {
        transform: none;
    }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

/* Modal Close Button — consistent across Bootstrap modals and pp-modals */
.modal-header .btn-close,
.pp-modal-header .btn-close,
.btn-close {
    background-color: transparent;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23374151'%3e%3cpath d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 0.875em;
    opacity: 0.7;
    border-radius: 6px;
    padding: 0;
    width: 2rem;
    height: 2rem;
    border: none;
    flex-shrink: 0;
    cursor: pointer;
    transition: opacity 0.15s;
}
.modal-header .btn-close:hover,
.pp-modal-header .btn-close:hover,
.btn-close:hover {
    opacity: 1;
    background-color: transparent !important;
    border-color: transparent !important;
    transform: none !important;
}

/* Alert/Banner Close Button Fix */
.alert .btn-close {
    padding: 0.25rem 0.5rem;
    width: auto;
    height: auto;
    align-self: flex-start;
    margin-top: -0.25rem;
    margin-bottom: -0.25rem;
}

/* Nav Link Active Color */
.nav-link.active {
    color: #000 !important;
    font-weight: 600;
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

/* ================================================================
   MODALS — Consistent Look & Feel (items 6, 7, 8)
   All modals share the same visual language:
   - White card, 16px border-radius, max-width 560px (md) or 800px (lg)
   - Header: white bg, bottom border, h5 title, close button top-right
   - Body: 24px padding
   - Footer: white bg, top border, right-aligned action buttons
   ================================================================ */

/* ── Bootstrap modal baseline overrides ── */
.modal-content {
    border: none;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    overflow: hidden;
}

.modal-header {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: 18px 24px;
    border-radius: 16px 16px 0 0;
}

.modal-header .modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1f2937;
}

.modal-header .modal-subtitle {
    font-size: 13px;
    color: #6b7280;
    margin-top: 2px;
}

.modal-body {
    padding: 20px 24px;
    background: #fff;
}

.modal-footer {
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
    padding: 14px 24px;
    border-radius: 0 0 16px 16px;
    gap: 8px;
}

/* ── Custom overlay modals (non-Bootstrap, position:fixed) ── */
.pp-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.55);
    z-index: 2000;
    padding: 16px;
    /* Force new stacking context for reliable fixed positioning */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    /* Overflow so tall modals are scrollable */
    overflow-y: auto;
    /* Center the modal box */
    -webkit-box-sizing: border-box;
    box-sizing: border-box;
}

/* JS opens modals by setting style.display — class .active is also supported */
.pp-modal-overlay.pp-modal-open,
.pp-modal-overlay.active {
    display: flex !important;
    align-items: flex-start;
    justify-content: center;
}

/* Vertically center when content is short enough */
.pp-modal-overlay.pp-modal-open::before,
.pp-modal-overlay.active::before {
    content: '';
    display: block;
    height: auto;
    min-height: calc(50% - 280px);
    flex-shrink: 0;
}

.pp-modal-box {
    background: #fff;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow: hidden;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    display: flex;
    flex-direction: column;
}

.pp-modal-box.pp-modal-lg {
    max-width: 800px;
}

.pp-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 18px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 1;
    flex-shrink: 0;
}

.pp-modal-header h5,
.pp-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1f2937;
}

.pp-modal-header p {
    margin: 4px 0 0;
    font-size: 13px;
    color: #6b7280;
}

.pp-modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1 1 auto;
}

.pp-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 24px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    position: sticky;
    bottom: 0;
    flex-shrink: 0;
}

/* ================================================================
   BUTTONS — Bootstrap 5.3 compatible override system
   Bootstrap 5.3 uses CSS custom properties (--bs-btn-*) for all
   button colors. We must override BOTH the variables AND the
   computed properties to guarantee correct rendering.
   ================================================================ */

/* ── Base sizing / layout ── */
.btn {
    font-weight: 600;
    border-radius: 8px;
    font-size: 14px;
    padding: 9px 18px;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.1s;
    touch-action: manipulation;
    text-decoration: none !important;
}
.btn:active { transform: translateY(1px); }

/* ── Solid variants ── */
.btn-primary {
    --bs-btn-color: #fff; --bs-btn-bg: #2c5aa0; --bs-btn-border-color: #2c5aa0;
    --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #1e3a8a; --bs-btn-hover-border-color: #1e3a8a;
    --bs-btn-active-color: #fff; --bs-btn-active-bg: #1e3a8a; --bs-btn-active-border-color: #1e3a8a;
    background-color: #2c5aa0 !important; border-color: #2c5aa0 !important; color: #fff !important;
}
.btn-primary:hover, .btn-primary:focus {
    background-color: #1e3a8a !important; border-color: #1e3a8a !important; color: #fff !important;
    box-shadow: 0 4px 10px rgba(44,90,160,0.3) !important;
}

.btn-secondary {
    --bs-btn-color: #fff; --bs-btn-bg: #6b7280; --bs-btn-border-color: #6b7280;
    --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #4b5563; --bs-btn-hover-border-color: #4b5563;
    background-color: #6b7280 !important; border-color: #6b7280 !important; color: #fff !important;
}
.btn-secondary:hover, .btn-secondary:focus {
    background-color: #4b5563 !important; border-color: #4b5563 !important; color: #fff !important;
}

.btn-success {
    --bs-btn-color: #fff; --bs-btn-bg: #10b981; --bs-btn-border-color: #10b981;
    --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #059669; --bs-btn-hover-border-color: #059669;
    background-color: #10b981 !important; border-color: #10b981 !important; color: #fff !important;
}
.btn-success:hover, .btn-success:focus {
    background-color: #059669 !important; border-color: #059669 !important; color: #fff !important;
}

.btn-danger {
    --bs-btn-color: #fff; --bs-btn-bg: #ef4444; --bs-btn-border-color: #ef4444;
    --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #dc2626; --bs-btn-hover-border-color: #dc2626;
    background-color: #ef4444 !important; border-color: #ef4444 !important; color: #fff !important;
}
.btn-danger:hover, .btn-danger:focus {
    background-color: #dc2626 !important; border-color: #dc2626 !important; color: #fff !important;
}

.btn-warning {
    --bs-btn-color: #fff; --bs-btn-bg: #f59e0b; --bs-btn-border-color: #f59e0b;
    --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #d97706; --bs-btn-hover-border-color: #d97706;
    background-color: #f59e0b !important; border-color: #f59e0b !important; color: #fff !important;
}
.btn-warning:hover, .btn-warning:focus {
    background-color: #d97706 !important; border-color: #d97706 !important; color: #fff !important;
}

.btn-info {
    --bs-btn-color: #fff; --bs-btn-bg: #3b82f6; --bs-btn-border-color: #3b82f6;
    --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #2563eb; --bs-btn-hover-border-color: #2563eb;
    background-color: #3b82f6 !important; border-color: #3b82f6 !important; color: #fff !important;
}
.btn-info:hover, .btn-info:focus {
    background-color: #2563eb !important; border-color: #2563eb !important; color: #fff !important;
}

/* ── Outline variants ── */
.btn-outline-primary {
    --bs-btn-color: #2c5aa0; --bs-btn-border-color: #2c5aa0; --bs-btn-bg: transparent;
    --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #2c5aa0; --bs-btn-hover-border-color: #2c5aa0;
    color: #2c5aa0 !important; border-color: #2c5aa0 !important; background-color: transparent !important;
}
.btn-outline-primary:hover, .btn-outline-primary:focus {
    background-color: #2c5aa0 !important; color: #fff !important; border-color: #2c5aa0 !important;
}

.btn-outline-secondary {
    --bs-btn-color: #6b7280; --bs-btn-border-color: #6b7280; --bs-btn-bg: transparent;
    --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #6b7280; --bs-btn-hover-border-color: #6b7280;
    color: #6b7280 !important; border-color: #6b7280 !important; background-color: transparent !important;
}
.btn-outline-secondary:hover, .btn-outline-secondary:focus {
    background-color: #6b7280 !important; color: #fff !important; border-color: #6b7280 !important;
}

.btn-outline-success {
    --bs-btn-color: #059669; --bs-btn-border-color: #10b981; --bs-btn-bg: transparent;
    --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #10b981; --bs-btn-hover-border-color: #10b981;
    color: #059669 !important; border-color: #10b981 !important; background-color: transparent !important;
}
.btn-outline-success:hover, .btn-outline-success:focus {
    background-color: #10b981 !important; color: #fff !important; border-color: #10b981 !important;
}

.btn-outline-danger {
    --bs-btn-color: #ef4444; --bs-btn-border-color: #ef4444; --bs-btn-bg: transparent;
    --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #ef4444; --bs-btn-hover-border-color: #ef4444;
    color: #ef4444 !important; border-color: #ef4444 !important; background-color: transparent !important;
}
.btn-outline-danger:hover, .btn-outline-danger:focus {
    background-color: #ef4444 !important; color: #fff !important; border-color: #ef4444 !important;
}

.btn-outline-warning {
    --bs-btn-color: #d97706; --bs-btn-border-color: #f59e0b; --bs-btn-bg: transparent;
    --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #f59e0b; --bs-btn-hover-border-color: #f59e0b;
    color: #d97706 !important; border-color: #f59e0b !important; background-color: transparent !important;
}
.btn-outline-warning:hover, .btn-outline-warning:focus {
    background-color: #f59e0b !important; color: #fff !important; border-color: #f59e0b !important;
}

.btn-outline-info {
    --bs-btn-color: #0369a1; --bs-btn-border-color: #3b82f6; --bs-btn-bg: transparent;
    --bs-btn-hover-color: #fff; --bs-btn-hover-bg: #3b82f6; --bs-btn-hover-border-color: #3b82f6;
    color: #0369a1 !important; border-color: #3b82f6 !important; background-color: transparent !important;
}
.btn-outline-info:hover, .btn-outline-info:focus {
    background-color: #3b82f6 !important; color: #fff !important; border-color: #3b82f6 !important;
}

/* ── Small size (btn-sm) — just sizing, inherits variant colors ── */
.btn-sm {
    font-size: 13px !important;
    padding: 5px 11px !important;
    min-height: 30px !important;
    border-radius: 6px !important;
}

/* Link button */
.btn-link {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    min-height: unset !important;
    color: #2c5aa0 !important;
    font-weight: 600;
    text-decoration: underline !important;
}

/* Ensure all text/links inside buttons stay white */
.btn a, .btn a:hover, .btn a:visited,
a.btn, a.btn:hover {
    color: inherit !important;
    text-decoration: none !important;
}

/* ================================================================
   LANGUAGE SELECTOR BUTTONS (print report modal)
   ================================================================ */
.lang-btn {
    padding: 7px 15px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    transition: all 0.15s;
    line-height: 1.4;
    min-height: 36px;
}
.lang-btn:hover  { border-color: #2c5aa0; color: #1e3a8a; background: #eff6ff; }
.lang-btn.active { border-color: #2c5aa0; background: #dbeafe; color: #1e3a8a; }

/* ================================================================
   SESSION CHECKLIST (print report modal)
   ================================================================ */
.session-check-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 11px 16px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background 0.1s;
}
.session-check-item:last-child { border-bottom: none; }
.session-check-item:hover { background: #f8f9fa; }
.session-check-item input[type="checkbox"] {
    width: 17px;
    height: 17px;
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: #2c5aa0;
    cursor: pointer;
}
.session-check-item .session-info { flex: 1; min-width: 0; }
.session-check-item .session-name { font-weight: 600; font-size: 14px; color: #1f2937; }
.session-check-item .session-meta { font-size: 12px; color: #6b7280; margin-top: 2px; }
.session-check-item .session-score {
    background: #f0fdf4;
    color: #16a34a;
    border: 1px solid #bbf7d0;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

/* ================================================================
   ASSESSMENT CARDS (assessments.php, multi_assessment.php)
   ================================================================ */
.assessment-card {
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 15px;
    background: #fff;
    transition: all 0.2s;
}
.assessment-card:hover {
    border-color: #2c5aa0;
    box-shadow: 0 2px 8px rgba(44,90,160,0.1);
}
.assessment-card.inactive {
    background: #f9fafb;
    opacity: 0.9;
}

/* Assessment select card (multi_assessment.php) */
.assessment-select-card {
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: all 0.18s;
    user-select: none;
    background: #fff;
    display: flex;
    align-items: center;
    gap: 14px;
}
.assessment-select-card:hover {
    border-color: #6366f1;
    background: #f5f3ff;
}
.assessment-select-card.selected {
    border-color: #4f46e5;
    background: #eef2ff;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.assessment-select-card .drag-handle {
    color: #9ca3af;
    font-size: 20px;
    cursor: grab;
    flex-shrink: 0;
}

/* ================================================================
   BADGE / TAG STYLES
   ================================================================ */
.tag-badge-small {
    font-size: 11px;
    padding: 2px 7px;
    background: #e0e7ff;
    color: #3730a3;
    border-radius: 99px;
    display: inline-block;
}

.score-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
}
.score-badge-teacher-led  { background: #dbeafe; color: #1e40af; }
.score-badge-student      { background: #e0e7ff; color: #4338ca; }

.percent-badge {
    padding: 6px 14px;
    border-radius: 6px;
    font-weight: 600;
    display: inline-block;
}
.percent-badge-high   { background: #d1fae5; color: #065f46; }
.percent-badge-mid    { background: #fef3c7; color: #92400e; }
.percent-badge-low    { background: #fee2e2; color: #991b1b; }

/* ================================================================
   MULTI-ASSESSMENT TESTING OVERLAY
   ================================================================ */
#testingOverlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.92);
    z-index: 3000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    backdrop-filter: blur(4px);
}
#testingOverlay.active { display: flex; }

.testing-card {
    background: #fff;
    color: #1f2937;
    border-radius: 20px;
    padding: 36px 44px;
    min-width: 400px;
    max-width: 95vw;
    text-align: center;
    box-shadow: 0 32px 80px rgba(0,0,0,0.55), 0 0 0 3px #4f46e5;
    border-top: 6px solid #4f46e5;
}

.item-display {
    font-size: 72px;
    font-weight: 800;
    letter-spacing: 4px;
    margin: 24px 0;
    color: #1f2937;
}

.progress-bar-wrap {
    background: #e5e7eb;
    border-radius: 99px;
    height: 8px;
    margin-bottom: 20px;
}
.progress-bar-fill {
    background: #4f46e5;
    height: 8px;
    border-radius: 99px;
    transition: width 0.3s;
}

/* ================================================================
   ORDER EDITOR drag-sort styles
   ================================================================ */
.sortable-ghost { opacity: 0.4; background: #e0e7ff !important; }
#assessmentSortList .list-group-item { user-select: none; }
#assessmentSortList .list-group-item:hover { background: #f0f4ff; border-color: #6366f1; }

/* ================================================================
   INLINE STYLES REPLACED — reusable utility classes
   ================================================================ */

/* Filter row / select on testing pages */
.filter-label {
    font-size: 14px;
    font-weight: 600;
    color: #4a5568;
}

/* History table row (teacher student_profile) */
.history-group-row {
    cursor: pointer;
    background: #f9fafb;
}
.history-group-row:hover { background: #f0f4ff !important; }

/* Accordion nested table header */
.attempt-table-header {
    margin: 0 0 12px 0;
    color: #6b7280;
    font-size: 14px;
}

/* Stats / score displays */
.stat-score-large {
    font-size: 18px;
    font-weight: 700;
    color: #10b981;
}
.stat-score-sub {
    font-size: 12px;
    color: #6b7280;
}

/* Session code display on testing page */
.session-code-wrapper {
    background: linear-gradient(135deg, #FFF5E6 0%, #FFE8D6 100%);
    padding: 24px;
    border-radius: 15px;
    text-align: center;
    margin-bottom: 24px;
}
.session-code-label {
    margin: 0 0 12px;
    font-size: 18px;
    font-weight: 600;
    color: #4A5568;
}
.session-code-hint {
    margin: 12px 0 0;
    color: #718096;
    font-size: 14px;
}

/* History modal item notes */
.item-note {
    background: #fef3c7;
    padding: 4px 8px;
    border-radius: 4px;
    margin-top: 4px;
    border-left: 3px solid #f59e0b;
    font-size: 13px;
}

/* Attempt timeline block */
.attempt-block {
    padding: 12px 16px;
    background: #f9fafb;
    margin-bottom: 12px;
    border-radius: 0 8px 8px 0;
}

/* Student note avatar bubble */
.note-avatar {
    background: #e0e7ff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    flex-shrink: 0;
}

/* Inline forms without card styling */
.form-inline-bare {
    background: none;
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
}

/* ── Nav tabs — global contrast fix ────────────────────────────────────────
   The navbar sets .nav-link { color: white !important } which leaks into
   every .nav-tabs on the page. These rules restore readable contrast. ── */
.nav-tabs .nav-item .nav-link,
.nav-tabs .nav-item a.nav-link,
.nav-tabs .nav-item button.nav-link {
    color: #6b7280 !important;
    background: transparent !important;
    border-bottom: 3px solid transparent !important;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    border-radius: 0 !important;
    font-weight: 600 !important;
    text-shadow: none !important;
    padding: 10px 16px !important;
    white-space: nowrap;
    transition: color .15s, border-color .15s;
}
.nav-tabs .nav-item .nav-link:hover,
.nav-tabs .nav-item a.nav-link:hover,
.nav-tabs .nav-item button.nav-link:hover {
    color: #2c5aa0 !important;
    background: transparent !important;
    border-bottom-color: #bfdbfe !important;
}
.nav-tabs .nav-item .nav-link.active,
.nav-tabs .nav-item a.nav-link.active,
.nav-tabs .nav-item button.nav-link.active {
    color: #1d4ed8 !important;
    background: #fff !important;
    border-bottom: 3px solid #2c5aa0 !important;
    font-weight: 700 !important;
}

/* Form switch style */
.form-switch .form-check-input {
    width: 3em;
    height: 1.5em;
}
.form-switch .form-check-input:checked {
    background-color: #10b981;
    border-color: #10b981;
}
