/**
 * CORNERSTONE V2.0 ENHANCED THEME SELECTOR CSS
 * Privacy-First, Offline-Capable Theme System with "Beefy Security"
 * 
 * Features:
 * - High-contrast mode support
 * - Reduced motion support
 * - Forced colors support
 * - Enhanced accessibility
 * - Mobile-first responsive design
 */

/* ============================================================================
   V2.0 ENHANCED THEME SELECTOR STYLING
   ============================================================================ */

.theme-selector {
    /* Base styling - Force override all theme variables */
    background: #000000 !important;
    color: var(--crt-primary, #ffffff) !important;
    border: 1px solid var(--crt-border, #008000) !important;
    border-radius: 4px;
    padding: 8px 12px;
    font-family: var(--theme-font-stack, 'Source Code Pro', monospace);
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
    outline: none;
    transition: all 0.2s ease;
    min-width: 150px;
    max-width: 200px;
    width: auto;

    /* Remove default appearance */
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;

    /* Custom dropdown arrow */
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 32px;
}

.theme-selector:hover {
    background: #000000 !important;
    color: var(--crt-primary, #ffffff) !important;
    border-color: transparent !important;
    box-shadow: none !important;
}

.theme-selector:focus {
    outline: none;
    box-shadow: none;
}

.theme-selector:active {
    transform: translateY(1px);
}

/* Theme option styling */
.theme-option {
    background: var(--crt-background, #000000);
    color: var(--crt-primary, #ffffff);
    padding: 8px 12px;
    border: none;
    font-family: var(--theme-font-stack, 'Source Code Pro', monospace);
    font-size: 14px;
}

.theme-option:hover {
    background: var(--crt-hover, rgba(0, 0, 0, 0));
    color: var(--crt-accent, transparent);
}

.theme-option:focus {
    outline: none;
}

/* Remove selection highlighting from dropdown options */
.theme-option:selected,
.theme-option[selected] {
    background: transparent !important;
    color: inherit !important;
}

/* Force selected option to be transparent */
.theme-selector option[selected] {
    background: transparent !important;
    color: var(--crt-primary, #ffffff) !important;
}

/* Remove any browser default selection styling */
.theme-selector option:checked,
.theme-selector option:selected {
    background: transparent !important;
    color: inherit !important;
}

/* ============================================================================
   ACCESSIBILITY ENHANCEMENTS
   ============================================================================ */

/* Screen reader only content */
.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;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .theme-selector {
        border: 2px solid currentColor !important;
        background: ButtonFace !important;
        color: ButtonText !important;
        font-weight: bold !important;
    }

    .theme-selector:hover {
        background: Highlight !important;
        color: HighlightText !important;
    }

    .theme-selector:focus {
        outline: none !important;
    }

    .theme-option {
        background: ButtonFace !important;
        color: ButtonText !important;
        border: 1px solid currentColor !important;
    }

    .theme-option:hover {
        background: Highlight !important;
        color: HighlightText !important;
    }
}

/* Forced colors mode support */
@media (forced-colors: active) {
    .theme-selector {
        border: 2px solid ButtonText !important;
        background: ButtonFace !important;
        color: ButtonText !important;
    }

    .theme-selector:hover {
        background: Highlight !important;
        color: HighlightText !important;
    }

    .theme-selector:focus {
        outline: none !important;
    }

    .theme-option {
        background: ButtonFace !important;
        color: ButtonText !important;
    }

    .theme-option:hover {
        background: Highlight !important;
        color: HighlightText !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {

    .theme-selector,
    .theme-option {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .theme-selector:hover {
        transform: none !important;
    }

    .theme-selector:active {
        transform: none !important;
    }
}

/* ============================================================================
   ERROR HANDLING STYLES
   ============================================================================ */

.theme-error-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #ff4444;
    color: white;
    padding: 12px 16px;
    border-radius: 4px;
    font-family: var(--theme-font-stack, 'Source Code Pro', monospace);
    font-size: 14px;
    font-weight: 500;
    z-index: 10000;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid #cc0000;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

/* Mobile-first approach */
@media (max-width: 768px) {
    .theme-selector {
        font-size: 12px;
        padding: 6px 10px;
        padding-right: 28px;
        background-size: 14px;
        background-position: right 6px center;
    }

    .theme-option {
        font-size: 12px;
        padding: 6px 10px;
    }
}

@media (max-width: 480px) {
    .theme-selector {
        font-size: 11px;
        padding: 5px 8px;
        padding-right: 24px;
        background-size: 12px;
        background-position: right 4px center;
    }

    .theme-option {
        font-size: 11px;
        padding: 5px 8px;
    }
}

/* ============================================================================
   DARK MODE SUPPORT
   ============================================================================ */

@media (prefers-color-scheme: dark) {
    .theme-selector {
        background: var(--crt-background, #1a1a1a);
        color: var(--crt-primary, #ffffff);
        border-color: transparent;
    }

    .theme-selector:hover {
        background: var(--crt-hover, rgba(0, 0, 0, 0));
        border-color: var(--crt-accent, transparent);
    }

    .theme-option {
        background: var(--crt-background, #1a1a1a);
        color: var(--crt-primary, #ffffff);
    }

    .theme-option:hover {
        background: var(--crt-hover, rgba(0, 0, 0, 0));
        color: var(--crt-accent, transparent);
    }
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
    .theme-selector {
        background: white !important;
        color: black !important;
        border: 1px solid black !important;
        box-shadow: none !important;
    }

    .theme-option {
        background: white !important;
        color: black !important;
    }
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

.theme-selector-loading {
    opacity: 0.6;
    pointer-events: none;
    cursor: not-allowed;
}

.theme-selector-error {
    border-color: #ff4444 !important;
    background: #ff4444 !important;
    color: white !important;
}

.theme-selector-success {
    border-color: #44ff44 !important;
    background: #44ff44 !important;
    color: black !important;
}

/* ============================================================================
   ANIMATION ENHANCEMENTS
   ============================================================================ */

.theme-selector {
    position: relative;
    overflow: hidden;
}

.theme-selector::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s ease;
}

.theme-selector:hover::before {
    left: 100%;
}

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

.theme-selector:focus-visible {
    outline: none !important;
    box-shadow: none !important;
}

/* Completely remove all selection highlighting */
.theme-selector:focus,
.theme-selector:active,
.theme-selector:focus-visible,
.theme-selector:focus-within {
    outline: none !important;
    box-shadow: none !important;
    border-color: transparent !important;
}

/* Remove all option highlighting */
.theme-selector option {
    background: var(--crt-background, #000000) !important;
    color: var(--crt-primary, #ffffff) !important;
}

.theme-selector option:checked,
.theme-selector option:selected,
.theme-selector option:hover,
.theme-selector option:focus {
    background: transparent !important;
    color: var(--crt-primary, #ffffff) !important;
    outline: none !important;
}

/* Force all option text to be white, no matter what */
.theme-selector option,
.theme-selector option:checked,
.theme-selector option:selected,
.theme-selector option:hover,
.theme-selector option:focus,
.theme-selector option:active {
    color: var(--crt-primary, #ffffff) !important;
    background: #000000 !important;
}

/* Force button text to be white in all states */
.theme-selector,
.theme-selector:hover,
.theme-selector:focus,
.theme-selector:active,
.theme-selector:focus-visible {
    color: var(--crt-primary, #ffffff) !important;
}

/* ============================================================================
   VENDOR-SPECIFIC SELECTION SUPPRESSION (Grok Strategy)
   ============================================================================ */

/* WebKit browsers (Chrome, Safari, Edge) */
.theme-selector::-webkit-focus-ring-color {
    color: transparent !important;
}

.theme-selector {
    -webkit-tap-highlight-color: transparent !important;
    -webkit-touch-callout: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    user-select: none !important;
}

/* Mozilla Firefox */
.theme-selector::-moz-focus-inner {
    border: none !important;
    outline: none !important;
}

/* Universal selection suppression */
.theme-selector:focus,
.theme-selector:active,
.theme-selector:focus-visible,
.theme-selector:focus-within,
.theme-selector:focus-visible:focus,
.theme-selector:focus-visible:focus-within {
    background: var(--crt-background, #000000) !important;
    color: var(--crt-primary, #ffffff) !important;
    border-color: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    -webkit-box-shadow: none !important;
    -moz-box-shadow: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

/* Prevent button from changing appearance when dropdown is open */
.theme-selector[aria-expanded="true"],
.theme-selector:focus-within {
    background: var(--crt-background, #000000) !important;
    color: var(--crt-primary, #ffffff) !important;
    border-color: transparent !important;
    box-shadow: none !important;
    outline: none !important;
}

/* High contrast mode compliance */
@media (prefers-contrast: high) {

    .theme-selector:focus,
    .theme-selector:focus-visible {
        outline: 1px solid var(--crt-primary, #ffffff) !important;
        outline-offset: 2px !important;
    }
}


/* ============================================================================
   CUSTOM SCROLLBAR STYLING - MINIMAL DESIGN
   ============================================================================ */

/* Webkit browsers (Chrome, Safari, Edge) */
.theme-selector::-webkit-scrollbar {
    width: 8px;
}

.theme-selector::-webkit-scrollbar-track {
    background: var(--crt-background, #000000);
    border-radius: 4px;
}

.theme-selector::-webkit-scrollbar-thumb {
    background: var(--crt-primary, #ffffff);
    border-radius: 4px;
    opacity: 0.3;
}

.theme-selector::-webkit-scrollbar-thumb:hover {
    opacity: 0.6;
}

/* Firefox */
.theme-selector {
    scrollbar-width: thin;
    scrollbar-color: var(--crt-primary, #ffffff) var(--crt-background, #000000);
}

/* ============================================================================
   LOADING STATES
   ============================================================================ */

.theme-selector[data-loading="true"] {
    opacity: 0.6;
    pointer-events: none;
    cursor: wait;
}

.theme-selector[data-loading="true"]::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 8px;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    transform: translateY(-50%);
}

@keyframes spin {
    0% {
        transform: translateY(-50%) rotate(0deg);
    }

    100% {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* ============================================================================
   DARK MODE AND MOBILE RESPONSIVE STYLING
   ============================================================================ */

@media (prefers-color-scheme: dark) {
    .theme-selector {
        background: var(--crt-background, #1a1a1a);
        color: var(--crt-primary, #ffffff);
        border-color: transparent;
    }
}

@media (max-width: 480px) {
    .theme-selector {
        font-size: 11px;
        padding: 0px 0px;
        padding-right: 0px;
        background-size: 12px;
        background-position: right 0px center;
    }
}