/* ==========================================================================
   ACCESSIBILITY CSS
   Comprehensive accessibility improvements for Morocco Taxi Booking Platform
   WCAG 2.1 AA Compliant
   ========================================================================== */

/* ==========================================================================
   FOCUS MANAGEMENT
   ========================================================================== */

/* Enhanced Focus Indicators */
:focus {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
    border-radius: 2px;
}

/* Remove default focus for mouse users, keep for keyboard users */
:focus:not(:focus-visible) {
    outline: none;
}

:focus-visible {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
    border-radius: 2px;
    box-shadow: 0 0 0 1px #ffffff;
}

/* Focus within containers */
:focus-within {
    outline: 2px solid #005fcc;
    outline-offset: 1px;
}

/* Skip to content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: #000;
    color: #fff;
    padding: 8px;
    text-decoration: none;
    border-radius: 0 0 4px 4px;
    z-index: 10000;
    font-weight: bold;
    transition: top 0.3s ease;
}

.skip-link:focus {
    top: 0;
    outline: 3px solid #005fcc;
}

/* ==========================================================================
   KEYBOARD NAVIGATION
   ========================================================================== */

/* Interactive elements keyboard styles */
button:focus,
input:focus,
select:focus,
textarea:focus,
a:focus,
[tabindex]:focus {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}

/* Custom focus for specific components */
.btn:focus {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
    box-shadow: 0 0 0 1px #ffffff, 0 0 0 4px #005fcc;
}

.card:focus {
    outline: 2px solid #005fcc;
    outline-offset: 2px;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 95, 204, 0.3);
}

/* Tab navigation indicators */
.tab-list {
    display: flex;
    border-bottom: 2px solid #e0e0e0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.tab-list .tab {
    position: relative;
    background: none;
    border: none;
    padding: 12px 24px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
}

.tab-list .tab:hover {
    background-color: #f5f5f5;
}

.tab-list .tab:focus {
    outline: 3px solid #005fcc;
    outline-offset: -3px;
}

.tab-list .tab[aria-selected="true"] {
    border-bottom-color: #f7b731;
    background-color: #fff;
    font-weight: bold;
}

/* ==========================================================================
   SCREEN READER SUPPORT
   ========================================================================== */

/* Screen reader only text */
.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Screen reader only text that becomes visible on focus */
.sr-only-focusable:focus {
    position: static !important;
    width: auto !important;
    height: auto !important;
    padding: inherit !important;
    margin: inherit !important;
    overflow: visible !important;
    clip: auto !important;
    white-space: normal !important;
}

/* Live regions for dynamic content */
.live-region {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.live-region[aria-live="polite"] {
    /* Announced when user is idle */
}

.live-region[aria-live="assertive"] {
    /* Announced immediately */
}

/* ==========================================================================
   COLOR CONTRAST & VISUAL ACCESSIBILITY
   ========================================================================== */

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #000000;
        --secondary-color: #000000;
        --text-color: #000000;
        --background-color: #ffffff;
        --border-color: #000000;
        --link-color: #0000ff;
        --visited-link-color: #800080;
    }
    
    .btn {
        border: 2px solid #000000;
        background-color: #ffffff;
        color: #000000;
    }
    
    .btn:hover,
    .btn:focus {
        background-color: #000000;
        color: #ffffff;
    }
    
    .card {
        border: 2px solid #000000;
        background-color: #ffffff;
    }
}

/* Reduced motion support */
@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;
    }
    
    /* Keep essential animations but make them instant */
    .loading-spinner {
        animation: none;
    }
    
    .loading-spinner::after {
        content: "Loading...";
        display: block;
        text-align: center;
        font-weight: bold;
    }
}

/* Dark mode accessibility */
@media (prefers-color-scheme: dark) {
    :root {
        --primary-color: #ffd700;
        --secondary-color: #ffffff;
        --text-color: #ffffff;
        --background-color: #121212;
        --border-color: #333333;
        --link-color: #66b3ff;
        --visited-link-color: #cc99ff;
    }
    
    /* Ensure sufficient contrast in dark mode */
    .btn {
        background-color: #333333;
        color: #ffffff;
        border: 1px solid #666666;
    }
    
    .btn:hover,
    .btn:focus {
        background-color: #555555;
        border-color: #888888;
    }
    
    .card {
        background-color: #1e1e1e;
        border: 1px solid #333333;
        color: #ffffff;
    }
}

/* ==========================================================================
   FORM ACCESSIBILITY
   ========================================================================== */

/* Form labels and inputs */
label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    color: var(--text-color);
}

/* Required field indicators */
.required::after {
    content: " *";
    color: #d32f2f;
    font-weight: bold;
    aria-label: "required";
}

/* Input field styling */
input,
select,
textarea {
    border: 2px solid #cccccc;
    border-radius: 4px;
    padding: 12px;
    font-size: 16px; /* Prevents zoom on iOS */
    transition: border-color 0.3s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: #005fcc;
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 95, 204, 0.2);
}

/* Error states */
.error input,
.error select,
.error textarea {
    border-color: #d32f2f;
    background-color: #ffeaea;
}

.error-message {
    color: #d32f2f;
    font-size: 14px;
    margin-top: 4px;
    display: flex;
    align-items: center;
}

.error-message::before {
    content: "⚠";
    margin-right: 4px;
    font-weight: bold;
}

/* Success states */
.success input,
.success select,
.success textarea {
    border-color: #2e7d32;
    background-color: #e8f5e8;
}

.success-message {
    color: #2e7d32;
    font-size: 14px;
    margin-top: 4px;
    display: flex;
    align-items: center;
}

.success-message::before {
    content: "✓";
    margin-right: 4px;
    font-weight: bold;
}

/* ==========================================================================
   BUTTON ACCESSIBILITY
   ========================================================================== */

/* Button base styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border: 2px solid transparent;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px; /* Touch target size */
    min-width: 44px;
}

/* Button states */
.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Button variants */
.btn-primary {
    background-color: #f7b731;
    color: #000000;
    border-color: #f7b731;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: #e6a429;
    border-color: #e6a429;
}

.btn-secondary {
    background-color: transparent;
    color: #f7b731;
    border-color: #f7b731;
}

.btn-secondary:hover,
.btn-secondary:focus {
    background-color: #f7b731;
    color: #000000;
}

/* Icon buttons */
.btn-icon {
    padding: 12px;
    min-width: 44px;
    min-height: 44px;
}

.btn-icon .icon {
    width: 20px;
    height: 20px;
}

/* ==========================================================================
   NAVIGATION ACCESSIBILITY
   ========================================================================== */

/* Navigation landmarks */
nav[role="navigation"] {
    position: relative;
}

/* Breadcrumb navigation */
.breadcrumb {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    padding: 0;
    margin: 0;
}

.breadcrumb li {
    display: flex;
    align-items: center;
}

.breadcrumb li:not(:last-child)::after {
    content: "/";
    margin: 0 8px;
    color: #666666;
}

.breadcrumb a {
    color: #005fcc;
    text-decoration: none;
}

.breadcrumb a:hover,
.breadcrumb a:focus {
    text-decoration: underline;
}

.breadcrumb [aria-current="page"] {
    color: #666666;
    font-weight: 600;
}

/* Mobile menu accessibility */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: 2px solid #cccccc;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
}

.mobile-menu-toggle:focus {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}

.mobile-menu-toggle[aria-expanded="true"] .menu-icon {
    transform: rotate(90deg);
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: #ffffff;
        border: 1px solid #cccccc;
        border-radius: 4px;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        z-index: 1000;
    }
    
    .nav-menu[aria-hidden="false"] {
        display: block;
    }
    
    .nav-menu a {
        display: block;
        padding: 12px 16px;
        border-bottom: 1px solid #eeeeee;
    }
    
    .nav-menu a:last-child {
        border-bottom: none;
    }
}

/* ==========================================================================
   MODAL ACCESSIBILITY
   ========================================================================== */

/* Modal overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

/* Modal content */
.modal {
    background-color: #ffffff;
    border-radius: 8px;
    padding: 24px;
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.modal:focus {
    outline: none;
}

/* Modal close button */
.modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover,
.modal-close:focus {
    background-color: #f5f5f5;
    outline: 3px solid #005fcc;
    outline-offset: 2px;
}

/* ==========================================================================
   TABLE ACCESSIBILITY
   ========================================================================== */

/* Accessible tables */
table {
    border-collapse: collapse;
    width: 100%;
    margin: 16px 0;
}

th,
td {
    border: 1px solid #cccccc;
    padding: 12px;
    text-align: left;
}

th {
    background-color: #f5f5f5;
    font-weight: 600;
}

/* Table captions */
caption {
    font-weight: 600;
    margin-bottom: 8px;
    text-align: left;
}

/* Responsive table wrapper */
.table-wrapper {
    overflow-x: auto;
    margin: 16px 0;
}

.table-wrapper:focus {
    outline: 2px solid #005fcc;
    outline-offset: 2px;
}

/* ==========================================================================
   LOADING AND STATUS INDICATORS
   ========================================================================== */

/* Loading states */
.loading {
    position: relative;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #f7b731;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Status messages */
.status-message {
    padding: 12px 16px;
    border-radius: 4px;
    margin: 16px 0;
    display: flex;
    align-items: center;
}

.status-message.success {
    background-color: #e8f5e8;
    color: #2e7d32;
    border: 1px solid #4caf50;
}

.status-message.error {
    background-color: #ffeaea;
    color: #d32f2f;
    border: 1px solid #f44336;
}

.status-message.warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffc107;
}

.status-message.info {
    background-color: #e3f2fd;
    color: #1565c0;
    border: 1px solid #2196f3;
}

.status-message::before {
    margin-right: 8px;
    font-weight: bold;
}

.status-message.success::before { content: "✓"; }
.status-message.error::before { content: "✗"; }
.status-message.warning::before { content: "⚠"; }
.status-message.info::before { content: "ℹ"; }

/* ==========================================================================
   TOUCH ACCESSIBILITY
   ========================================================================== */

/* Touch target sizes */
.touch-target {
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Hover states for touch devices */
@media (hover: none) {
    .btn:hover {
        transform: none;
        box-shadow: none;
    }
    
    .card:hover {
        transform: none;
        box-shadow: none;
    }
}

/* ==========================================================================
   PRINT ACCESSIBILITY
   ========================================================================== */

@media print {
    /* Ensure good contrast for printing */
    * {
        background: transparent !important;
        color: black !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    /* Show URLs for links */
    a[href]:after {
        content: " (" attr(href) ")";
        font-size: 12px;
    }
    
    /* Hide interactive elements */
    .btn,
    .modal,
    .mobile-menu-toggle,
    .skip-link {
        display: none !important;
    }
    
    /* Ensure headings are clear */
    h1, h2, h3, h4, h5, h6 {
        page-break-after: avoid;
        font-weight: bold;
    }
    
    /* Avoid breaking content */
    p, blockquote, img {
        page-break-inside: avoid;
    }
} 