/* ===== CSS Custom Properties (Theme Variables) ===== */
:root {
    /* Normal Theme Colors */
    --bg-color: #ffffff;
    --text-color: #333333;
    --heading-color: #222222;
    --link-color: #0066cc;
    --link-hover: #004499;
    --border-color: #dddddd;
    --panel-bg: #f5f5f5;
    --button-bg: #0066cc;
    --button-text: #ffffff;
    --button-hover: #004499;
    
    /* Font Size */
    --base-font-size: 16px;
}

/* High Contrast Theme */
body.theme-high-contrast {
    --bg-color: #000000;
    --text-color: #ffffff;
    --heading-color: #ffffff;
    --link-color: #ffff00;
    --link-hover: #ffff99;
    --border-color: #ffffff;
    --panel-bg: #1a1a1a;
    --button-bg: #ffff00;
    --button-text: #000000;
    --button-hover: #ffff99;
}

/* Dark Mode Theme */
body.theme-dark {
    --bg-color: #1a1a1a;
    --text-color: #e0e0e0;
    --heading-color: #ffffff;
    --link-color: #66b3ff;
    --link-hover: #99ccff;
    --border-color: #444444;
    --panel-bg: #2a2a2a;
    --button-bg: #66b3ff;
    --button-text: #000000;
    --button-hover: #99ccff;
}

/* Font Size Classes */
body.font-normal {
    --base-font-size: 16px;
}

body.font-large {
    --base-font-size: 20px;
}

body.font-xlarge {
    --base-font-size: 24px;
}

/* Apply Theme Variables */
body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: var(--base-font-size);
    transition: background-color 0.3s ease, color 0.3s ease, font-size 0.2s ease;
}

h1, h2, h3, h4, h5, h6 {
    color: var(--heading-color) !important;
}

a {
    color: var(--link-color) !important;
}

a:hover {
    color: var(--link-hover) !important;
}

/* Apply theme to common elements */
section, .clinic-card, .doctor-card, .clinic-page, .clinic-header, 
.opening-hours, .clinics, .doctors, .contact-info {
    background-color: var(--panel-bg) !important;
    color: var(--text-color) !important;
}

.intro, .contact-details, .clinic-description, .doctor-card p, 
.clinic-card p, .rich-text, .contact-details p, .specialization {
    color: var(--text-color) !important;
}

.clinic-card, .doctor-card {
    border-color: var(--border-color) !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2) !important;
}

.clinic-card:hover, .doctor-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.3) !important;
}

strong {
    color: var(--heading-color) !important;
}

.hours-table td, .day-name, .hours-time {
    color: var(--text-color) !important;
}

.clinic-address, .doctor-item {
    background-color: var(--bg-color) !important;
    color: var(--text-color) !important;
}

/* Ensure buttons and interactive elements use theme */
button, .map-link {
    background-color: var(--button-bg) !important;
    color: var(--button-text) !important;
}

button:hover, .map-link:hover {
    background-color: var(--button-hover) !important;
}

/* Border adjustments for themes */
.clinic-header, section h2, .hours-table tr, .clinic-hours, 
.clinic-doctors, .doctor-contact {
    border-color: var(--border-color) !important;
}

/* ===== Accessibility Widget Styles ===== */
.accessibility-widget {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
}

.a11y-toggle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--button-bg);
    color: var(--button-text);
    border: 2px solid var(--border-color);
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, background-color 0.3s ease;
}

.a11y-toggle:hover {
    transform: scale(1.1);
    background-color: var(--button-hover);
}

.a11y-toggle:focus {
    outline: 3px solid var(--link-color);
    outline-offset: 2px;
}

.a11y-panel {
    position: absolute;
    top: 60px;
    right: 0;
    width: 280px;
    background-color: var(--panel-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.a11y-panel.hidden {
    display: none;
}

.a11y-panel h3 {
    margin: 0 0 15px 0;
    font-size: 1.2em;
    color: var(--heading-color);
}

.a11y-section {
    margin-bottom: 20px;
}

.a11y-section label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    font-size: 0.9em;
    color: var(--text-color);
}

.a11y-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.a11y-btn {
    flex: 1;
    min-width: 70px;
    padding: 10px 12px;
    background-color: var(--button-bg);
    color: var(--button-text);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.a11y-btn:hover {
    background-color: var(--button-hover);
    transform: translateY(-2px);
}

.a11y-btn:focus {
    outline: 3px solid var(--link-color);
    outline-offset: 2px;
}

.a11y-btn.active {
    background-color: var(--link-color);
    border-color: var(--link-color);
    color: #ffffff;
}

.a11y-reset {
    width: 100%;
    padding: 10px;
    background-color: #666666;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: bold;
    transition: background-color 0.2s ease;
}

.a11y-reset:hover {
    background-color: #888888;
}

.a11y-reset:focus {
    outline: 3px solid var(--link-color);
    outline-offset: 2px;
}

/* Responsive: Hide widget on small screens or show simplified version */
@media (max-width: 768px) {
    .accessibility-widget {
        top: 10px;
        right: 10px;
    }
    
    .a11y-toggle {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    
    .a11y-panel {
        width: 250px;
        padding: 15px;
    }
}