/* Base styles */
html {
    box-sizing: border-box;
    height: 100%; /* Ensure html takes full viewport height */
    background-color: #f4f7f6; /* Set base background to light gray */
}
*, *:before, *:after {
    box-sizing: inherit;
}

body {
    font-family: 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    margin: 0;
    line-height: 1.6;
    background-color: var(--color-dark); /* Set body background to dark blue */
    color: #333;
    overflow-x: hidden;
    display: flex; /* Enable flexbox */
    flex-direction: column; /* Stack children vertically */
    min-height: 100vh; /* Ensure body takes at least full viewport height */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    width: 100%; /* Ensure container always takes full width */
}

/* Header */
.main-header {
    background-color: var(--color-header-bg); /* consistent with footer */
    color: var(--color-header-text);
    padding: 0.5rem 0;
    /* Add extra padding to the top to account for iOS safe area */
    padding-top: calc(0.5rem + env(safe-area-inset-top));
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Logo styling */
.app-title-logo {
    display: flex; /* To vertically align the image */
    align-items: center;
    text-decoration: none; /* Remove underline from link */
}

.header-logo {
    height: 72px; /* Adjust height as needed */
    width: auto;
    filter: var(--logo-filter); /* Make logo white, or none if it's already reversible */
    margin-right: 10px; /* Add some space between logo and text */
}

.header-text {
    color: var(--color-header-text);
    font-size: 1.5rem; /* Reduced font size */
    font-weight: 500; /* Slightly less bold */
    text-decoration: none; /* Ensure no underline from parent link */
}

.main-nav a {
    color: var(--color-header-text);
    text-decoration: none;
    margin-left: 1.5rem;
    font-size: 1rem;
}

.main-nav span {
    color: var(--color-header-text);
}

.main-nav a:hover {
    text-decoration: underline;
}

/* Flash messages */
.flashes {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
}

.flashes li {
    display: flex;
    align-items: center; /* Ensures vertical centering of all flex items */
    padding: 1rem 1.2rem;
    margin-bottom: 1rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    border-width: 1px;
    border-style: solid;
    line-height: 1.4; /* Consistent line height for text */
}

.flash-icon {
    flex-shrink: 0;
    margin-right: 0.75rem; /* Reduced margin for tighter look */
    line-height: 0; /* Important for vertical alignment of SVG */
}

.flash-icon svg {
    width: 20px; /* Slightly smaller icons */
    height: 20px; /* Slightly smaller icons */
    vertical-align: middle; /* Ensures SVG itself is vertically aligned */
}

.flash-message {
    flex-grow: 1;
    line-height: 1.4; /* Ensure consistent line height for message text */
    padding-top: 2px; /* Slight adjustment for visual balance if needed */
    padding-bottom: 2px; /* Slight adjustment for visual balance if needed */
}

.flash-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    opacity: 0.7;
    padding: 0 0.5rem;
    margin-left: 1rem; /* Space between message and close button */
}

.flash-close:hover {
    opacity: 1;
}

/* Specific styles for flash categories */
.flash-success {
    background-color: #f0fdf4; /* Lighter Green */
    color: #166534; /* Darker Green */
    border-color: #bbf7d0; /* Soft Green Border */
}

.flash-error, .flash-danger {
    background-color: #fef2f2; /* Lighter Red */
    color: #991b1b; /* Darker Red */
    border-color: #fecaca; /* Soft Red Border */
}

.flash-info, .flash-default { /* Added .flash-default here */
    background-color: #eff6ff; /* Lighter Blue */
    color: #1e40af; /* Darker Blue */
    border-color: #bfdbfe; /* Soft Blue Border */
}

/* Main Content Area */
.content-area-wrap {
    background-color: #f4f7f6; /* Give content area its own light background */
    flex-grow: 1; /* Allow content area to grow and push footer down */
}
.content-area {

    padding-top: 2rem;
    padding-bottom: 3rem;

}

/* Embeddable (iframed) pages: no header/footer chrome, no min-height/background bleed */
body.embed {
    min-height: 0;
    background-color: #f4f7f6;
}
body.embed .content-area-wrap {
    flex-grow: 0;
}
body.embed .content-area {
    padding-top: 1rem;
    padding-bottom: 1rem;
}

/* In embed mode the form's own .card padding already provides internal breathing room,
   and the surrounding WordPress page provides its own margins around the iframe — the
   .container side padding on top of that is pure redundant whitespace eating into the
   width available for the form. */
body.embed .container {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

/* The embedded form is always a compact island inside someone else's page, never a full
   page of its own — it doesn't need desktop-scale card padding even when the iframe
   itself is wide. */
body.embed .card {
    padding: 1.25rem;
}

/* Footer */
.main-footer {
    background-color: var(--color-header-bg); /* consistent with header */
    color: var(--color-header-text);
    text-align: center;
    /* Add extra padding to the bottom to account for iOS safe area */
    padding-bottom: calc(1rem + env(safe-area-inset-bottom));
    margin-top: 3rem;
    border-bottom: 1px solid var(--color-header-bg); /* Add a matching border to cover any gaps */
}

/* Card Component (from home.html) */
.card {
    background-color: white;
    padding: 2em;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
}

.login-container { /* Specific styles for login form */
    max-width: 400px;
    margin: 0 auto; /* Center it horizontally within its parent */
    text-align: center;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--color-primary); /* Dark Blue from logo for headings */
    margin-top: 0;
    margin-bottom: 1rem;
    font-weight: 600;
}

h1 {
    /* border-bottom: 2px solid var(--color-accent); Golden accent for h1 */
    /* padding-bottom: 0.5rem; */
}

/* Forms */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #555;
}

.enrollment-mode-options {
    display: flex;
    gap: 0.75rem;
}

/* Specificity note: a plain ".enrollment-mode-option { display: flex }" loses to the
   pre-existing ".form-group label { display: block }" rule (same 0-1-1 vs 0-1-0
   specificity, but that rule is declared first isn't why — 0-1-1 simply outranks 0-1-0).
   Scoping every rule under the #enrollment-mode-chooser ancestor id keeps this block a
   flex row without needing !important. */
#enrollment-mode-chooser .enrollment-mode-option {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.65rem;
    padding: 1.1rem 1rem;
    border: 2px solid #dcdcdc;
    border-radius: 12px;
    background-color: white;
    font-weight: 600;
    font-size: 1.05rem;
    color: #333;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

#enrollment-mode-chooser .enrollment-mode-option:hover {
    border-color: var(--color-accent);
}

#enrollment-mode-chooser .enrollment-mode-option:has(input:checked) {
    border-color: var(--color-accent);
    background-color: var(--color-accent-20);
    box-shadow: 0 0 0 1px var(--color-accent);
}

/* The native radio is kept (for accessibility/keyboard use) but made invisible in favour
   of a custom dot drawn via ::before, which looks consistent across browsers/OSes. It's
   stretched to cover the whole label (rather than shrunk to ~0 size) so there's no stray
   fragment of the native control's own rendering left visible next to the text. */
#enrollment-mode-chooser .enrollment-mode-option input[type="radio"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    margin: 0;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
}

#enrollment-mode-chooser .enrollment-mode-option::before {
    content: '';
    display: inline-block;
    flex-shrink: 0;
    width: 1.2em;
    height: 1.2em;
    border-radius: 50%;
    border: 2px solid #ccc;
    background-color: white;
    transition: border-color 0.15s, background 0.15s;
}

#enrollment-mode-chooser .enrollment-mode-option:has(input:checked)::before {
    border-color: var(--color-accent);
    background: radial-gradient(circle, var(--color-accent) 0 42%, transparent 46%);
}

#enrollment-mode-chooser .enrollment-mode-option input[type="radio"]:focus-visible ~ *,
#enrollment-mode-chooser .enrollment-mode-option:has(input[type="radio"]:focus-visible) {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

@media (max-width: 480px) {
    .enrollment-mode-options {
        flex-direction: column;
    }
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"], /* Added for completeness */
select,
textarea {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid #dcdcdc;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 1rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--color-accent); /* Golden accent focus */
    box-shadow: 0 0 0 3px var(--color-accent-20);
    outline: none;
}

/* Buttons */
.button {
    display: inline-block;
    padding: 0.8rem 1.5rem;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

a.button {
    /* Match default button line-height to fix height differences */
    line-height: normal;
}

.button.primary {
    background-color: var(--color-primary); /* Primary Blue from logo */
    color: white;
    border-color: var(--color-primary);
}

.button.primary:hover {
    background-color: var(--color-dark); /* Darker Blue for hover */
    border-color: var(--color-dark); /* Match hover background */
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.button.danger {
    background-color: #e74c3c; /* Red */
    color: white;
}

.button.danger:hover {
    background-color: #c0392b;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.button.secondary {
    background-color: #ecf0f1; /* Light gray base */
    color: #333; /* Standard dark text color */
    border: 1px solid #bdc3c7; /* Subtle light gray border (original value) */
}

.button.secondary:hover {
    background-color: var(--color-accent); /* Golden accent on hover */
    color: white; /* White text on golden hover */
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

.info-text { /* from home.html */
    margin-top: 1.5em;
    font-size: 0.9em;
    color: #777;
}

a {
    color: var(--color-primary); /* Primary Blue for links */
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--color-dark);
    text-decoration: underline;
}

/* Mobile responsiveness - basic */
@media (max-width: 768px) {
    .container {
        padding: 1rem; /* Reduced padding for smaller screens */
    }

    /* .card's 2em padding is fine on desktop, but the application form nests a .card
       (each student block) inside another .card (the form itself) — on a phone that's
       two lots of ~32px eaten from both sides before any actual content, which is what
       was squeezing the granular weekday picker down to one letter per line. */
    .card {
        padding: 1.25rem;
    }

    /* By removing flex-direction: column, header-content remains a row */
    /* space-between on the parent will push logo and nav to either side */

    .main-nav span {
        display: none; /* Hide "Welcome..." text on mobile */
    }

    .main-nav a {
        margin-left: 0; /* Remove desktop margin on mobile */
    }

    .home-layout .class-listings {
        margin-top: 2rem; /* Add space between login block and class listings */
    }
}

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

    .card {
        padding: 0.85rem;
    }

    /* Give the granular weekday table's 4 columns back the width the card/container
       padding above was eating — tighter spacing here, not smaller text, is what makes
       "6:00 PM" fit on one line instead of wrapping letter-by-letter. */
    table.granular-schedule {
        border-spacing: 0.2rem;
    }

    table.granular-schedule td {
        padding: 0.2rem;
    }

    .granular-option {
        padding: 0.25rem 0.3rem;
        gap: 0.2rem;
    }
}

/* From dashboard.html */
.admin-links-list {
    list-style: none;
    padding: 0;
    margin-top: 1rem;
}

.admin-links-list li {
    margin-bottom: 0.5rem;
}

/* From admin_applications.html */
.dashboard-nav {
    margin-bottom: 1.5rem;
    text-align: center; /* Center the "Back to Dashboard" button */
}

.dashboard-nav .button {
    margin-right: 0.5rem; /* Add some spacing if multiple buttons */
}

.application-actions {
    margin-top: 1.5rem; /* Space between info and actions */
    display: flex;
    flex-wrap: wrap; /* Allow forms to wrap on smaller screens */
    gap: 1rem; /* Space between approve/deny forms */
}

.application-actions .action-form {
    flex: 1; /* Distribute space evenly */
    min-width: 280px; /* Minimum width before wrapping */
    padding: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background-color: #fcfcfc;
}

.application-actions .action-form .form-group {
    margin-bottom: 1rem;
}

/* Status indicators */
.status-pending {
    color: #f39c12; /* Orange for pending */
    font-weight: bold;
}

.status-approved {
    color: #27ae60; /* Green for approved */
    font-weight: bold;
}

.status-denied {
    color: #e74c3c; /* Red for denied */
    font-weight: bold;
}

/* Form elements within actions */
.form-select, .form-textarea {
    width: 100%;
    padding: 0.6em;
    border: 1px solid #dcdcdc;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 0.95rem;
    margin-top: 0.5em; /* Space from label */
}

.form-textarea {
    min-height: 70px; /* Adjust height for admin notes */
    resize: vertical;
}

/* Mobile adjustments */
@media (max-width: 600px) {
    .application-actions {
        flex-direction: column; /* Stack forms vertically */
    }
    .application-actions .action-form {
        min-width: unset;
    }
}

/* From apply.html */
form#application-form {
    max-width: 600px; /* Specific max-width for application form */
    margin: 2em auto;
}

form#application-form h2, form#application-form h3 {
    text-align: center;
}

input[readonly] {
    background-color: #f5f5f5; /* Lighter background for readonly */
    cursor: not-allowed;
}

.student-block {
    margin-bottom: 1.5rem; /* Consistent spacing */
    text-align: left;
    position: relative;
}

.student-block h3 {
    text-align: left;
    margin-bottom: 1rem;
}

.student-block .remove-student-btn {
    position: absolute;
    top: 15px; /* Adjust positioning */
    right: 15px; /* Adjust positioning */
    width: 34px;
    height: 34px;
    font-size: 1rem;
    line-height: 34px;
    border-radius: 50%;
    padding: 0;
}

.student-block p { /* For "Select which class(es)..." */
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 500;
    color: #555;
}

.sections-container {
    margin-top: 1rem;
    border-top: 1px dashed #eee;
    padding-top: 1rem;
}

.section-row {
    margin-bottom: 0.8rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid #f5f5f5;
}

.section-row:last-child {
    border-bottom: none;
}

.section-row label {
    flex-shrink: 0;
    margin-right: 0.5rem;
    margin-bottom: 0;
    width: auto;
    font-weight: normal;
}

.section-row .form-select {
    flex-grow: 1;
    width: auto;
    margin-bottom: 0;
}

.auto-selected-class-label {
    padding: 0.6rem 0.9rem;
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    color: #333;
    font-size: 0.95rem;
}

.section-row .remove-section-btn {
    position: static; /* Override absolute positioning */
    margin-left: 0; /* Remove static margin-left */
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    font-size: 1rem;
    line-height: 30px;
    padding: 0;
}

.button.full-width {
    width: 100%;
    display: block; /* Make block to fill width */
    margin-top: 1em;
}

.button.small {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    font-weight: 600; /* Consistent font-weight */
}

.form-separator {
    border: none;
    border-top: 1px dashed #e0e0e0;
    margin: 2rem 0;
}

@media (max-width: 600px) {
    .section-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    .section-row label {
        margin-bottom: 0.2rem;
    }
    .section-row .form-select {
        width: 100%;
    }
    .section-row .remove-section-btn {
        align-self: flex-end; /* Push remove button to the right */
        margin-top: -30px; /* Overlap with select */
    }
}

/* Granular scheduling: weekday table with radio "bubbles" for day/time-slot picks */
.granular-schedule-table {
    margin-top: 0.75rem;
    overflow-x: auto;
}

table.granular-schedule {
    border-collapse: separate;
    border-spacing: 0.35rem;
    width: 100%;
    table-layout: fixed; /* equal-width columns that shrink to fit, instead of growing with content */
}

table.granular-schedule th {
    color: var(--color-primary);
    font-weight: 600;
    text-align: center;
    padding-bottom: 0.25rem;
    font-size: 0.8rem;
    overflow-wrap: break-word;
}

table.granular-schedule td {
    vertical-align: top;
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 0.35rem;
}

.granular-day-options {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.granular-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.3rem 0.4rem;
    border: 1px solid #dcdcdc;
    border-radius: 999px;
    background-color: white;
    font-size: 0.72rem;
    line-height: 1.2;
    white-space: normal; /* let time labels wrap onto a second line instead of overflowing */
    overflow-wrap: break-word;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background-color 0.15s;
}

.granular-option:has(input:checked) {
    border-color: var(--color-accent);
    background-color: var(--color-accent-20);
    font-weight: 600;
}

.granular-option.skip {
    color: #777;
}

.granular-option input[type="radio"] {
    margin: 0;
    accent-color: var(--color-accent);
}

/* From parent_dashboard.html */
.parent-info {
    /* margin-bottom: 2em; - already covered by .card margin-bottom */
}

.child-section {
    /* border: 1px solid #ccc; - removed, covered by card */
    /* padding: 1.5em; - removed, covered by card */
    /* margin-bottom: 2em; - removed, covered by card margin-bottom */
    /* border-radius: 5px; - removed, covered by card border-radius */
}

.class-section.card-nested { /* Styling for nested card */
    background-color: #f9f9f9; /* Retain subtle background for nested card */
    border: 1px solid #eee; /* Light border for nested card */
    padding: 1.5em; /* Padding for nested card */
    margin-bottom: 1.5rem; /* Consistent spacing */
    border-radius: 6px; /* Slightly smaller border-radius for nested card */
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); /* Subtle shadow for nested card */
}

.class-section h3 {
    /* margin-top: 0; color: #555; - already covered by h3 style */
}

.daily-records-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.daily-record {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping */
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px dashed #e0e0e0;
    padding-bottom: 0.8em;
    margin-bottom: 0.8em;
    gap: 0.5rem 1rem; /* Add gap for spacing */
}

.record-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.record-date {
    font-weight: bold;
    color: #555;
}

.record-status {
    font-weight: bold;
}

.record-progress {
    flex-basis: 100%; /* Take full width on new line if it wraps */
    color: #555;
    font-style: italic;
    padding-left: 1rem; /* Indent progress update */
}

.daily-record:last-child {
    border-bottom: none;
}

/* Status styles (present, absent) - reusing existing status- classes */
.status-present {
    color: #27ae60; /* Green */
}
.status-absent {
    color: #e74c3c; /* Red */
}

.pagination {
    margin-top: 2rem;
    margin-bottom: 2rem;
    text-align: center;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

.pagination .button { /* Reuse button class */
    padding: 0.8em 1.5em;
    margin: 0;
}

.pagination .current-month {
    font-size: 1.1rem;
    font-weight: bold;
    color: #2c3e50;
}

/* From teacher_dashboard.html */

/* Date Navigation */
.date-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem; /* Space between items */
    padding: 1em; /* Reduce padding slightly for compactness */
}

.date-navigation input[type="date"] {
    flex-grow: 1; /* Allow the input to take available space */
    text-align: center;
    min-width: 120px; /* Ensure date input is not too small */
}

.date-navigation .button {
    padding: 0.5em 0.8em; /* Make buttons more compact */
    white-space: nowrap; /* Prevent button text from wrapping */
}

/* Toast notifications */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}
.toast {
    background-color: #333;
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    margin-bottom: 10px;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}
.toast.show {
    opacity: 1;
}

/* Teacher Info */
.teacher-info {
    /* margin-bottom: 2em; - covered by .card */
}

/* Quicksearch */
.quicksearch-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem; /* Ensure consistent margin from previous elements */
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
}
.quicksearch-container .form-input {
    flex-grow: 1; /* Let it take available space */
    width: auto; /* Override specific width if any */
    min-width: 200px; /* Ensure it's not too small on desktop */
}

@media (max-width: 600px) {
    .quicksearch-container {
        flex-direction: column; /* Stack label and input vertically */
        align-items: flex-start; /* Align label to the left */
        gap: 0.5rem; /* Reduce gap when stacked */
    }
    .quicksearch-container .form-input {
        width: 100%; /* Take full width when stacked */
        min-width: unset; /* Remove min-width constraint */
    }
}

/* Section Block */
.section-block {
    /* border: 1px solid #ccc; - covered by .card */
    /* padding: 1.5em; - covered by .card */
    /* margin-bottom: 2em; - covered by .card margin-bottom */
    /* border-radius: 5px; - covered by .card border-radius */
}
.section-block h2 {
    /* margin-top: 0; color: #333; - covered by global h2 */
}

/* Student Entry (will be in _student_list_fragment.html) */
.student-entry {
    background-color: #f9f9f9;
    border: 1px solid #eee;
    padding: 1.5em; /* Increased padding */
    margin-bottom: 1.5rem;
    border-radius: 6px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    position: relative; /* Added for absolute positioning of children */
}
.student-entry h3 {
    /* margin-top: 0; color: #555; - covered by global h3 */
}

/* Custom Checkbox Button */
.checkbox-button {
    display: inline-flex; /* Use flex for internal alignment */
    align-items: center;
    padding: 8px 12px;
    border: 1px solid #bdc3c7;
    border-radius: 6px;
    cursor: pointer;
    background-color: #ecf0f1;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
    user-select: none;
    white-space: nowrap; /* Prevent "Present" from wrapping */
}
.checkbox-button input[type="checkbox"],
.checkbox-button input[type="radio"] {
    display: none;
}
.checkbox-button.checked.absent {
    background-color: #e74c3c; /* Red */
    color: white;
    border-color: #e74c3c;
}
.checkbox-button.checked.present {
    background-color: #27ae60; /* Green */
    color: white;
    border-color: #27ae60;
}
.student-entry .status-indicator {
    position: absolute;
    top: 24px;
    right: 24px;
    padding: 5px 10px;
    background-color: rgba(39, 174, 96, 0.9); /* Green with some transparency */
    color: white; /* Changed back to white */
    border-radius: 4px;
    font-size: 0.8em;
    font-weight: bold;
    text-transform: uppercase;
    z-index: 10; /* Ensure it's above other content */
    transition: opacity 0.5s ease-in-out, visibility 0.5s ease-in-out; /* Add visibility transition */
}

/* Streamlined Student Block Styles */
.attendance-controls {
    display: flex;
    align-items: center;
    gap: 1rem; /* Consistent spacing */
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.attendance-controls label { /* For the checkbox button */
    margin-bottom: 0;
}

.attendance-controls .form-input {
    flex-grow: 1;
    min-width: 150px;
}

/* Media query for attendance controls on small screens */
@media (max-width: 600px) {
    .student-entry {
        padding: 1em; /* Reduce padding for student entry */
    }

    .attendance-controls {
        flex-direction: column; /* Stack primary elements (buttons row, input, status) */
        gap: 0.5rem; /* Reduced gap for vertical stacking */
        align-items: stretch; /* Make items stretch to fill width */
    }

    .attendance-controls .button-group {
        display: flex;
        width: 100%; /* Take full width */
        justify-content: space-around; /* Distribute space evenly */
        gap: 0.5rem; /* Gap between buttons */
    }

    .attendance-controls .checkbox-button {
        flex-grow: 1; /* Allow buttons to grow and fill space */
        padding: 0.5em 0.8em; /* Make buttons more compact */
        white-space: nowrap; /* Keep text on one line within button */
        text-align: center;
        justify-content: center;
    }

    .attendance-controls .form-input {
        width: 100%; /* Take full width */
        min-width: unset;
        padding: 0.5em 0.8em; /* Make input more compact */
    }
}

/* Last Records */
.last-records {
    margin-top: 1rem;
}

.last-records p {
    margin: 0.3em 0;
    font-size: 0.9em;
}

.compact-records {
    margin-top: 0.8rem;
    font-size: 0.9em;
    color: #555;
}

.compact-record-entry {
    display: inline-block; /* Allows margins and padding */
    margin-right: 0.5em; /* Space between entries */
    white-space: nowrap; /* Keep each entry on one line */
}



/* Transfer Student Controls */
.transfer-student-controls {
    display: flex;
    align-items: center;
    /* Removed gap: 1rem; - as it's not working as expected */
    margin-top: 1rem;
    flex-wrap: wrap; /* Allows items to wrap onto the next line */
    padding-top: 1rem;
    border-top: 1px dashed #e0e0e0;
}
.transfer-student-controls .form-label {
    margin-bottom: 1rem; /* Space below label, whether next element is inline or wrapped */
    white-space: nowrap;
    margin-right: 1rem; /* Space to the right for inline elements */
}
.transfer-select {
    flex-grow: 1; /* Allow select to take available space */
    min-width: 150px; /* Minimum width for select */
    margin-right: 1rem; /* Space to the right for inline elements */
    margin-bottom: 1rem; /* Space below select, whether next element is inline or wrapped */
}
.transfer-student-controls .button {
    width: auto;
    margin-top: 0;
    margin-bottom: 1rem; /* Space below button if it's followed by other wrapped elements */
}

/* Custom styling for <details> and <summary> to replace default marker */
summary {
    display: flex; /* Use flexbox for alignment */
    align-items: center; /* Vertically align text and marker */
    cursor: pointer;
    font-weight: 600;
    color: var(--color-primary); /* Match link/header colors */
    padding: 0.5em 0;
    list-style: none; /* Hide default marker in Firefox */
}

summary::-webkit-details-marker {
    display: none; /* Hide default marker in Webkit */
}

summary::before {
    content: '';
    width: 0.5em;
    height: 0.5em;
    background-color: var(--color-primary);
    clip-path: polygon(0% 0%, 100% 50%, 0% 100%); /* Right-pointing triangle */
    margin-right: 0.75em;
    transform: rotate(0);
    transition: transform 0.2s ease-in-out;
}

details[open] > summary::before {
    transform: rotate(90deg);
}

details > *:not(summary) {
    margin-top: 1em; /* Add some space between summary and content */
}


/* HTMX Indicator */
.htmx-indicator {
    display: inline-block;
    vertical-align: middle;
    margin-left: 10px;
    color: #555;
    font-style: italic;
    opacity: 0; /* Hidden by default */
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    visibility: hidden;
}
.htmx-indicator.htmx-request {
    opacity: 1; /* Visible during AJAX request */
    visibility: visible;
}


/* Parent Dashboard Mobile Optimizations */
@media (max-width: 600px) {
    .parent-dashboard .card,
    .parent-dashboard .class-section.card-nested {
        padding: 1rem;
    }

    .parent-dashboard h1,
    .parent-dashboard h2,
    .parent-dashboard h3,
    .parent-dashboard h4,
    .parent-dashboard p {
        word-break: break-word;
    }

    .parent-dashboard .record-progress {
        padding-left: 0;
    }

    .parent-dashboard .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }

    .parent-dashboard .pagination .button {
        padding: 0.5em 0.8em; /* Smaller padding for buttons */
        flex-grow: 1; /* Allow buttons to take more space if needed */
        min-width: unset; /* Remove min-width constraint */
        margin-top: 0.5rem; /* Add space when buttons wrap */
    }

    .parent-dashboard .pagination .current-month {
        font-size: 1rem; /* Smaller font size for current month */
        text-align: center;
        order: -1; /* Move current month to the top */
        width: 100%; /* Take full width */
    }
}


/* Home Page Layout */
.home-layout {
    /* Mobile-first: elements stack by default (no float/grid/flex here) */
}

@media (min-width: 769px) {
    .home-layout {
        display: flex;
        gap: 2rem;
        align-items: flex-start;
    }

    .class-listings {
        flex-grow: 1;
        order: 1; /* Appears first on the left */
    }

    .login-column {
        flex-shrink: 0;
        width: 380px;
        order: 2; /* Appears second on the right */
    }

    .login-column .login-container {
        margin: 0;
        max-width: 100%;
    }
}

.class-listings h2 {
    border-bottom: 2px solid #eee;
    padding-bottom: 0.5rem;
    margin-top: 2rem;
}

.class-description {
    margin-top: 1rem;
}

/* Admin Dashboard Specific Styles */
.dashboard-container {
    width: 100%;
}

.dashboard-main-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1.5rem 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    text-align: center;
    padding: 1.5rem;
}

.stat-card h3 {
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    color: #555;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--color-primary);
}

.enrollment-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.section-enrollment-card {
    padding: 1rem 1.5rem;
}

.section-enrollment-card h4 {
    margin-bottom: 0.5rem;
}

.progress-bar {
    width: 100%;
    background-color: #e0e0e0;
    border-radius: 4px;
    height: 10px;
    overflow: hidden;
    margin-top: 0.5rem;
}

.progress-bar-fill {
    height: 100%;
    background-color: #27ae60; /* Green */
    width: 0%;
    transition: width 0.5s ease-in-out;
}

.stat-fraction {
    font-size: 0.9rem;
    color: #666;
    margin-top: -0.5rem;
}

.stat-fraction-small {
    font-size: 0.8rem;
    color: #777;
}

.table-container {
    overflow-x: auto;
    padding: 1rem; /* Override card padding for less space */
}

.section-stats-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Ensure table has a minimum width for readability */
}

.section-stats-table th, .section-stats-table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.section-stats-table th {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333;
    background-color: #f9f9f9;
}

.section-stats-table td {
    font-size: 0.95rem;
}

.section-stats-table tbody tr:last-child td {
    border-bottom: none;
}

.section-stats-table td p {
    margin: 0;
    line-height: 1.4;
}

.icon-button {
    background-color: #e74c3c;
    border: none;
    padding: 0;
    cursor: pointer;
    color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 0; /* Add this */
}

.icon-button:hover {
    background-color: #c0392b;
}

.icon-button.danger {
    background-color: #e74c3c;
    color: white;
}

.icon-button.danger:hover {
    background-color: #c0392b;
}

.icon-button svg {
    width: 20px;
    height: 20px;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Custom File Input Styling */
.hidden-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

.file-upload-container {
    display: flex;
    align-items: center;
    gap: 10px; /* Space between choose file button and file name display */
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
}

.upload-button {
    /* Inherits styling from .button.secondary */
    flex-shrink: 0; /* Prevent button from shrinking */
}

.file-name-display {
    flex-grow: 1; /* Allow text to take available space */
    color: #555;
    font-size: 0.9em;
    white-space: nowrap; /* Prevent file name from wrapping */
    overflow: hidden; /* Hide overflow */
    text-overflow: ellipsis; /* Add ellipsis for overflow */
    min-width: 0; /* Allow shrinking */
}

.impersonation-bar {
    background-color: #f39c12; /* A distinct color, e.g., orange */
    color: white;
    padding: 10px 20px;
    text-align: center;
    font-weight: bold;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000; /* Ensure it's above other content */
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.impersonation-bar .button {
    background-color: #e67e22; /* A slightly darker orange for the button */
    color: white;
    border: none;
    padding: 5px 15px;
    border-radius: 5px;
    text-decoration: none;
    font-size: 0.9em;
    transition: background-color 0.2s;
}

.impersonation-bar .button:hover {
    background-color: #d35400; /* Even darker orange on hover */
}

/* Password nudge bar */
.password-nudge-bar {
    background-color: #e8f4fd;
    color: #1a5276;
    text-align: center;
    padding: 8px 1.5rem;
    font-size: 0.9em;
    border-bottom: 1px solid #aed6f1;
}

.password-nudge-bar a {
    color: #1a5276;
    font-weight: 600;
}

/* Login tabs */
.login-tabs {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    margin-bottom: 1.25rem;
}

.login-tab {
    flex: 1;
    background: none;
    border: none;
    padding: 0.6rem 0;
    font-size: 0.95rem;
    color: #666;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    font-weight: 500;
    transition: color 0.15s, border-color 0.15s;
}

.login-tab:hover {
    color: var(--color-dark);
}

.login-tab.active {
    color: var(--color-dark);
    border-bottom-color: var(--color-dark);
}

.login-tab-content {
    padding-top: 0.25rem;
}

.login-divider {
    border-top: 1px solid #e0e0e0;
    margin: 1.25rem 0 1rem;
}

/* Auth pages (forgot/reset/set password) */
.auth-page-layout {
    display: flex;
    justify-content: center;
    padding: 2rem 0;
}

.auth-card {
    width: 100%;
    max-width: 420px;
}

.auth-card h1 {
    margin-top: 0;
    font-size: 1.5rem;
}

.auth-card p {
    color: #555;
    margin-bottom: 1.25rem;
}

