/* ===== CSS CUSTOM PROPERTIES FOR THEMES ===== */
:root[data-theme="light"] {
    --primary-500: #2563EB;
    --accent-500: #3B82F6;
    --bg-page: #FAFAFA;
    --bg-surface: #FFFFFF;
    --text-primary: #0F172A;
    --text-secondary: #64748B;
    --border-subtle: #E2E8F0;
    --gradient-primary: linear-gradient(135deg, #2563EB 0%, #4F46E5 100%);
    --loading-color: var(--primary-500);
    --success-color: #10B981;
    --error-color: #EF4444;
}

:root[data-theme="dark"] {
    --primary-500: #3B82F6;
    --accent-500: #60A5FA;
    --bg-page: #0F172A;
    --bg-surface: #1E293B;
    --text-primary: #F8FAFC;
    --text-secondary: #CBD5E1;
    --border-subtle: #334155;
    --gradient-primary: linear-gradient(135deg, #3B82F6 0%, #8B5CF6 100%);
    --loading-color: var(--primary-500);
    --success-color: #10B981;
    --error-color: #EF4444;
}

:root[data-theme="blue"] {
    --primary-500: #1D4ED8;
    --accent-500: #3B82F6;
    --bg-page: #F0F9FF;
    --bg-surface: #FFFFFF;
    --text-primary: #1E3A8A;
    --text-secondary: #475569;
    --border-subtle: #BFDBFE;
    --gradient-primary: linear-gradient(135deg, #1D4ED8 0%, #0891B2 100%);
    --loading-color: var(--primary-500);
    --success-color: #059669;
    --error-color: #DC2626;
}

/* ===== THEME SWITCHER STYLING ===== */
.theme-dropdown.show {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
}

.theme-option.active-theme {
    background: var(--gradient-primary) !important;
    color: white !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.theme-option.active-theme .theme-preview {
    border-color: white !important;
}

.theme-option.active-theme .text-left div:first-child {
    color: white !important;
}

.theme-option.active-theme .text-left div:last-child {
    color: rgba(255, 255, 255, 0.8) !important;
}

/* ===== LOADING STATES ===== */
.giscus-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    transition: opacity 0.3s ease;
}

.giscus-loading-state.hidden {
    display: none;
}

.loading-spinner-container {
    margin-bottom: 24px;
    position: relative;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-subtle);
    border-top: 3px solid var(--loading-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

.loading-dots {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 16px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--loading-color);
    animation: pulseSoft 1.4s ease-in-out infinite both;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }
.dot:nth-child(3) { animation-delay: 0s; }

.loading-content {
    text-align: center;
}

.loading-text {
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 8px 0;
}

.loading-subtext {
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 400;
    margin: 0;
    opacity: 0.7;
}

/* ===== ERROR STATE ===== */
.giscus-error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.giscus-error-state.hidden {
    display: none;
}

.error-icon {
    margin-bottom: 16px;
}

.error-title {
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0 0 8px 0;
}

.error-message {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin: 0 0 24px 0;
}

.retry-button {
    transition: all 0.3s ease;
}

.retry-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.25);
}

/* ===== FEATURE CARDS ===== */
.feature-card {
    transition: all 0.3s ease;
    cursor: default;
}

.feature-card:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.8);
}

.feature-icon {
    transition: all 0.3s ease;
}

.feature-card:hover .feature-icon {
    transform: scale(1.1);
}

/* ===== THEME TRANSITION EFFECTS ===== */
.theme-changing {
    transition: all 0.3s ease;
}

.theme-changing * {
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease !important;
}

/* ===== ANIMATIONS ===== */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes pulseSoft {
    0%, 80%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    40% {
        opacity: 1;
        transform: scale(1.2);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounceGentle {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

.animate-fade-in {
    animation: fadeIn 0.6s ease-in-out;
}

.animate-bounce-gentle {
    animation: bounceGentle 2s infinite;
}

.animate-pulse-soft {
    animation: pulseSoft 2s infinite;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 768px) {
    .loading-spinner {
        width: 36px;
        height: 36px;
    }
    
    .feature-card {
        padding: 20px;
    }
    
    .feature-icon {
        width: 40px;
        height: 40px;
    }
}

@media (max-width: 480px) {
    .loading-spinner {
        width: 32px;
        height: 32px;
    }
    
    .feature-card {
        padding: 16px;
    }
}

/* ===== DYNAMIC BACKGROUNDS ===== */
body[data-theme="light"] {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 50%, #f1f5f9 100%);
    color: var(--text-primary);
}

body[data-theme="dark"] {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    color: var(--text-primary);
}

body[data-theme="blue"] {
    background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 50%, #f0f9ff 100%);
    color: var(--text-primary);
}

/* ===== SMOOTH TRANSITIONS ===== */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ===== THEME SWITCHER ENHANCEMENTS ===== */
.theme-dropdown {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.theme-option:hover .theme-preview {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.theme-option.active-theme .theme-preview {
    transform: scale(1.05);
    border-color: white !important;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.3);
}

/* ===== ACCESSIBILITY IMPROVEMENTS ===== */
button:focus,
select:focus,
input:focus {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
    .theme-option {
        border: 1px solid currentColor !important;
    }
    
    .feature-card {
        border-width: 2px !important;
    }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .loading-spinner {
        animation: none;
        border-top-color: var(--loading-color);
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .theme-dropdown,
    .theme-toggle {
        display: none !important;
    }
    
    .feature-card {
        border: 1px solid #ccc !important;
        box-shadow: none !important;
        page-break-inside: avoid;
    }
}

/* ===== FOCUS VISIBLE IMPROVEMENTS ===== */
button:focus-visible,
select:focus-visible,
input:focus-visible {
    outline: 2px solid var(--primary-500);
    outline-offset: 2px;
}

/* ===== UTILITY CLASSES ===== */
.transition-smooth {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.backdrop-blur-strong {
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}