/* ===============================================
   DESIGN & ACCESSIBILITY IMPROVEMENTS
   Add this file after style.css in header.php
   =============================================== */

/* ==========================================
   1. ACCESSIBILITY - FOCUS STATES (CRITICAL)
   ========================================== */

/* Focus-visible for keyboard navigation - removes focus ring for mouse clicks */
*:focus {
    outline: none;
}

*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Button focus states */
.btn:focus-visible,
button:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.2);
}

.btn-primary:focus-visible {
    outline-color: var(--white);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.3);
}

.btn-outline:focus-visible {
    background: rgba(99, 102, 241, 0.05);
}

/* Link focus states */
a:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-radius: 2px;
}

.main-nav a:focus-visible {
    background: rgba(99, 102, 241, 0.1);
    outline: 2px solid var(--primary-color);
}

/* Form input focus states - enhanced */
.form-control:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 1px;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

/* Icon button focus states */
.btn-icon:focus-visible,
.btn-cart:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    transform: scale(1.05);
}

/* Dropdown focus */
.dropdown-toggle:focus-visible {
    background: rgba(99, 102, 241, 0.05);
    outline: 2px solid var(--primary-color);
}

/* Mobile menu toggle focus */
.mobile-menu-toggle:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    background: rgba(99, 102, 241, 0.1);
}

/* Radio and checkbox focus (when visible) */
input[type="radio"]:focus-visible + .package-content,
input[type="radio"]:focus-visible + .payment-content {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

/* Card links focus */
.category-card:focus-visible,
.product-card:focus-visible,
.platform-card:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
    transform: translateY(-5px);
}

/* ==========================================
   2. DISABLED STATES
   ========================================== */

/* Disabled buttons */
.btn:disabled,
.btn[disabled],
button:disabled,
button[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary:disabled,
.btn-primary[disabled] {
    background: var(--gray);
    border-color: var(--gray);
}

.btn-outline:disabled,
.btn-outline[disabled] {
    color: var(--gray);
    border-color: var(--border-color);
}

/* Disabled inputs */
input:disabled,
textarea:disabled,
select:disabled,
.form-control:disabled,
input[disabled],
textarea[disabled],
select[disabled],
.form-control[disabled] {
    background-color: var(--light-gray);
    color: var(--gray);
    cursor: not-allowed;
    opacity: 0.6;
    border-color: var(--border-color);
}

/* Disabled radio/checkbox labels */
input[type="radio"]:disabled + .package-content,
input[type="checkbox"]:disabled + label {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ==========================================
   3. REDUCED MOTION (ACCESSIBILITY)
   ========================================== */

@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;
    }

    /* Disable scroll animations */
    .proof-ticker {
        animation: none !important;
    }

    /* Disable spinner rotation */
    .spinner,
    .fa-spinner {
        animation: none !important;
    }

    /* Disable pulse effects */
    .pulse-badge,
    .pulse-button {
        animation: none !important;
    }

    /* Disable transform animations */
    .feature-card,
    .category-card,
    .product-card,
    .btn {
        transition: none !important;
    }

    .feature-card:hover,
    .category-card:hover,
    .product-card:hover {
        transform: none !important;
    }
}

/* ==========================================
   4. IMPROVED ERROR STATES
   ========================================== */

/* Error state for inputs */
.form-control.error,
input.error,
textarea.error,
select.error,
input:invalid:not(:placeholder-shown),
textarea:invalid:not(:placeholder-shown) {
    border-color: var(--danger-color);
    border-width: 2px;
    background-color: rgba(239, 68, 68, 0.05);
}

.form-control.error:focus,
input.error:focus,
textarea.error:focus {
    border-color: var(--danger-color);
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

/* Success state for inputs */
.form-control.success,
input.success,
textarea.success,
input:valid:not(:placeholder-shown):not([type="email"]):not([type="url"]) {
    border-color: var(--secondary-color);
    background-color: rgba(16, 185, 129, 0.05);
}

/* Error message styling improvements */
.error-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--danger-color);
    font-size: 0.9rem;
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.05);
    border-radius: 6px;
    border-left: 4px solid var(--danger-color);
}

.error-message::before {
    content: "⚠";
    font-size: 1.2rem;
}

/* ==========================================
   5. IMPROVED ACTIVE STATES
   ========================================== */

/* Button active states (when clicked) */
.btn:active:not(:disabled) {
    transform: translateY(0);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-primary:active:not(:disabled) {
    background: var(--primary-hover);
}

/* Link active states */
a:active {
    opacity: 0.8;
}

/* ==========================================
   6. LOADING STATES IMPROVEMENTS
   ========================================== */

/* Loading button state */
.btn.loading,
.btn[data-loading="true"] {
    position: relative;
    color: transparent;
    pointer-events: none;
}

.btn.loading::after,
.btn[data-loading="true"]::after {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    top: 50%;
    left: 50%;
    margin-left: -8px;
    margin-top: -8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.6s linear infinite;
}

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

/* ==========================================
   7. BETTER TOOLTIPS & LABELS
   ========================================== */

/* Required field indicator */
label .required,
label[required]::after {
    content: "*";
    color: var(--danger-color);
    margin-left: 0.25rem;
    font-weight: 700;
}

/* Helper text styling */
.form-help,
small.form-help {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.875rem;
    color: var(--gray);
}

/* Tooltip basic styling */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.5rem 0.75rem;
    background: var(--dark);
    color: var(--white);
    font-size: 0.85rem;
    border-radius: 6px;
    white-space: nowrap;
    z-index: 1000;
    margin-bottom: 0.5rem;
}

/* ==========================================
   8. IMPROVED LINK VISIBILITY
   ========================================== */

/* Make links more distinguishable */
.main-content a:not(.btn):not(.category-card):not(.product-card):not(.platform-card) {
    color: var(--primary-color);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.main-content a:not(.btn):not(.category-card):not(.product-card):not(.platform-card):hover {
    text-decoration-thickness: 2px;
    color: var(--primary-hover);
}

/* ==========================================
   9. BETTER CARD ACCESSIBILITY
   ========================================== */

/* Card links should have visible affordance */
a.category-card,
a.product-card,
a.platform-card {
    cursor: pointer;
}

a.category-card:hover,
a.product-card:hover,
a.platform-card:hover {
    cursor: pointer;
}

/* Add keyboard indicator for card navigation */
a.category-card:focus-visible::before,
a.product-card:focus-visible::before,
a.platform-card:focus-visible::before {
    content: "→";
    position: absolute;
    left: 1rem;
    top: 1rem;
    font-size: 1.5rem;
    color: var(--primary-color);
    font-weight: 700;
}

/* ==========================================
   10. SKIP TO CONTENT LINK (ACCESSIBILITY)
   ========================================== */

.skip-to-content {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-color);
    color: white;
    padding: 0.75rem 1.5rem;
    text-decoration: none;
    border-radius: 0 0 4px 0;
    z-index: 10000;
    font-weight: 600;
}

.skip-to-content:focus {
    top: 0;
}

/* ==========================================
   11. SCREEN READER ONLY TEXT
   ========================================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border-width: 0;
}

.sr-only-focusable:focus,
.sr-only-focusable:active {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    white-space: normal;
}

/* ==========================================
   12. MOBILE IMPROVEMENTS
   ========================================== */

@media (max-width: 768px) {
    /* Increase touch target sizes */
    .btn,
    button,
    a.btn {
        min-height: 44px;
        min-width: 44px;
        padding: 0.75rem 1.25rem;
    }

    .btn-icon,
    .btn-cart {
        min-width: 44px;
        min-height: 44px;
    }

    /* Better spacing for mobile forms */
    .form-group {
        margin-bottom: 1.5rem;
    }

    /* Prevent zoom on input focus (iOS) */
    input,
    select,
    textarea {
        font-size: 16px;
    }

    /* Better mobile dropdowns */
    .dropdown-menu {
        font-size: 16px;
    }

    /* Improve mobile header spacing */
    .header-actions .btn-outline {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        min-width: auto;
    }
}

/* ==========================================
   13. PRINT STYLES
   ========================================== */

@media print {
    /* Hide navigation and non-essential elements */
    .header,
    .footer,
    .btn,
    .flash-message,
    .social-proof-banner {
        display: none;
    }

    /* Ensure readable text */
    body {
        color: black;
        background: white;
    }

    /* Show URLs for links */
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }
}

/* ==========================================
   14. HIGH CONTRAST MODE
   ========================================== */

@media (prefers-contrast: high) {
    :root {
        --primary-color: #0000ff;
        --dark: #000000;
        --border-color: #000000;
    }

    .btn-outline {
        border-width: 2px;
    }

    .form-control {
        border-width: 2px;
    }
}
