/**
 * Cookie Consent Banner Styles
 * WCAG 2.2 AA Compliant
 * Mobile-first responsive design with iPhone safe area support
 * 
 * Note: This file is loaded directly (not through asset pipeline)
 * Path: /cookie-consent.css
 */

/* ============================================
   Banner Container
   ============================================ */

.cookie-consent-banner {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    background-color: #fff;
    border-top: 1px solid #d4d4d8;
    box-shadow: 0 -4px 6px -1px rgb(0 0 0 / 10%), 0 -2px 4px -1px rgb(0 0 0 / 6%);
    max-height: 90vh;
    overflow-y: auto;
    
    /* iPhone safe area support - critical for not being hidden by Safari UI */
    padding-bottom: env(safe-area-inset-bottom);
}

/* Dark mode support */
[data-theme="dark"] .cookie-consent-banner {
    background-color: #27272a;
    border-top-color: #3f3f46;
}

/* Position above bottom navigation on mobile (4rem = 64px nav height) */
@media (width <= 1023px) {
    .cookie-consent-banner {
        bottom: calc(4rem + env(safe-area-inset-bottom));
    }
}

/* Desktop: banner at true bottom */
@media (width >= 1024px) {
    .cookie-consent-banner {
        bottom: 0;
    }
}

.cookie-consent-container {
    max-width: 80rem;
    margin: 0 auto;
    padding: 1rem;
}

@media (width >= 640px) {
    .cookie-consent-container {
        padding: 1.25rem 1.5rem;
    }
}

/* ============================================
   Content Layout
   ============================================ */

.cookie-consent-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (width >= 768px) {
    .cookie-consent-content {
        flex-direction: row;
        align-items: center;
        gap: 1.5rem;
    }
}

.cookie-consent-text {
    flex: 1;
    min-width: 0;
}

.cookie-consent-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #212529;
    margin: 0 0 0.25rem;
}

[data-theme="dark"] .cookie-consent-title {
    color: #e4e4e7;
}

.cookie-consent-description {
    font-size: 0.875rem;
    line-height: 1.5;
    color: #64748b;
    margin: 0 0 0.5rem;
}

[data-theme="dark"] .cookie-consent-description {
    color: #a1a1aa;
}

.cookie-consent-link {
    font-size: 0.875rem;
    color: #2E4E3F;
    text-decoration: underline;
    transition: opacity 0.2s;
}

.cookie-consent-link:hover {
    opacity: 0.8;
}

.cookie-consent-link:focus-visible {
    outline: 2px solid #2E4E3F;
    outline-offset: 2px;
    border-radius: 2px;
}

[data-theme="dark"] .cookie-consent-link {
    color: #D3A71A;
}

[data-theme="dark"] .cookie-consent-link:focus-visible {
    outline-color: #D3A71A;
}

/* ============================================
   Action Buttons
   ============================================ */

.cookie-consent-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
}

@media (width >= 640px) {
    .cookie-consent-actions {
        flex-flow: row wrap;
        width: auto;
    }
}

@media (width >= 768px) {
    .cookie-consent-actions {
        flex-shrink: 0;
    }
}

.cookie-consent-btn {
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    
    /* WCAG 2.5.5 Level AA - Minimum 44x44px touch target */
    min-height: 44px;
    min-width: 44px;
}

@media (width >= 640px) {
    .cookie-consent-btn {
        padding: 0.625rem 1rem;
    }
}

.cookie-consent-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Primary button (Accept All) */
.cookie-consent-btn-primary {
    background-color: #2E4E3F;
    color: #fff;
}

.cookie-consent-btn-primary:hover:not(:disabled) {
    background-color: #4A6F5C;
}

.cookie-consent-btn-primary:focus-visible {
    outline: 2px solid #2E4E3F;
    outline-offset: 2px;
}

[data-theme="dark"] .cookie-consent-btn-primary {
    background-color: #D3A71A;
    color: #1a1a1a;
}

[data-theme="dark"] .cookie-consent-btn-primary:hover:not(:disabled) {
    background-color: #e6bd3a;
}

[data-theme="dark"] .cookie-consent-btn-primary:focus-visible {
    outline-color: #D3A71A;
}

/* Secondary button (Essential Only) */
.cookie-consent-btn-secondary {
    background-color: #f4f4f5;
    color: #212529;
    border: 1px solid #d4d4d8;
}

.cookie-consent-btn-secondary:hover:not(:disabled) {
    background-color: #e4e4e7;
}

.cookie-consent-btn-secondary:focus-visible {
    outline: 2px solid #2E4E3F;
    outline-offset: 2px;
}

[data-theme="dark"] .cookie-consent-btn-secondary {
    background-color: #3f3f46;
    color: #e4e4e7;
    border-color: #52525b;
}

[data-theme="dark"] .cookie-consent-btn-secondary:hover:not(:disabled) {
    background-color: #52525b;
}

[data-theme="dark"] .cookie-consent-btn-secondary:focus-visible {
    outline-color: #D3A71A;
}

/* Tertiary button (Manage Preferences) */
.cookie-consent-btn-tertiary {
    background-color: transparent;
    color: #2E4E3F;
    border: 1px solid #d4d4d8;
}

.cookie-consent-btn-tertiary:hover:not(:disabled) {
    background-color: #f4f4f5;
}

.cookie-consent-btn-tertiary:focus-visible {
    outline: 2px solid #2E4E3F;
    outline-offset: 2px;
}

[data-theme="dark"] .cookie-consent-btn-tertiary {
    color: #D3A71A;
    border-color: #52525b;
}

[data-theme="dark"] .cookie-consent-btn-tertiary:hover:not(:disabled) {
    background-color: #3f3f46;
}

[data-theme="dark"] .cookie-consent-btn-tertiary:focus-visible {
    outline-color: #D3A71A;
}

/* ============================================
   Preferences Modal
   ============================================ */

.cookie-consent-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgb(0 0 0 / 50%);
    z-index: 60;
    animation: fadeIn 0.2s ease-out;
}

[data-theme="dark"] .cookie-consent-backdrop {
    background-color: rgb(0 0 0 / 70%);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.cookie-consent-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 61;
    background-color: #fff;
    border-radius: 0.5rem;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 10%), 0 10px 10px -5px rgb(0 0 0 / 4%);
    max-width: 90vw;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
    width: 100%;
}

@media (width >= 640px) {
    .cookie-consent-modal {
        width: 32rem;
        max-width: calc(100vw - 2rem);
    }
}

[data-theme="dark"] .cookie-consent-modal {
    background-color: #27272a;
}

@keyframes slideUp {
    from {
        transform: translate(-50%, -45%);
        opacity: 0;
    }

    to {
        transform: translate(-50%, -50%);
        opacity: 1;
    }
}

/* Modal Header */
.cookie-consent-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem;
    border-bottom: 1px solid #e4e4e7;
}

[data-theme="dark"] .cookie-consent-modal-header {
    border-bottom-color: #3f3f46;
}

.cookie-consent-modal-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #212529;
    margin: 0;
}

[data-theme="dark"] .cookie-consent-modal-title {
    color: #e4e4e7;
}

.cookie-consent-modal-close {
    padding: 0.5rem;
    color: #71717a;
    background-color: transparent;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
    
    /* Minimum touch target */
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cookie-consent-modal-close:hover {
    background-color: #f4f4f5;
}

.cookie-consent-modal-close:focus-visible {
    outline: 2px solid #2E4E3F;
    outline-offset: 2px;
}

[data-theme="dark"] .cookie-consent-modal-close {
    color: #a1a1aa;
}

[data-theme="dark"] .cookie-consent-modal-close:hover {
    background-color: #3f3f46;
}

[data-theme="dark"] .cookie-consent-modal-close:focus-visible {
    outline-color: #D3A71A;
}

/* Modal Body */
.cookie-consent-modal-body {
    padding: 1.25rem;
}

.cookie-consent-modal-description {
    font-size: 0.875rem;
    line-height: 1.5;
    color: #64748b;
    margin: 0 0 1.25rem;
}

[data-theme="dark"] .cookie-consent-modal-description {
    color: #a1a1aa;
}

.cookie-consent-modal-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* Cookie Option */
.cookie-consent-option {
    padding: 0.875rem;
    background-color: #f9fafb;
    border-radius: 0.375rem;
}

[data-theme="dark"] .cookie-consent-option {
    background-color: #18181b;
}

.cookie-consent-option-header {
    display: flex;
    align-items: flex-start;
    gap: 0.625rem;
    margin-bottom: 0.375rem;
}

.cookie-consent-checkbox {
    width: 1.125rem;
    height: 1.125rem;
    margin-top: 0.125rem;
    border-radius: 0.25rem;
    border: 1px solid #d4d4d8;
    color: #2E4E3F;
    cursor: pointer;
    flex-shrink: 0;
}

.cookie-consent-checkbox:focus-visible {
    outline: 2px solid #2E4E3F;
    outline-offset: 2px;
}

.cookie-consent-checkbox-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

[data-theme="dark"] .cookie-consent-checkbox {
    border-color: #52525b;
    color: #D3A71A;
}

[data-theme="dark"] .cookie-consent-checkbox:focus-visible {
    outline-color: #D3A71A;
}

.cookie-consent-option-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #212529;
    cursor: pointer;
    flex: 1;
}

[data-theme="dark"] .cookie-consent-option-label {
    color: #e4e4e7;
}

.cookie-consent-option-required {
    font-size: 0.75rem;
    font-weight: 400;
    color: #71717a;
}

[data-theme="dark"] .cookie-consent-option-required {
    color: #a1a1aa;
}

.cookie-consent-option-description {
    font-size: 0.8125rem;
    line-height: 1.5;
    color: #64748b;
    margin: 0;
    padding-left: 1.75rem;
}

[data-theme="dark"] .cookie-consent-option-description {
    color: #a1a1aa;
}

/* Modal Footer */
.cookie-consent-modal-footer {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.25rem;
    border-top: 1px solid #e4e4e7;
}

@media (width >= 640px) {
    .cookie-consent-modal-footer {
        flex-direction: row;
        justify-content: flex-end;
    }
}

[data-theme="dark"] .cookie-consent-modal-footer {
    border-top-color: #3f3f46;
}

/* ============================================
   Accessibility Enhancements
   ============================================ */

/* Ensure all interactive elements meet WCAG 2.5.5 */
@media (pointer: coarse) {
    .cookie-consent-btn,
    .cookie-consent-modal-close,
    .cookie-consent-checkbox {
        min-height: 44px;
        min-width: 44px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .cookie-consent-banner {
        border-top-width: 2px;
    }
    
    .cookie-consent-btn {
        border-width: 2px;
    }
    
    .cookie-consent-link:focus-visible,
    .cookie-consent-btn:focus-visible,
    .cookie-consent-modal-close:focus-visible,
    .cookie-consent-checkbox:focus-visible {
        outline-width: 3px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .cookie-consent-backdrop,
    .cookie-consent-modal {
        animation: none;
    }
    
    .cookie-consent-btn,
    .cookie-consent-link,
    .cookie-consent-modal-close {
        transition: none;
    }
}
