/*
 * Modern Blue Survey Theme - Base Styles
 * Version: 1.0.0
 *
 * Purpose: Foundation styles and vanilla theme overrides
 * This file provides essential base styling and neutralizes
 * vanilla theme conflicts with the modern dark theme.
 *
 * Load order: base.css → variables.css → custom.css → responsive.css
 *
 * Structure:
 * 1. Vanilla Overrides - Neutralize conflicting vanilla styles
 * 2. Essential Compatibility - Keep critical vanilla functionality
 * 3. Dark Theme Foundations - Base dark theme styles
 * 4. Bootstrap Compatibility - Migration helpers
 * 5. RTL Support - Right-to-left language support
 * 6. Accessibility Foundations - Screen reader & keyboard navigation
 * 7. Print Foundations - Base print styles
 */

/* ==================== 1. VANILLA OVERRIDES ==================== */
/* Neutralize vanilla styles that conflict with dark theme */

/* Override .well class - make transparent for dark theme
 * Vanilla uses light gray background (#f5f5f5) which conflicts with dark theme
 * Used in: group descriptions, help text containers, info boxes
 */
.well {
    background-color: transparent !important;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
    padding: 0 !important;
    min-height: auto !important;
}

/* Specific override for group-description with .well class */
div.group-description.well,
.well.group-description.row,
div.well.group-description.row.space-col {
    background: transparent !important;
    background-color: transparent !important;
    background-image: none !important;
}

/* Reset heading margins - we control spacing in custom.css
 * Vanilla adds 2rem top margin which can create unwanted spacing
 */
.h1, .h2, .h3, h1, h2, h3 {
    margin-top: 0;
    margin-bottom: 0;
}

.h4, .h5, .h6, h4, h5, h6 {
    margin-top: 0;
    margin-bottom: 0;
}

/* Reduce body padding - we use custom header instead of fixed navbar
 * Vanilla sets padding-top: 90px for fixed navbar
 * LimeSurvey's JavaScript sets inline style="padding-top: 43px"
 * Override all variations with 10px for tighter spacing
 */
body {
    padding-top: 10px !important;
    padding-bottom: 0 !important;
}

/* Additional override with higher specificity for body element */
/* This overrides inline styles set by JavaScript */
html body,
body.survey_modern_blue,
body#bodyelement,
body[style*="padding-top"] {
    padding-top: 10px !important;
}

/* ==================== 2. ESSENTIAL COMPATIBILITY ==================== */
/* Keep critical vanilla base.css rules needed for functionality */

/* Index button list spacing
 * Removes spacing between list group items in navigation
 */
.index-button .list-group:not(:last-child) {
    margin-bottom: -1px;
}

/* Table borders for matrix questions
 * Ensures borders inherit theme colors for consistent appearance
 */
tbody, td, tfoot, th, thead, tr {
    border: 1px solid;
    border-color: inherit;
}

/* Responsive form label alignment
 * Ensures proper label positioning for horizontal forms on mobile/desktop
 * Critical for sub-questions with labels
 */
@media (max-width: 768px) {
    .form-horizontal .control-label.col-12 {
        text-align: left;
    }

    .dir-rtl .form-horizontal .control-label.col-12 {
        text-align: right;
    }
}

@media (min-width: 769px) {
    .form-horizontal .control-label.col-12 {
        text-align: right;
    }

    .dir-rtl .form-horizontal .control-label.col-12 {
        text-align: left;
    }
}

/* ==================== 3. DARK THEME FOUNDATIONS ==================== */
/* Base styles for dark theme before custom.css applies detailed styling */

/* Global dark theme base
 * Ensures dark background is applied even before custom.css loads
 */
html, body {
    background-color: #000000 !important;
    color: #FFFFFF;
    margin: 0;
    padding: 0;
}

/* Default link colors for dark theme
 * Vanilla uses blue links (#007bff) which don't have enough contrast on dark
 */
a {
    color: #06AFFF;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover {
    color: #3dc2ff;
    text-decoration: underline;
}

a:focus {
    outline: 2px solid #06AFFF;
    outline-offset: 2px;
}

/* Default text colors
 * Ensures text inherits proper color from parent containers
 */
body, p, div, span, label {
    color: inherit;
}

/* ==================== 4. BOOTSTRAP COMPATIBILITY ==================== */
/* Additional Bootstrap 3 → 5 compatibility classes */

/* Form control static
 * For read-only form displays in Bootstrap 3 style
 */
.form-control-static {
    padding-top: 7px;
    padding-bottom: 7px;
    margin-bottom: 0;
    min-height: 34px;
}

/* Panel to Card migration helpers
 * Bootstrap 3 used panels, Bootstrap 4/5 uses cards
 */
.panel {
    background: transparent;
    border: none;
    margin-bottom: 20px;
}

.panel-body {
    padding: 0;
}

.panel-heading {
    padding: 0;
    border: none;
    background: transparent;
}

/* ==================== 5. RTL SUPPORT ==================== */
/* Right-to-left language support foundations */

.dir-rtl {
    direction: rtl;
    text-align: right;
}

.dir-ltr {
    direction: ltr;
    text-align: left;
}

/* RTL-specific adjustments */
.dir-rtl .pull-left {
    float: right !important;
}

.dir-rtl .pull-right {
    float: left !important;
}

/* ==================== 6. ACCESSIBILITY FOUNDATIONS ==================== */
/* Screen reader only content and accessibility helpers */

/* Screen reader only class
 * Hides content visually but keeps it available to screen readers
 */
.sr-only,
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Focusable screen reader content
 * Shows hidden content when focused (e.g., skip links)
 */
.sr-only-focusable:focus,
.visually-hidden-focusable:focus {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* Skip to main content link
 * Accessibility helper for keyboard navigation
 */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #06AFFF;
    color: #000;
    padding: 8px;
    text-decoration: none;
    z-index: 10000;
}

.skip-link:focus {
    top: 0;
}

/* Focus visible improvements
 * Better focus indicators for keyboard navigation
 */
*:focus-visible {
    outline: 2px solid #06AFFF;
    outline-offset: 2px;
}

/* ==================== 7. PRINT FOUNDATIONS ==================== */
/* Base print styles for surveys */

@media print {
    /* Reset to light theme for printing */
    body {
        background: white !important;
        color: black !important;
    }

    /* Hide non-printable elements */
    .no-print,
    .navbar,
    .progress-bar,
    .navigation-buttons,
    button,
    .btn {
        display: none !important;
    }

    /* Ensure text is readable */
    a {
        color: #000 !important;
        text-decoration: underline !important;
    }

    /* Page breaks */
    .question-container,
    .group-container {
        page-break-inside: avoid;
    }

    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
    }
}

/* ==================== END OF BASE.CSS ==================== */
