/* ==========================================
   SISTEMA DE TEMAS - DARK/LIGHT MODE
   ========================================== */

/* ==========================================
   VARIÁVEIS BASE (LIGHT THEME - PADRÃO)
   ========================================== */
:root {
    /* Cores Base Light Theme */
    --primary-blue: #1a73e8;
    --primary-blue-hover: #1557b0;
    --primary-blue-light: #e8f0fe;
    --primary-blue-dark: #0d47a1;
    
    /* Backgrounds Light */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #ffffff;
    --bg-hover: #f1f3f4;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    
    /* Text Colors Light */
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --text-light: #9aa0a6;
    --text-muted: #dadce0;
    
    /* Borders Light */
    --border-color: #dadce0;
    --border-hover: #bdc1c6;
    --border-focus: #1a73e8;
    
    /* Shadows Light */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1), 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1), 0 10px 10px rgba(0, 0, 0, 0.04);
    
    /* Gradientes Light */
    --gradient-primary: linear-gradient(135deg, #1a73e8 0%, #4285f4 100%);
    --gradient-surface: linear-gradient(135deg, #f8f9fa 0%, #ffffff 100%);
    --gradient-card: linear-gradient(145deg, #ffffff 0%, #f8f9fa 100%);
    --gradient-card-hover: linear-gradient(135deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.98) 100%);
    
    /* Status Colors */
    --success-color: #34a853;
    --warning-color: #fbbc04;
    --error-color: #ea4335;
    --info-color: #4285f4;
    
    /* Variáveis adicionais para tema claro */
    --text-light: #94a3b8;
    --primary-blue: #4a90e2;
    
    /* Theme Identifier */
    --theme-mode: 'light';
}

/* ==========================================
   DARK THEME VARIABLES
   ========================================== */
[data-theme="dark"] {
    /* Cores Base Dark Theme */
    --primary-blue: #4285f4;
    --primary-blue-hover: #5a9bff;
    --primary-blue-light: #1e3a8a;
    --primary-blue-dark: #1d4ed8;
    
    /* Backgrounds Dark */
    --bg-primary: #121212;
    --bg-secondary: #1e1e1e;
    --bg-tertiary: #2d2d2d;
    --bg-hover: #2a2a2a;
    --bg-card: #1e1e1e;
    --bg-input: #2d2d2d;
    
    /* Text Colors Dark */
    --text-primary: #e8eaed;
    --text-secondary: #9aa0a6;
    --text-light: #5f6368;
    --text-muted: #3c4043;
    
    /* Borders Dark */
    --border-color: #3c4043;
    --border-hover: #5f6368;
    --border-focus: #4285f4;
    
    /* Shadows Dark (mais sutis) */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4), 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5), 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.6), 0 10px 10px rgba(0, 0, 0, 0.5);
    
    /* Gradientes Dark */
    --gradient-primary: linear-gradient(135deg, #4285f4 0%, #1d4ed8 100%);
    --gradient-surface: linear-gradient(135deg, #1e1e1e 0%, #2d2d2d 100%);
    --gradient-card: linear-gradient(145deg, #1e1e1e 0%, #2d2d2d 100%);
    --gradient-card-hover: linear-gradient(135deg, rgba(45, 45, 45, 0.98) 0%, rgba(30, 30, 30, 0.98) 100%);
    
    /* Status Colors Dark (mais vibrantes) */
    --success-color: #4caf50;
    --warning-color: #ff9800;
    --error-color: #f44336;
    --info-color: #2196f3;
    
    /* Variáveis adicionais para tema dark */
    --text-light: #5f6368;
    --primary-blue: #4285f4;
    
    /* Theme Identifier */
    --theme-mode: 'dark';
}

/* ==========================================
   THEME TOGGLE BUTTON
   ========================================== */
.theme-toggle {
    background: transparent;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--text-secondary);
    position: relative;
    overflow: hidden;
    margin-right: 16px;
}

.theme-toggle:hover {
    border-color: var(--primary-blue);
    color: var(--primary-blue);
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-icon {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: absolute;
}

.theme-icon.hidden {
    opacity: 0;
    transform: rotate(180deg) scale(0.5);
}

.theme-icon:not(.hidden) {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* Animação especial para o toggle */
.theme-toggle.switching {
    animation: themeSwitch 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes themeSwitch {
    0% { transform: scale(1) rotate(0deg); }
    50% { transform: scale(0.8) rotate(180deg); }
    100% { transform: scale(1) rotate(360deg); }
}

/* ==========================================
   APLICAÇÃO DOS TEMAS NOS COMPONENTES
   ========================================== */

/* Body e estrutura principal */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Headers */
.main-header {
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

/* Cards e surfaces */
.result-item,
.publication-card,
.skeleton-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.result-item:hover,
.publication-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-lg);
}

/* Inputs e formulários */
.search-input,
.compact-input {
    background-color: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--border-color);
    transition: all 0.3s ease;
}

.search-input::placeholder,
.compact-input::placeholder {
    color: var(--text-light);
}

.search-input-wrapper {
    background: var(--gradient-surface);
    border-color: var(--border-color);
    transition: all 0.3s ease;
}

.search-input-wrapper:focus-within {
    border-color: var(--border-focus);
    box-shadow: var(--shadow-md);
}

/* Botões */
.search-button,
.compact-button {
    background: var(--gradient-primary);
    transition: all 0.3s ease;
}

.action-button {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    border-color: var(--border-color);
    transition: all 0.3s ease;
}

.action-button:hover {
    background-color: var(--primary-blue);
    color: white;
    border-color: var(--primary-blue);
}

.action-button.primary {
    background: var(--gradient-primary);
    color: white;
}

/* Filtros */
.filter-button {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    border-color: var(--border-color);
    transition: all 0.3s ease;
}

.filter-button:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}

.filter-button.active {
    background: var(--gradient-primary);
    color: white;
    border-color: transparent;
}

/* Footer */
.main-footer {
    background-color: var(--bg-secondary);
    color: var(--text-secondary);
    border-top: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

/* Loading states */
.loading-state {
    color: var(--text-secondary);
}

.skeleton {
    background: linear-gradient(90deg, var(--bg-hover) 25%, var(--border-color) 50%, var(--bg-hover) 75%);
    background-size: 200% 100%;
}

/* Toast notifications */
.toast {
    background-color: var(--bg-card);
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

/* Scrollbar para dark mode */
[data-theme="dark"] ::-webkit-scrollbar {
    width: 8px;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
    background: var(--border-hover);
}

/* ==========================================
   ANIMAÇÕES DE TRANSIÇÃO DE TEMA
   ========================================== */
.theme-transition {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Classe temporária para smooth transition */
.theme-switching * {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* ==========================================
   PREFERÊNCIAS DO SISTEMA
   ========================================== */
@media (prefers-color-scheme: dark) {
    /* Não aplicar automaticamente - usuário deve escolher */
    /* Sistema respeita apenas a escolha manual */
}

/* ==========================================
   INDICADORES VISUAIS DE TEMA
   ========================================== */

/* Badge no canto para debug (removível em produção) */
.theme-indicator {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: var(--gradient-primary);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.theme-indicator.show {
    opacity: 1;
}

/* ==========================================
   RESPONSIVIDADE DO THEME TOGGLE
   ========================================== */
@media (max-width: 768px) {
    .theme-toggle {
        width: 40px;
        height: 40px;
        margin-right: 12px;
    }
    
    .theme-icon {
        width: 18px;
        height: 18px;
    }
}

/* ==========================================
   ESTADOS ESPECIAIS
   ========================================== */

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000000;
        --text-secondary: #000000;
    }
    
    [data-theme="dark"] {
        --border-color: #ffffff;
        --text-secondary: #ffffff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .theme-toggle,
    .theme-icon,
    .theme-switching *,
    .theme-transition {
        transition: none !important;
        animation: none !important;
    }
}

/* ==========================================
   VARIÁVEIS GLOBAIS DE TRANSIÇÃO
   ========================================== */
:root {
    /* Easing curves para animações suaves */
    --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-in: cubic-bezier(0.4, 0, 1, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
}
