/**
 * Terms of Service Consent Modal Styles
 * WCAG 2.1 AA Compliant - Mobile Responsive
 *
 * Features:
 * - Blocking modal overlay (no close button, cannot dismiss)
 * - Accordion pattern for organized content sections
 * - Mobile-first responsive design
 * - Sticky footer with action buttons
 * - Touch-friendly controls (44x44px minimum)
 * - Keyboard navigation support
 * - High contrast for readability
 */

/* ============================================
   Modal Overlay (Blocking)
   ============================================ */

#tos-consent-modal {
    display: none; /* Hidden by default, shown via JS */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75);
    z-index: 10000; /* Above everything */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    align-items: flex-start;
    justify-content: center;
    padding: var(--space-md);
}

/* ============================================
   Modal Container
   ============================================ */

.tos-modal-container {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 700px;
    width: 100%;
    margin: var(--space-xl) auto;
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 3rem);
    position: relative;
}

/* Mobile: Full-screen modal */
@media (max-width: 768px) {
    #tos-consent-modal {
        padding: 0;
    }

    .tos-modal-container {
        border-radius: 0;
        margin: 0;
        max-height: 100vh;
        height: 100vh;
    }
}

/* ============================================
   Modal Header
   ============================================ */

.tos-modal-header {
    padding: var(--space-xl);
    border-bottom: 2px solid var(--gray-200);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

@media (max-width: 768px) {
    .tos-modal-header {
        padding: var(--space-lg);
        border-radius: 0;
    }
}

.tos-modal-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 var(--space-sm);
    line-height: 1.2;
}

@media (max-width: 768px) {
    .tos-modal-title {
        font-size: 1.5rem;
    }
}

.tos-modal-subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    margin: 0 0 var(--space-sm);
    line-height: 1.5;
}

.tos-modal-version {
    font-size: 0.875rem;
    color: var(--text-light);
    font-weight: 500;
}

.tos-required-badge {
    display: inline-block;
    background-color: var(--danger);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-full);
    margin-top: var(--space-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   Modal Body (Scrollable)
   ============================================ */

.tos-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-xl);
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .tos-modal-body {
        padding: var(--space-lg);
    }
}

/* ============================================
   Accordion Sections
   ============================================ */

.tos-accordion-section {
    margin-bottom: var(--space-lg);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.tos-accordion-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border: none;
    cursor: pointer;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: left;
    transition: background-color var(--transition-fast);
    min-height: 44px; /* WCAG touch target */
}

.tos-accordion-header:hover {
    background: var(--gray-100);
}

.tos-accordion-header:focus-visible {
    outline: none;
    box-shadow: inset var(--focus-ring);
}

.tos-accordion-header[aria-expanded="true"] .tos-accordion-icon {
    transform: rotate(180deg);
}

.tos-accordion-icon {
    font-size: 1.25rem;
    transition: transform var(--transition-fast);
    flex-shrink: 0;
    margin-left: var(--space-sm);
}

.tos-accordion-content {
    padding: var(--space-lg);
    background: var(--bg-primary);
    line-height: 1.6;
    color: var(--text-primary);
}

.tos-accordion-content[hidden] {
    display: none;
}

/* Content inside accordion */
.tos-accordion-content h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: var(--space-md) 0 var(--space-sm);
    color: var(--text-primary);
}

.tos-accordion-content p {
    margin-bottom: var(--space-md);
    color: var(--text-secondary);
}

.tos-accordion-content ul,
.tos-accordion-content ol {
    margin: var(--space-md) 0;
    padding-left: var(--space-xl);
}

.tos-accordion-content li {
    margin-bottom: var(--space-sm);
    color: var(--text-secondary);
}

.tos-accordion-content strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* ============================================
   Consent Checkboxes
   ============================================ */

.tos-consent-checkboxes {
    margin-top: var(--space-lg);
}

.tos-consent-checkbox-item {
    display: flex;
    align-items: flex-start;
    margin-bottom: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 2px solid var(--gray-200);
    transition: border-color var(--transition-fast);
}

.tos-consent-checkbox-item:hover {
    border-color: var(--primary-light);
}

.tos-consent-checkbox {
    width: 20px;
    height: 20px;
    min-width: 20px;
    margin: 2px var(--space-md) 0 0;
    cursor: pointer;
    accent-color: var(--primary);
}

.tos-consent-checkbox:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.tos-consent-label {
    flex: 1;
    font-size: 0.9375rem;
    color: var(--text-primary);
    line-height: 1.5;
    cursor: pointer;
    user-select: none;
}

/* ============================================
   Error Message
   ============================================ */

.tos-error-message {
    display: none;
    background-color: #fee;
    border: 1px solid var(--danger);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-top: var(--space-md);
    color: var(--danger);
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.5;
}

.tos-error-message[style*="display: block"] {
    display: block;
}

/* ============================================
   Modal Footer (Sticky)
   ============================================ */

.tos-modal-footer {
    padding: var(--space-xl);
    border-top: 2px solid var(--gray-200);
    background: var(--bg-secondary);
    display: flex;
    gap: var(--space-md);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    position: sticky;
    bottom: 0;
}

@media (max-width: 768px) {
    .tos-modal-footer {
        padding: var(--space-lg);
        flex-direction: column-reverse;
        border-radius: 0;
    }
}

.tos-modal-footer .btn {
    flex: 1;
    min-height: 44px; /* WCAG touch target */
    font-size: 1rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

@media (max-width: 768px) {
    .tos-modal-footer .btn {
        width: 100%;
    }
}

/* Accept All Button (Primary) */
#tos-accept-all-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
}

#tos-accept-all-btn:hover:not(:disabled) {
    background-color: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

#tos-accept-all-btn:disabled {
    background-color: var(--gray-400);
    cursor: not-allowed;
    opacity: 0.6;
}

#tos-accept-all-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* Decline Button (Secondary) */
#tos-decline-btn {
    background-color: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--gray-300);
    cursor: pointer;
}

#tos-decline-btn:hover {
    background-color: var(--gray-100);
    border-color: var(--gray-400);
}

#tos-decline-btn:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

/* ============================================
   Loading States
   ============================================ */

.tos-modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-2xl);
}

.tos-modal-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-300);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: tos-spin 0.8s linear infinite;
}

@keyframes tos-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   Screen Reader Only
   ============================================ */

.tos-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   Print Styles (Hide modal in print)
   ============================================ */

@media print {
    #tos-consent-modal {
        display: none !important;
    }
}
