/* Theme Modal CSS Variables */
:root {
    /* Theme Modal Variables */
    --theme-modal-width: 600px;
    --theme-modal-max-height: 600px;
    
    /* Theme Option Items */
    --theme-option-height: 80px;
    --theme-option-padding: 20px;
    --theme-option-border-radius: 16px;
    --theme-option-border: 1px solid rgba(255, 255, 255, 0.08);
    --theme-option-hover-bg: rgba(255, 255, 255, 0.04);
    --theme-option-selected-bg: rgba(42, 82, 152, 0.1);
    --theme-option-selected-border: rgba(42, 82, 152, 0.3);
    --theme-option-transition: all 0.2s ease;
    --theme-option-border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    
    /* Theme Preview */
    --theme-preview-width: 60px;
    --theme-preview-height: 40px;
    --theme-preview-border-radius: 8px;
    --theme-preview-border: 1px solid rgba(0, 0, 0, 0.1);
    --theme-preview-header-height: 12px;
    --theme-preview-header-margin: 4px;
    --theme-preview-header-border-radius: 2px;
    --theme-preview-content-margin: 4px;
    --theme-preview-content-gap: 2px;
    --theme-preview-line-height: 3px;
    --theme-preview-line-border-radius: 1.5px;
    --theme-preview-short-width: 60%;
    --theme-preview-light-header-bg: rgba(0, 0, 0, 0.1);
    --theme-preview-dark-header-bg: rgba(255, 255, 255, 0.1);
    --theme-preview-light-line-bg: rgba(0, 0, 0, 0.08);
    --theme-preview-dark-line-bg: rgba(255, 255, 255, 0.08);
    
    /* Theme Preview Container */
    --theme-preview-light-bg: linear-gradient(135deg, #ffffff 0%, #f5f5f5 100%);
    --theme-preview-light-color: #333;
    --theme-preview-dark-bg: linear-gradient(135deg, #2c2c2e 0%, #1c1c1e 100%);
    --theme-preview-dark-color: #fff;
    --theme-preview-auto-bg: linear-gradient(135deg, #ffffff 0%, #2c2c2e 50%, #1c1c1e 100%);
    --theme-auto-icon-size: 12px;
    --theme-auto-icon-opacity: 0.8;
    
    /* Theme Info */
    --theme-info-gap: 4px;
    --theme-label-font-size: 18px;
    --theme-label-font-weight: 600;
    --theme-label-color: var(--text-color);
    --theme-description-font-size: 14px;
    --theme-description-color: rgba(255, 255, 255, 0.6);
    
    /* Theme Selections */
    --theme-preview-container-margin: 16px;
    --theme-info-flex: 1;
    --theme-selection-indicator-margin: 16px;
    
    /* Selection Indicator */
    --selection-circle-size: 24px;
    --selection-circle-border: 2px solid rgba(255, 255, 255, 0.3);
    --selection-circle-selected: 2px solid #2a5298;
    --selection-circle-transition: all 0.2s ease;
    --selection-circle-border-radius: 50%;
    --selection-checkmark-size: 20px;
    --selection-checkmark-color: #2a5298;
    --selection-checkmark-opacity: 0;
    --selection-checkmark-selected-opacity: 1;
    
    /* Theme Info Card */
    --theme-info-card-padding: 40px 24px;
    --theme-info-card-border: var(--button-border);
    --theme-icon-container-size: 80px;
    --theme-icon-container-bg: rgba(42, 82, 152, 0.16);
    --theme-icon-container-border-radius: 20px;
    --theme-icon-container-border: 1px solid rgba(42, 82, 152, 0.24);
    --theme-icon-container-blur: 8px;
    --theme-icon-size: 40px;
    --theme-info-title-font-size: 32px;
    --theme-info-title-font-weight: 700;
    --theme-info-title-color: var(--text-color);
    --theme-info-title-margin: 24px 0 16px 0;
    --theme-info-description-font-size: 16px;
    --theme-info-description-color: rgba(255, 255, 255, 0.7);
    --theme-info-description-line-height: 1.5;
    --theme-info-description-max-width: 600px;
    
    /* Theme Options Card */
    --theme-options-card-bg: rgba(255, 255, 255, 0.02);
    --theme-options-card-border-radius: 16px;
    --theme-options-card-border: 1px solid rgba(255, 255, 255, 0.08);
    --theme-options-card-margin: 24px 0;
    
    /* Modal Back Button */
    --modal-back-btn-size: 32px;
    --modal-back-btn-bg: rgb(51, 51, 54);
    --modal-back-btn-hover-bg: rgb(71, 71, 74);
    --modal-back-btn-border-radius: 50%;
    --modal-back-btn-color: rgba(255, 255, 255, 0.8);
    --modal-back-btn-hover-color: rgba(255, 255, 255, 1);
    --modal-back-btn-transition: all 0.2s ease;
    --modal-back-btn-icon-size: 16px;
}

:root[data-theme="light"], :root[data-theme=""] {
    /* Light Mode Adjustments */
    --theme-option-selected-bg: rgba(42, 82, 152, 0.08);
    --theme-option-selected-border: rgba(42, 82, 152, 0.2);
    --selection-circle-selected: 2px solid #2a5298;
    --selection-checkmark-color: #2a5298;
    --selection-circle-border: 2px solid rgba(0, 0, 0, 0.2);
    
    /* Theme Option Items - Light Mode */
    --theme-option-hover-bg: rgba(0, 0, 0, 0.02);
    --theme-option-border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    
    /* Theme Info - Light Mode */
    --theme-description-color: rgba(0, 0, 0, 0.5);
    --theme-info-card-border: var(--button-border);
    
    /* Theme Info Card - Light Mode */
    --theme-info-card-border: 1px solid rgba(0, 0, 0, 0.1);
    --theme-icon-container-bg: rgba(42, 82, 152, 0.08);
    --theme-icon-container-border: 1px solid rgba(42, 82, 152, 0.15);
    --theme-info-description-color: rgba(0, 0, 0, 0.6);
    
    /* Theme Options Card - Light Mode */
    --theme-options-card-bg: rgba(0, 0, 0, 0.01);
    --theme-options-card-border: 1px solid rgba(0, 0, 0, 0.06);
    
    /* Modal Back Button - Light Mode */
    --modal-back-btn-bg: rgba(0, 0, 0, 0.05);
    --modal-back-btn-hover-bg: rgba(0, 0, 0, 0.1);
    --modal-back-btn-color: rgba(0, 0, 0, 0.6);
    --modal-back-btn-hover-color: rgba(0, 0, 0, 0.9);
}

:root[data-theme="dark"] {
    /* Dark Mode Adjustments */
    --theme-option-selected-bg: rgba(91, 139, 196, 0.1);
    --theme-option-selected-border: rgba(91, 139, 196, 0.3);
    --selection-circle-selected: 2px solid #5b8bc4;
    --selection-checkmark-color: #5b8bc4;
    --selection-circle-border: 2px solid rgba(255, 255, 255, 0.3);
    
    /* Theme Option Items - Dark Mode */
    --theme-option-hover-bg: rgba(255, 255, 255, 0.04);
    --theme-option-border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    
    /* Theme Info - Dark Mode */
    --theme-description-color: rgba(255, 255, 255, 0.6);
    --theme-info-card-border: 1px solid rgba(255, 255, 255, 0.1);
    
    /* Theme Info Card - Dark Mode */
    --theme-icon-container-bg: rgba(42, 82, 152, 0.2);
    --theme-icon-container-border: 1px solid rgba(42, 82, 152, 0.3);
    --theme-info-description-color: rgba(255, 255, 255, 0.7);
    
    /* Theme Options Card - Dark Mode */
    --theme-options-card-bg: rgba(255, 255, 255, 0.02);
    --theme-options-card-border: 1px solid rgba(255, 255, 255, 0.08);
    
    /* Modal Back Button - Dark Mode */
    --modal-back-btn-bg: rgba(255, 255, 255, 0.1);
    --modal-back-btn-hover-bg: rgba(255, 255, 255, 0.15);
    --modal-back-btn-color: rgba(255, 255, 255, 0.8);
    --modal-back-btn-hover-color: rgba(255, 255, 255, 1);
}

/* Theme Info Card */
.theme-info-card {
    padding: 40px 24px;
    text-align: center;
    margin: 0 0 0 0;
    position: relative;
}

.theme-info-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--button-border);
}

.theme-icon-container {
    width: var(--theme-icon-container-size);
    height: var(--theme-icon-container-size);
    margin: 0 auto 24px auto;
    background: var(--theme-icon-container-bg);
    border-radius: var(--theme-icon-container-border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(var(--theme-icon-container-blur));
    border: var(--theme-icon-container-border);
}

.theme-icon {
    width: 40px;
    height: 40px;
    filter: brightness(0) saturate(100%) invert(31%) sepia(67%) saturate(1330%) hue-rotate(204deg) brightness(94%) contrast(92%);
}

.theme-info-title {
    margin: 24px 0 16px 0;
    font-size: 32px;
    font-weight: 700;
    color: var(--text-color);
}

.theme-info-description {
    margin: 0 auto 0 auto;
    font-size: 16px;
    color: var(--theme-info-description-color);
    line-height: 1.5;
    max-width: 600px;
}


/* Theme Options Card */
.theme-options-card {
    background: var(--theme-options-card-bg);
    border-radius: var(--theme-options-card-border-radius);
    border: var(--theme-options-card-border);
    margin: var(--theme-options-card-margin);
    overflow: visible;
}

.theme-option-item {
    display: flex;
    align-items: center;
    padding: var(--theme-option-padding);
    border-bottom: var(--theme-option-border-bottom);
    cursor: pointer;
    transition: var(--theme-option-transition);
    position: relative;
}

.theme-option-item:last-child {
    border-bottom: none;
}

.theme-option-item:hover {
    background: var(--theme-option-hover-bg);
}

.theme-option-item.selected {
    background: transparent;
    border-color: transparent;
}

.theme-preview-container {
    margin-right: var(--theme-preview-container-margin);
    flex-shrink: 0;
}

.theme-preview {
    width: var(--theme-preview-width);
    height: var(--theme-preview-height);
    border-radius: var(--theme-preview-border-radius);
    position: relative;
    overflow: hidden;
    border: var(--theme-preview-border);
}

.light-preview {
    background: var(--theme-preview-light-bg);
    color: var(--theme-preview-light-color);
}

.dark-preview {
    background: var(--theme-preview-dark-bg);
    color: var(--theme-preview-dark-color);
}

.auto-preview {
    background: var(--theme-preview-auto-bg);
    position: relative;
}

.auto-preview .auto-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: var(--theme-auto-icon-size);
    opacity: var(--theme-auto-icon-opacity);
}

.preview-header {
    height: var(--theme-preview-header-height);
    margin: var(--theme-preview-header-margin);
    border-radius: var(--theme-preview-header-border-radius);
}

.light-preview .preview-header {
    background: var(--theme-preview-light-header-bg);
}

.dark-preview .preview-header {
    background: var(--theme-preview-dark-header-bg);
}

.auto-preview .preview-header {
    background: var(--theme-preview-dark-header-bg);
}

.preview-content {
    margin: var(--theme-preview-content-margin);
    display: flex;
    flex-direction: column;
    gap: var(--theme-preview-content-gap);
}

.preview-line {
    height: var(--theme-preview-line-height);
    border-radius: var(--theme-preview-line-border-radius);
}

.light-preview .preview-line {
    background: var(--theme-preview-light-line-bg);
    width: 100%;
}

.dark-preview .preview-line {
    background: var(--theme-preview-dark-line-bg);
    width: 100%;
}

.auto-preview .preview-line {
    background: var(--theme-preview-dark-line-bg);
    width: 100%;
}

.preview-line.short {
    width: var(--theme-preview-short-width);
}

.theme-info {
    flex: var(--theme-info-flex);
    display: flex;
    flex-direction: column;
    gap: var(--theme-info-gap);
}

.theme-label {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
}

.theme-description {
    font-size: var(--theme-description-font-size);
    color: var(--theme-description-color);
}

.theme-selection-indicator {
    margin-left: var(--theme-selection-indicator-margin);
    flex-shrink: 0;
}

.selection-circle {
    width: var(--selection-circle-size);
    height: var(--selection-circle-size);
    border: var(--selection-circle-border);
    border-radius: var(--selection-circle-border-radius);
    transition: var(--selection-circle-transition);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-option-item.selected .selection-circle {
    border-color: transparent;
}

.selection-checkmark {
    width: var(--selection-checkmark-size);
    height: var(--selection-checkmark-size);
    opacity: var(--selection-checkmark-opacity);
    transition: var(--selection-circle-transition);
    filter: brightness(0) saturate(100%) invert(31%) sepia(67%) saturate(1330%) hue-rotate(204deg) brightness(94%) contrast(92%);
}

.theme-option-item.selected .selection-checkmark {
    opacity: var(--selection-checkmark-selected-opacity);
}

/* Dark Mode Checkmark Filter */
:root[data-theme="dark"] .selection-checkmark {
    filter: brightness(0) saturate(100%) invert(36%) sepia(73%) saturate(1161%) hue-rotate(196deg) brightness(106%) contrast(82%);
}

/* Modal Back Button */
.modal-back-btn {
    width: var(--modal-action-btn-size);
    height: var(--modal-action-btn-size);
    border-radius: 50%;
    background-color: var(--modal-action-btn-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    z-index: 20;
    color: var(--modal-action-btn-color);
    transition: var(--modal-action-btn-transition);
}

.modal-back-btn:hover {
    background-color: var(--modal-action-btn-hover-bg);
    color: var(--modal-action-btn-hover-color);
}

.modal-back-btn i {
    font-size: var(--modal-action-btn-icon-size);
    font-weight: var(--modal-action-btn-icon-weight);
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    :root {
        /* Mobile Theme Modal Variables */
        --theme-modal-width: 95vw;
        --theme-modal-max-height: 90vh;
        
        /* Mobile Theme Option Items */
        --theme-option-height: 70px;
        --theme-option-padding: 16px;
        
        /* Mobile Theme Preview */
        --theme-preview-width: 50px;
        --theme-preview-height: 35px;
        
        /* Mobile Theme Info Card */
        --theme-info-card-padding: 24px 16px;
        --theme-icon-container-size: 60px;
        --theme-icon-size: 30px;
        --theme-info-title-font-size: 24px;
        --theme-info-description-font-size: 14px;
        
        /* Mobile Selection Indicator */
        --selection-circle-size: 20px;
        --selection-checkmark-size: 16px;
        
        /* Mobile Theme Info */
        --theme-label-font-size: 16px;
        --theme-description-font-size: 13px;
        --theme-preview-container-margin: 12px;
        --theme-selection-indicator-margin: 12px;
    }
    
    /* Mobile Modal */
    .modal {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
    }
    
    /* Mobile Modal Header */
    .modal-header {
        padding: 12px 16px;
    }
    
    .modal-title {
        font-size: 20px;
    }
    
    /* Mobile Theme Info Card */
    .theme-info-card {
        padding: var(--theme-info-card-padding);
    }
    
    .theme-icon-container {
        width: var(--theme-icon-container-size);
        height: var(--theme-icon-container-size);
        margin: 0 auto 16px auto;
    }
    
    .theme-icon {
        width: var(--theme-icon-size);
        height: var(--theme-icon-size);
    }
    
    .theme-info-title {
        font-size: var(--theme-info-title-font-size);
        margin: 16px 0 12px 0;
    }
    
    .theme-info-description {
        font-size: var(--theme-info-description-font-size);
        line-height: 1.4;
    }
    
    /* Mobile Theme Options */
    .theme-options-card {
        margin: 16px 0;
    }
    
    .theme-option-item {
        padding: var(--theme-option-padding);
        min-height: var(--theme-option-height);
    }
    
    .theme-preview-container {
        margin-right: var(--theme-preview-container-margin);
    }
    
    .theme-preview {
        width: var(--theme-preview-width);
        height: var(--theme-preview-height);
    }
    
    .theme-label {
        font-size: var(--theme-label-font-size);
    }
    
    .theme-description {
        font-size: var(--theme-description-font-size);
    }
    
    .theme-selection-indicator {
        margin-left: var(--theme-selection-indicator-margin);
    }
    
    .selection-circle {
        width: var(--selection-circle-size);
        height: var(--selection-circle-size);
    }
    
    .selection-checkmark {
        width: var(--selection-checkmark-size);
        height: var(--selection-checkmark-size);
    }
}

/* Extra Small Mobile Devices */
@media (max-width: 480px) {
    :root {
        /* Extra Small Mobile Variables */
        --theme-modal-width: 98vw;
        --theme-modal-max-height: 95vh;
        
        --theme-option-height: 60px;
        --theme-option-padding: 12px;
        
        --theme-preview-width: 40px;
        --theme-preview-height: 30px;
        
        --theme-info-card-padding: 20px 12px;
        --theme-icon-container-size: 50px;
        --theme-icon-size: 25px;
        --theme-info-title-font-size: 20px;
        --theme-info-description-font-size: 13px;
        
        --theme-label-font-size: 15px;
        --theme-description-font-size: 12px;
        --theme-preview-container-margin: 10px;
        --theme-selection-indicator-margin: 10px;
        
        --selection-circle-size: 18px;
        --selection-checkmark-size: 14px;
    }
    
    .modal {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        margin: 0;
        border-radius: 0;
    }
    
    .modal-header {
        padding: 10px 12px;
    }
    
    .modal-title {
        font-size: 18px;
    }
    
    .theme-info-card {
        padding: var(--theme-info-card-padding);
    }
    
    .theme-icon-container {
        width: var(--theme-icon-container-size);
        height: var(--theme-icon-container-size);
        margin: 0 auto 12px auto;
    }
    
    .theme-icon {
        width: var(--theme-icon-size);
        height: var(--theme-icon-size);
    }
    
    .theme-info-title {
        font-size: var(--theme-info-title-font-size);
        margin: 12px 0 8px 0;
    }
    
    .theme-info-description {
        font-size: var(--theme-info-description-font-size);
        line-height: 1.3;
    }
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Modal Base Styles */
.modal {
    width: var(--theme-modal-width);
    max-height: var(--theme-modal-max-height);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(20px);
    overflow: visible;
    transform: scale(0.9) translateY(20px);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

/* Modal Content */
.modal-content {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.3) transparent;
}

/* Custom Scrollbar für Webkit-Browser */
.modal-content::-webkit-scrollbar {
    width: 8px;
}

.modal-content::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.modal-content::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.5);
}

/* Force scrolling for theme modal */
.modal-content {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    max-height: calc(600px - 80px) !important;
}

/* Specific theme modal scrolling */
#themeModal .modal-content {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    max-height: calc(600px - 80px) !important;
    height: auto !important;
}

#themeModal .modal {
    overflow: visible !important;
    max-height: 600px !important;
}

/* Ultimate theme modal fix */
#themeModal .modal-content,
#themeModal .theme-info-card,
#themeModal .theme-options-card {
    overflow: visible !important;
}

#themeModal .modal-content {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    max-height: calc(600px - 80px) !important;
    height: auto !important;
    flex: 1 !important;
    min-height: 0 !important;
}

/* Mobile Fullscreen Theme Modal */
@media (max-width: 768px) {
    #themeModal .modal {
        width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        margin: 0 !important;
        border-radius: 0 !important;
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
    }
    
    #themeModal .modal-content {
        max-height: calc(100vh - 80px) !important;
        height: calc(100vh - 80px) !important;
    }
}
