/* ==========================================================================
   Accessibility Floating Widget & Global Modifier System
   --------------------------------------------------------------------------
   CONTENTS:
   0. Color Custom Properties (:root Variables)
   1. Floating Launcher Button
   2. Control Panel Card (Modal UI)
   3. Panel Option Controls (Switches, Sizing Grid, Buttons)
   4. A11y Modifier Modes
      4.1 High Contrast Mode (.a11y-high-contrast)
      4.2 Text Scaling Mode (.a11y-font-large, .a11y-font-xlarge)
      4.3 Dyslexic Typography (.a11y-dyslexic)
      4.4 Keyboard Focus Outlines (.a11y-highlight-focus)
   5. Native Dark Theme (.a11y-dark-mode)
      5.1 Base Page & Layout Containers
      5.2 Navigation Bars & Sidebars (.subnav, .nav)
      5.3 Form Controls & Buttons
      5.4 Tables & Reservation Lists (#orderList, #orderHours, #orderTables)
      5.5 Accordion Groups (.template-group)
      5.6 Dialogs & Datepicker Modal (#customDatePickerModal)
   ========================================================================== */

/* ==========================================================================
   0. COLOR CUSTOM PROPERTIES (:ROOT VARIABLES)
   ========================================================================== */
:root {
    /* Widget & Light Theme Palette */
    --a11y-primary: #2f244b;
    --a11y-accent: #5ca0ca;
    --a11y-focus-ring: #ff9f00;
    --a11y-danger: #e03a3a;
    --a11y-danger-hover: #f06e76;
    --a11y-white: #ffffff;
    --a11y-black: #343434;
    --a11y-grey-light: #fafafa;
    --a11y-grey-hover: #f2f2f2;
    --a11y-border: #e9e9e9;
    --a11y-input-border: #cacaca;
    --a11y-text-desc: #777777;

    /* High Contrast Palette (WCAG AAA) */
    --a11y-hc-bg: #121212;
    --a11y-hc-black: #000000;
    --a11y-hc-cyan: #00ffff;
    --a11y-hc-yellow: #ffff00;

    /* Native Dark Theme Palette */
    --a11y-dark-bg: #121214;
    --a11y-dark-surface: #1a1a1e;
    --a11y-dark-card: #24242b;
    --a11y-dark-border: #2e2e34;
    --a11y-dark-input-border: #3f3f46;
    --a11y-dark-hover: #334155;
    --a11y-dark-text: #e2e8f0;
    --a11y-dark-muted: #94a3b8;
    --a11y-dark-placeholder: #71717a;
    --a11y-dark-sky: #38bdf8;
    --a11y-dark-sky-hover: #7dd3fc;
    --a11y-dark-sky-active: #0284c7;
}

/* ==========================================================================
   1. FLOATING LAUNCHER BUTTON
   ========================================================================== */
.a11y-launcher-btn {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary, var(--a11y-primary));
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    border: none;
    cursor: pointer;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    outline: none;
}

.a11y-launcher-btn:hover,
.a11y-launcher-btn:focus {
    transform: scale(1.08) rotate(10deg);
    background: var(--accent, var(--a11y-accent));
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.a11y-launcher-btn svg {
    width: 28px;
    height: 28px;
    fill: var(--a11y-white);
    transition: transform 0.3s ease;
}

/* ==========================================================================
   2. CONTROL PANEL CARD (MODAL UI)
   ========================================================================== */
.a11y-panel-card {
    position: fixed;
    bottom: 96px;
    left: 24px;
    width: 340px;
    max-width: 90vw;
    background: var(--a11y-white);
    border: 1px solid var(--border, var(--a11y-border));
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    z-index: 99998;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    font-family: "Plus Jakarta Sans", sans-serif;
}

.a11y-panel-card.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* Header Section */
.a11y-header {
    background: var(--primary, var(--a11y-primary));
    padding: 16px 20px;
    color: var(--a11y-white);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.a11y-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.5px;
    color: var(--a11y-white) !important;
}

.a11y-close-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 4px;
    transition: color 0.2s ease;
}

.a11y-close-btn:hover {
    color: var(--a11y-white);
}

/* Body Section */
.a11y-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--a11y-white);
}

/* ==========================================================================
   3. PANEL OPTION CONTROLS (SWITCHES, SIZING GRID, BUTTONS)
   ========================================================================== */
.a11y-option-group {
    background: var(--grey, var(--a11y-grey-light));
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s ease;
    border: 1px solid var(--border, var(--a11y-border));
}

.a11y-option-group:hover {
    background: var(--grey-2, var(--a11y-grey-hover));
}

.a11y-option-label {
    display: flex;
    flex-direction: column;
    font-weight: 600;
    color: var(--black, var(--a11y-black));
    font-size: 0.95rem;
    cursor: pointer;
    user-select: none;
    flex-grow: 1;
}

.a11y-option-desc {
    font-size: 0.75rem;
    color: var(--a11y-text-desc);
    font-weight: 400;
    margin-top: 2px;
}

/* Toggle Switch Capsule */
.a11y-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 28px;
    flex-shrink: 0;
    cursor: pointer;
}

.a11y-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.a11y-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--input-border, var(--a11y-input-border));
    transition: 0.3s;
    border-radius: 34px;
}

.a11y-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: var(--a11y-white);
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

input:checked + .a11y-slider {
    background-color: var(--primary, var(--a11y-primary));
}

input:focus + .a11y-slider {
    box-shadow: 0 0 1px var(--primary, var(--a11y-primary));
}

input:checked + .a11y-slider:before {
    transform: translateX(20px);
}

/* Text Sizing Button Grid */
.a11y-size-grid {
    display: flex;
    gap: 8px;
}

.a11y-size-btn {
    flex: 1;
    background: var(--a11y-white);
    border: 1px solid var(--input-border, var(--a11y-input-border));
    padding: 8px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    color: var(--black, var(--a11y-black));
    display: flex;
    align-items: center;
    justify-content: center;
}

.a11y-size-btn:hover {
    background: var(--grey, var(--a11y-grey-light));
    border-color: var(--accent, var(--a11y-accent));
}

.a11y-size-btn.active {
    background: var(--primary, var(--a11y-primary));
    border-color: var(--primary, var(--a11y-primary));
    color: var(--a11y-white);
}

/* Reset Footer Action Button */
.a11y-reset-btn {
    background: none;
    border: none;
    color: var(--red, var(--a11y-danger));
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    text-align: center;
    padding: 8px 0 0 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.2s ease;
}

.a11y-reset-btn:hover {
    color: var(--red2, var(--a11y-danger-hover));
    text-decoration: underline;
}

/* ==========================================================================
   4. ACCESSIBILITY MODIFIER STATES (APPLIED TO HTML / BODY)
   ========================================================================== */

/* 4.1 High Contrast Mode (WCAG AAA Compliance) */
body.a11y-high-contrast {
    background-color: var(--a11y-hc-bg) !important;
    color: var(--a11y-white) !important;
}

body.a11y-high-contrast *:not(.a11y-panel-card):not(.a11y-panel-card *) {
    background-color: var(--a11y-hc-bg) !important;
    color: var(--a11y-white) !important;
    border-color: var(--a11y-white) !important;
    text-shadow: none !important;
    box-shadow: none !important;
}

body.a11y-high-contrast a:not(.a11y-panel-card *) {
    color: var(--a11y-hc-cyan) !important;
    text-decoration: underline !important;
    font-weight: 700 !important;
}

body.a11y-high-contrast button:not(.a11y-panel-card *),
body.a11y-high-contrast input:not(.a11y-panel-card *),
body.a11y-high-contrast select:not(.a11y-panel-card *) {
    border: 2px solid var(--a11y-white) !important;
    background: var(--a11y-hc-black) !important;
    color: var(--a11y-hc-yellow) !important;
}

body.a11y-high-contrast .status,
body.a11y-high-contrast .table-marker {
    background: var(--a11y-hc-black) !important;
    border: 3px double var(--a11y-white) !important;
    color: var(--a11y-white) !important;
}

/* 4.2 Proportional Root Text Scaling */
html.a11y-font-large,
:root.a11y-font-large,
body.a11y-font-large {
    font-size: 78.125% !important; /* 1.25x scale of 62.5% base */
}

html.a11y-font-xlarge,
:root.a11y-font-xlarge,
body.a11y-font-xlarge {
    font-size: 93.75% !important; /* 1.50x scale of 62.5% base */
}

/* 4.3 Dyslexic-Friendly Typography Overrides */
body.a11y-dyslexic,
body.a11y-dyslexic p,
body.a11y-dyslexic span,
body.a11y-dyslexic a,
body.a11y-dyslexic h1,
body.a11y-dyslexic h2,
body.a11y-dyslexic h3,
body.a11y-dyslexic h4,
body.a11y-dyslexic td,
body.a11y-dyslexic button,
body.a11y-dyslexic input,
body.a11y-dyslexic select {
    font-family: 'Comic Sans MS', cursive, sans-serif !important;
    letter-spacing: 0.12em !important;
    word-spacing: 0.16em !important;
    line-height: 1.6 !important;
}

/* 4.4 High Visibility Keyboard Focus Outlines */
body.a11y-highlight-focus *:focus,
body.a11y-highlight-focus *:focus-within {
    outline: 4px solid var(--a11y-focus-ring) !important;
    outline-offset: 4px !important;
    box-shadow: 0 0 12px var(--a11y-focus-ring) !important;
}

body.a11y-highlight-focus .a11y-switch input:focus + .a11y-slider,
.a11y-switch input:focus + .a11y-slider {
    outline: 3px solid var(--a11y-focus-ring) !important;
    outline-offset: 3px !important;
    box-shadow: 0 0 8px var(--a11y-focus-ring) !important;
}

body.a11y-highlight-focus a:hover,
body.a11y-highlight-focus button:hover,
body.a11y-highlight-focus input:hover,
body.a11y-highlight-focus select:hover,
body.a11y-highlight-focus .table-marker:hover,
body.a11y-highlight-focus .a11y-launcher-btn:hover {
    outline: 3px dashed var(--a11y-focus-ring) !important;
    outline-offset: 2px !important;
}

/* ==========================================================================
   5. NATIVE DARK THEME SUPPORT (.a11y-dark-mode)
   ========================================================================== */

/* 5.1 Base Page & Core Layout Containers */
html.a11y-dark-mode,
body.a11y-dark-mode {
    background-color: var(--a11y-dark-bg) !important;
    color: var(--a11y-dark-text) !important;
}

body.a11y-dark-mode *:not(.a11y-panel-card):not(.a11y-panel-card *) {
    color: var(--a11y-dark-text);
}

body.a11y-dark-mode div.left,
body.a11y-dark-mode div.rectangle,
body.a11y-dark-mode div.center-block,
body.a11y-dark-mode .sidebar,
body.a11y-dark-mode .card,
body.a11y-dark-mode .panel,
body.a11y-dark-mode .modal-content,
body.a11y-dark-mode .dashboard-box,
body.a11y-dark-mode header,
body.a11y-dark-mode footer,
body.a11y-dark-mode .navbar,
body.a11y-dark-mode .admin-box,
body.a11y-dark-mode .login-box {
    background-color: var(--a11y-dark-surface) !important;
    border-color: var(--a11y-dark-border) !important;
    color: var(--a11y-white) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25) !important;
}

body.a11y-dark-mode h1, body.a11y-dark-mode .h1,
body.a11y-dark-mode h2, body.a11y-dark-mode .h2,
body.a11y-dark-mode h3, body.a11y-dark-mode .h3,
body.a11y-dark-mode h4, body.a11y-dark-mode .h4,
body.a11y-dark-mode h5, body.a11y-dark-mode .h6, 
body.a11y-dark-mode strong {
    color: var(--a11y-white) !important;
}

/* 5.2 Navigation Bars & Sidebars */
body.a11y-dark-mode .subnav {
    background-color: var(--a11y-dark-surface) !important;
    border-bottom: 1px solid var(--a11y-dark-border) !important;
}

body.a11y-dark-mode .subnav-items,
body.a11y-dark-mode .subnav-items a {
    color: var(--a11y-dark-text) !important;
}

body.a11y-dark-mode .subnav-items.active,
body.a11y-dark-mode .subnav-items.active a,
body.a11y-dark-mode .subnav-items span,
body.a11y-dark-mode .btn-new-reservation {
    color: var(--a11y-dark-sky) !important;
    border-bottom-color: var(--a11y-dark-sky) !important;
}

body.a11y-dark-mode .nav,
body.a11y-dark-mode #nav {
    background-color: var(--a11y-dark-surface) !important;
    border-right: 1px solid var(--a11y-dark-border) !important;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.4) !important;
}

body.a11y-dark-mode .nav .nav-item,
body.a11y-dark-mode #nav .nav-item {
    color: var(--a11y-dark-text) !important;
}

body.a11y-dark-mode .nav .nav-item:hover,
body.a11y-dark-mode #nav .nav-item:hover {
    color: var(--a11y-white) !important;
}

body.a11y-dark-mode .nav .nav-item--active,
body.a11y-dark-mode #nav .nav-item--active {
    color: var(--a11y-dark-sky) !important;
    font-weight: 700 !important;
}

/* 5.3 Form Controls & Interactive Buttons */
body.a11y-dark-mode input:not(.a11y-panel-card *),
body.a11y-dark-mode select:not(.a11y-panel-card *),
body.a11y-dark-mode textarea:not(.a11y-panel-card *),
body.a11y-dark-mode .form-control {
    background-color: var(--a11y-dark-card) !important;
    color: var(--a11y-white) !important;
    border: 1px solid var(--a11y-dark-input-border) !important;
}

body.a11y-dark-mode input::placeholder,
body.a11y-dark-mode textarea::placeholder {
    color: var(--a11y-dark-placeholder) !important;
}

body.a11y-dark-mode a:not(.a11y-panel-card *):not(.btn) {
    color: var(--a11y-dark-sky) !important;
}

body.a11y-dark-mode a:not(.a11y-panel-card *):not(.btn):hover {
    color: var(--a11y-dark-sky-hover) !important;
    text-decoration: underline !important;
}

body.a11y-dark-mode .btn-outline {
    border-color: var(--a11y-dark-sky) !important;
    color: var(--a11y-dark-sky) !important;
    background-color: transparent !important;
}

body.a11y-dark-mode .btn-outline.active {
    background-color: var(--a11y-dark-sky) !important;
    color: var(--a11y-dark-bg) !important;
}

/* 5.4 Tables & Reservation Lists */
body.a11y-dark-mode table,
body.a11y-dark-mode .table,
body.a11y-dark-mode [role="table"],
body.a11y-dark-mode #orderList,
body.a11y-dark-mode #orderHours,
body.a11y-dark-mode #orderTables {
    background-color: var(--a11y-dark-surface) !important;
    border-color: var(--a11y-dark-border) !important;
}

body.a11y-dark-mode tr,
body.a11y-dark-mode td,
body.a11y-dark-mode th,
body.a11y-dark-mode [role="row"],
body.a11y-dark-mode [role="cell"],
body.a11y-dark-mode [role="columnheader"],
body.a11y-dark-mode #orderList .reservation-header,
body.a11y-dark-mode #orderHours .reservation-header,
body.a11y-dark-mode #orderTables .reservation-header,
body.a11y-dark-mode #orderList .reservation-row,
body.a11y-dark-mode #orderHours .reservation-row,
body.a11y-dark-mode #orderTables .reservation-row {
    border-color: var(--a11y-dark-border) !important;
    color: var(--a11y-dark-text) !important;
}

body.a11y-dark-mode .reservation-header,
body.a11y-dark-mode [role="columnheader"],
body.a11y-dark-mode th,
body.a11y-dark-mode #orderList .table-header,
body.a11y-dark-mode #orderHours .table-header,
body.a11y-dark-mode #orderTables .table-header {
    background: var(--a11y-dark-card) !important;
    background-color: var(--a11y-dark-card) !important;
    border-color: var(--a11y-dark-border) !important;
    color: var(--a11y-white) !important;
}

body.a11y-dark-mode #orderList .reservation-row:nth-child(odd),
body.a11y-dark-mode #orderHours .reservation-row:nth-child(odd),
body.a11y-dark-mode #orderTables .reservation-row:nth-child(odd) {
    background-color: var(--a11y-dark-card) !important;
}

body.a11y-dark-mode #orderList .table-items,
body.a11y-dark-mode #orderHours .table-items,
body.a11y-dark-mode #orderTables .table-items,
body.a11y-dark-mode #orderList .reservation-row-wrap,
body.a11y-dark-mode #orderHours .reservation-row-wrap,
body.a11y-dark-mode #orderTables .reservation-row-wrap {
    color: var(--a11y-dark-text) !important;
}

body.a11y-dark-mode #orderHours h4,
body.a11y-dark-mode #orderTables h4 {
    color: var(--a11y-dark-sky) !important;
}

body.a11y-dark-mode .floor-plan,
body.a11y-dark-mode .table-graphic,
body.a11y-dark-mode svg.floor-plan-svg {
    background-color: #131316 !important;
    border-color: var(--a11y-dark-border) !important;
}

body.a11y-dark-mode .table-marker {
    background-color: var(--a11y-dark-card) !important;
    border-color: var(--a11y-dark-input-border) !important;
    color: var(--a11y-white) !important;
}

/* 5.5 Mail Template Accordion Groups */
body.a11y-dark-mode .template-header,
body.a11y-dark-mode .template-header.template-item {
    background-color: var(--a11y-dark-card) !important;
    border-color: var(--a11y-dark-border) !important;
    color: var(--a11y-white) !important;
}

body.a11y-dark-mode .template-item {
    background-color: var(--a11y-dark-surface) !important;
    border-bottom-color: var(--a11y-dark-border) !important;
    color: var(--a11y-dark-text) !important;
}

body.a11y-dark-mode .template-item-option-title,
body.a11y-dark-mode .template-item-title,
body.a11y-dark-mode .template-item-number {
    color: var(--a11y-dark-text) !important;
}

body.a11y-dark-mode .template-group.active .template-item-option-title {
    color: var(--a11y-dark-sky) !important;
}

/* 5.6 Dialogs & Custom Datepicker Modal */
body.a11y-dark-mode dialog,
body.a11y-dark-mode #customDatePickerModal {
    background: transparent !important;
    color: var(--a11y-dark-text) !important;
}

body.a11y-dark-mode dialog::backdrop,
body.a11y-dark-mode #customDatePickerModal::backdrop {
    background: rgba(0, 0, 0, 0.75) !important;
}

body.a11y-dark-mode .modal-wrap {
    background-color: var(--a11y-dark-surface) !important;
    border: 1px solid var(--a11y-dark-border) !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5) !important;
    color: var(--a11y-dark-text) !important;
}

body.a11y-dark-mode .modal-topbar {
    background-color: var(--a11y-dark-card) !important;
    border-bottom: 1px solid var(--a11y-dark-border) !important;
}

body.a11y-dark-mode .modal-topbar-text {
    color: var(--a11y-dark-sky) !important;
}

body.a11y-dark-mode .calendar-nav button img {
    filter: brightness(0) invert(1) !important;
}

body.a11y-dark-mode .calendar-nav span,
body.a11y-dark-mode #dpMonthLabel {
    color: var(--a11y-white) !important;
}

body.a11y-dark-mode .weekday {
    color: var(--a11y-dark-muted) !important;
}

body.a11y-dark-mode .day {
    background-color: var(--a11y-dark-card) !important;
    border: 1px solid var(--a11y-dark-border) !important;
    color: var(--a11y-dark-text) !important;
}

body.a11y-dark-mode .day .day-inner {
    color: var(--a11y-dark-text) !important;
}

body.a11y-dark-mode .day:hover {
    background-color: var(--a11y-dark-hover) !important;
}

body.a11y-dark-mode .day.selected {
    background-color: var(--a11y-primary) !important;
    border: 2px solid var(--a11y-dark-sky) !important;
}

body.a11y-dark-mode .day.selected .day-inner {
    color: var(--a11y-white) !important;
}

body.a11y-dark-mode .day.today {
    background-color: var(--a11y-dark-sky-active) !important;
}

body.a11y-dark-mode .day.today .day-inner {
    color: var(--a11y-white) !important;
}
