:root {
    --primary-blue: #003399;
    --light-blue: #3366cc;
    --success-green: #28a745;
    --bg-light: #f8f9fa;
    --border-color: #dee2e6;
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-light);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

img {
    max-width: 100%;
    height: auto;
}

.skip-link {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    background: var(--primary-blue);
    color: white;
    z-index: 1000;
}

.skip-link:focus {
    position: fixed;
    top: 0;
    left: 0;
    width: auto;
    height: auto;
    padding: 12px 16px;
    margin: 0;
    overflow: visible;
    clip: auto;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    border-radius: 0 0 4px 0;
    color: white;
}

*:focus-visible {
    outline: 3px solid var(--light-blue);
    outline-offset: 2px;
}

.school-header {
    background: linear-gradient(135deg, var(--primary-blue), var(--light-blue));
    color: white;
    padding: 0.75rem 0;
}

.school-name-greek {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin-bottom: 0.25rem;
}

.school-name-german {
    font-size: 1rem;
    color: #ffffff;
    margin-bottom: 0;
}

.school-footer {
    background-color: var(--primary-blue);
    color: #ffffff;
    font-size: 0.875rem;
    min-height: 44px;
}

.footer-link {
    color: #cce5ff;
    padding: 8px;
    display: inline-block;
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.footer-link:hover,
.footer-link:focus {
    color: #ffffff;
}

.school-footer p {
    margin-bottom: 0.5rem;
}

.card {
    border: 1px solid var(--border-color);
}

.card-header h4 {
    font-size: 1.1rem;
}

.child-section {
    background-color: #fff;
    transition: background-color 0.2s;
}

.child-section:hover {
    background-color: #f8f9ff;
}

.success-icon {
    display: inline-block;
    width: 64px;
    height: 64px;
    line-height: 64px;
    border-radius: 50%;
    background-color: var(--success-green);
    color: white;
    font-size: 2rem;
    font-weight: bold;
}

.reference-box {
    background-color: #e8f5e9;
    border: 2px solid var(--success-green);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

.ref-number {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    color: var(--primary-blue);
    letter-spacing: 1px;
}

.contribution-display {
    font-size: 1.1rem;
}

.form-label {
    font-weight: 500;
}

.text-danger {
    color: #dc3545 !important;
}

/* ==========================================================================
   MOBILE RESPONSIVENESS - Comprehensive mobile optimizations
   ========================================================================== */

/* Small devices (landscape phones, 576px and down) */
@media (max-width: 576px) {
    /* Header optimizations */
    .school-header .container {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .school-name-greek {
        font-size: 1.25rem;
    }
    
    .school-name-german {
        font-size: 0.875rem;
    }
    
    /* Navigation buttons - ensure minimum touch target */
    .school-header .btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }
    
    /* Card optimizations */
    .card {
        margin-left: 0;
        margin-right: 0;
        border-radius: 8px;
    }
    
    .card-header h4,
    .card-header h5 {
        font-size: 1rem;
        padding: 0.75rem;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .card-footer {
        padding: 0.75rem;
    }
    
    /* Reference number display */
    .ref-number {
        font-size: 1.1rem;
        word-break: break-all;
    }
    
    /* Success icon */
    .success-icon {
        width: 56px;
        height: 56px;
        line-height: 56px;
        font-size: 1.75rem;
    }
    
    /* Form controls - ensure readable text */
    .form-control,
    .form-select {
        font-size: 16px;
        min-height: 44px;
        padding: 0.5rem 0.75rem;
    }
    
    /* Labels - ensure readability */
    .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.35rem;
        display: block;
    }
    
    /* Buttons - minimum touch target */
    .btn {
        min-height: 44px;
        padding: 0.5rem 1rem;
        font-size: 1rem;
        touch-action: manipulation;
    }
    
    .btn-sm {
        min-height: 44px;
        padding: 0.35rem 0.75rem;
        font-size: 0.875rem;
    }
    
    .btn-lg {
        min-height: 48px;
        padding: 0.75rem 1.5rem;
        font-size: 1.1rem;
    }
    
    /* Wizard progress - stack on mobile */
    .wizard-progress ol {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .wizard-progress-step {
        min-width: 100%;
        text-align: left;
        padding: 0.5rem;
        border-bottom: 2px solid var(--border-color);
        border-left: 3px solid transparent;
    }
    
    .wizard-progress-step.active {
        border-left-color: var(--primary-blue);
        background-color: rgba(0, 51, 153, 0.05);
    }
    
    .wizard-progress-step.completed {
        border-left-color: var(--success-green);
    }
    
    .wizard-progress-num {
        width: 1.5rem;
        height: 1.5rem;
        font-size: 0.875rem;
    }
    
    .wizard-progress-label {
        font-size: 0.875rem;
    }
    
    /* Child section */
    .child-section {
        padding: 1rem !important;
    }
    
    .child-section legend.h5 {
        font-size: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    /* Remove child button */
    .remove-child {
        min-height: 44px;
        min-width: 44px;
        padding: 0.5rem;
    }
    
    /* Table responsiveness */
    .table-responsive {
        -webkit-overflow-scrolling: touch;
    }
    
    table {
        font-size: 0.875rem;
    }
    
    table th,
    table td {
        padding: 0.5rem;
        white-space: nowrap;
    }
    
    /* Alert messages */
    .alert {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .alert-heading {
        font-size: 1rem;
    }
    
    /* Review blocks */
    .review-block dt {
        font-size: 0.9rem;
    }
    
    .review-block dd {
        font-size: 0.875rem;
    }
    
    /* Footer */
    .school-footer {
        font-size: 0.75rem;
        padding: 1rem 0;
    }
    
    .school-footer p {
        font-size: 0.75rem;
    }
}

/* Extra small devices (phones, 375px and down - iPhone SE) */
@media (max-width: 375px) {
    html {
        font-size: 14px;
    }
    
    .school-name-greek {
        font-size: 1.1rem;
    }
    
    .school-name-german {
        font-size: 0.8rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
    
    h3 {
        font-size: 1.1rem;
    }
    
    .card-header h4 {
        font-size: 0.95rem;
    }
    
    .form-control,
    .form-select {
        font-size: 16px;
    }
}

/* Medium devices (tablets, 768px and down) */
@media (max-width: 768px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Stack columns on mobile */
    .row > [class*="col-"] {
        margin-bottom: 0.5rem;
    }
    
    /* Table headers - wrap text */
    .table th {
        white-space: normal;
        word-wrap: break-word;
        max-width: 150px;
    }
    
    /* Export page button */
    .btn-lg.text-nowrap {
        white-space: normal;
        word-wrap: break-word;
    }
}

/* Touch target enhancements for all mobile devices */
@media (pointer: coarse) {
    /* Ensure all interactive elements have minimum 44px touch target */
    a,
    button,
    input,
    select,
    textarea,
    [role="button"],
    [tabindex] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Form checkboxes and radios - touch devices */
    .form-check-input {
        width: 24px;
        height: 24px;
        margin-top: 0;
    }
    
    .form-check-label {
        padding: 8px 12px;
        margin-left: 4px;
        display: inline-flex;
        align-items: center;
    }
    
    .form-check {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    
    /* Links in content */
    .card-body a,
    .alert a {
        display: inline-block;
        padding: 4px 8px;
        margin: -4px -8px;
    }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
    }
    
    .btn {
        border-width: 2px;
    }
}

/* Print styles */
@media print {
    .school-header,
    .school-footer,
    .wizard-progress,
    .btn,
    nav {
        display: none !important;
    }
    
    body {
        background: white;
        font-size: 12pt;
    }
    
    .card {
        border: 1px solid #000;
        box-shadow: none;
    }
}

/* --- Honeypot field (anti-bot) ---------------------------------------
   Visually hidden and unreachable by keyboard/screen-reader users, but
   still a normal focusable-by-default input in the DOM so unsophisticated
   bots that fill in every field will populate it. */
.hp-field {
    position: absolute;
    left: -9999px;
    top: -9999px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

/* --- Multi-step wizard progress indicator ----------------------------- */
.wizard-progress ol {
    counter-reset: none;
}

.wizard-progress-step {
    flex: 1 1 auto;
    min-width: 100px;
    text-align: center;
    padding: 0.5rem 0.25rem;
    border-bottom: 3px solid var(--border-color);
    color: #6c757d;
    font-size: 0.85rem;
}

.wizard-progress-step.active {
    border-bottom-color: var(--primary-blue);
    color: var(--primary-blue);
    font-weight: 600;
}

.wizard-progress-step.completed {
    border-bottom-color: var(--success-green);
    color: var(--success-green);
}

.wizard-progress-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background-color: var(--border-color);
    color: #495057;
    font-weight: 700;
    margin-right: 0.35rem;
}

.wizard-progress-step.active .wizard-progress-num {
    background-color: var(--primary-blue);
    color: #fff;
}

.wizard-progress-step.completed .wizard-progress-num {
    background-color: var(--success-green);
    color: #fff;
}

.wizard-progress-label {
    display: inline-block;
    vertical-align: middle;
}

/* --- Review step summary ----------------------------------------------- */
.review-block {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
}

.review-block:last-child {
    border-bottom: none;
}

.review-block dt {
    font-weight: 600;
    color: #495057;
}

.review-block dd {
    margin-bottom: 0.4rem;
}

/* --- Touch target sizing (WCAG 2.5.5) ----------------------------------
    Add/remove-child controls and wizard navigation buttons get a larger
    minimum tap target on small screens. */
.remove-child,
#addChildBtn,
.wizard-next,
.wizard-back {
    min-height: 44px;
    min-width: 44px;
    touch-action: manipulation;
}

/* ==========================================================================
   ADDITIONAL MOBILE OPTIMIZATIONS
   ========================================================================== */

/* Prevent horizontal scroll */
html,
body {
    overflow-x: hidden;
    width: 100%;
}

/* Ensure main content doesn't overflow */
#main-content {
    overflow-x: hidden;
    max-width: 100%;
}

/* Fix table overflow on mobile */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Ensure buttons in card footers wrap properly */
.card-footer .d-flex {
    flex-wrap: wrap;
    gap: 0.5rem;
}

/* Fix long words breaking layout */
.card-body,
.alert,
.review-block {
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Ensure form inputs don't cause overflow */
.form-control,
.form-select {
    max-width: 100%;
}

/* Fix reference box on mobile */
.reference-box {
    padding: 0.75rem;
    word-break: break-all;
}

/* Optimize contribution display */
.contribution-display {
    font-size: 1rem;
}

/* Fix activity checkboxes layout on mobile */
.d-flex.flex-wrap.gap-3 {
    gap: 0.75rem !important;
}

/* Activity fieldset alignment */
fieldset .form-label,
fieldset legend {
    margin-bottom: 0.5rem;
}

fieldset .d-flex .form-check {
    margin-bottom: 0;
}

.form-check {
    min-width: 120px;
}

/* ==========================================================================
   CHECKBOX & RADIO ACCESSIBILITY ENHANCEMENTS
   WCAG 2.1 AA/AAA - Visibility, Focus, Touch Targets
   ========================================================================== */

/* Base checkbox/radio styling - ALL devices */
.form-check-input {
    width: 22px !important;
    height: 22px !important;
    margin-top: 0 !important;
    border: 2px solid #6c757d !important;
    cursor: pointer;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, background-color 0.15s ease-in-out;
    flex-shrink: 0;
    vertical-align: middle;
}

/* Align form-check container items vertically */
.form-check {
    display: flex;
    align-items: center;
    min-height: 32px;
}

/* Hover state - critical for visibility */
.form-check-input:hover {
    border-color: #0d6efd !important;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.15) !important;
}

/* Focus state - WCAG 2.4.7 compliance */
.form-check-input:focus {
    border-color: #0d6efd !important;
    outline: none;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.4), 0 0 0 6px rgba(13, 110, 253, 0.15) !important;
}

/* Focus-visible for keyboard navigation */
.form-check-input:focus-visible {
    border-color: #0d6efd !important;
    outline: 3px solid #0d6efd;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.4);
}

/* Checked state enhancement */
.form-check-input:checked {
    background-color: #0d6efd !important;
    border-color: #0d6efd !important;
}

/* Checked + focus combination */
.form-check-input:checked:focus {
    box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.4), 0 0 0 6px rgba(13, 110, 253, 0.15) !important;
}

/* Invalid/error state */
.form-check-input.is-invalid,
.form-check-input:invalid {
    border-color: #dc3545;
}

.form-check-input.is-invalid:focus,
.form-check-input:invalid:focus {
    box-shadow: 0 0 0 4px rgba(220, 53, 69, 0.4);
}

/* Label enhancements - improved click/touch target */
.form-check-label {
    padding: 4px 8px;
    margin-left: 2px;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.15s ease-in-out;
    display: inline-flex;
    align-items: center;
    line-height: 1.4;
}

/* Label hover state */
.form-check-label:hover {
    background-color: rgba(13, 110, 253, 0.05);
}

/* Label focus (when checkbox receives focus) */
.form-check-input:focus + .form-check-label {
    background-color: rgba(13, 110, 253, 0.08);
}

/* Required checkbox indicator */
.form-check-required .form-check-label::after {
    content: ' *';
    color: #dc3545;
    font-weight: 700;
    font-size: 1.1em;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .form-check-input {
        border-width: 3px;
        border-color: #000000;
    }
    
    .form-check-input:checked {
        background-color: #000000;
        border-color: #000000;
    }
    
    .form-check-input:focus {
        outline: 3px solid #000000;
        outline-offset: 2px;
    }
}

/* Ensure error messages are readable */
.invalid-feedback,
.text-danger {
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Fix admin table for mobile */
@media (max-width: 768px) {
    .table th,
    .table td {
        max-width: 200px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .table td code {
        word-break: break-all;
        font-size: 0.75rem;
    }
}

/* Loading state for submit button */
#submitBtn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Ensure proper spacing for mobile */
@media (max-width: 576px) {
    .mb-4 {
        margin-bottom: 1.5rem !important;
    }
    
    .mt-5 {
        margin-top: 2rem !important;
    }
    
    .p-4 {
        padding: 1rem !important;
    }
    
    .p-3 {
        padding: 0.75rem !important;
    }
}

/* Fix for iOS Safari viewport issue */
@supports (-webkit-touch-callout: none) {
    .school-header {
        padding-top: env(safe-area-inset-top);
    }
    
    .school-footer {
        padding-bottom: env(safe-area-inset-bottom);
    }
}

/* --- Visually hidden (screen reader only) ------------------------------
    Content is hidden visually but remains available to screen readers.
    Used for accessibility announcements and error counts. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}
