/* ============================================================
   SDG Localidades — Estilos personalizados
   ============================================================ */

/* Animaciones */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(46, 117, 182, 0.4); }
    50% { box-shadow: 0 0 0 15px rgba(46, 117, 182, 0); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

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

@keyframes checkmark {
    0% { stroke-dashoffset: 50; }
    100% { stroke-dashoffset: 0; }
}

/* Clases de animación */
.animate-fade-in {
    animation: fadeIn 0.5s ease-out forwards;
}

.animate-slide-in {
    animation: slideIn 0.4s ease-out forwards;
}

.animate-bounce-in {
    animation: bounceIn 0.6s ease-out forwards;
}

.animate-pulse-glow {
    animation: pulseGlow 2s infinite;
}

/* Shimmer loading effect */
.shimmer {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Drop zone hover state */
.drop-zone-active {
    border-color: #2E75B6 !important;
    background-color: rgba(46, 117, 182, 0.05) !important;
    transform: scale(1.01);
}

/* Phase timeline items */
.phase-item {
    transition: all 0.5s ease-out;
    opacity: 0;
    transform: translateX(-10px);
}

.phase-item.visible {
    opacity: 1;
    transform: translateX(0);
}

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

.phase-item.completed .phase-icon {
    color: #10B981;
}

.phase-item.running .phase-icon {
    color: #2E75B6;
    animation: spin 2s linear infinite;
}

.phase-item.error .phase-icon {
    color: #EF4444;
}

.phase-item.pending .phase-icon {
    color: #9CA3AF;
}

/* Progress bar gradient animation */
.progress-animated {
    background: linear-gradient(90deg, #2E75B6, #4A9BDB, #2E75B6);
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

/* File tag colors */
.file-tag { transition: all 0.2s ease; }
.file-tag:hover { transform: translateY(-1px); }

/* Responsive scrollable log */
#detailLog {
    scrollbar-width: thin;
    scrollbar-color: #CBD5E1 transparent;
}

#detailLog::-webkit-scrollbar {
    width: 6px;
}

#detailLog::-webkit-scrollbar-track {
    background: transparent;
}

#detailLog::-webkit-scrollbar-thumb {
    background-color: #CBD5E1;
    border-radius: 3px;
}

/* Custom checkbox animation */
input[type="checkbox"]:checked + label {
    text-decoration: line-through;
    opacity: 0.6;
}

/* Success checkmark animation */
.checkmark-path {
    stroke-dasharray: 50;
    stroke-dashoffset: 50;
    animation: checkmark 0.8s ease-out forwards 0.3s;
}

/* Mascota SVG: estilos y animaciones inline en index.html */

/* ============================================================
   FASES: TRANSICION COMPLETADA -> PENDIENTE
   ============================================================ */

.phase-slide-out {
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0);
    opacity: 1;
}

.phase-slide-out.slide-complete {
    transform: translateY(10px);
    opacity: 0;
}

#completedPhases .phase-item {
    animation: fadeIn 0.5s ease-out forwards;
    opacity: 0.8;
    transform: scale(0.97);
}

#completedPhases .phase-item:hover {
    opacity: 1;
    transform: scale(1);
}

#pendingPhases .phase-item {
    transition: all 0.4s ease-out;
}

#pendingPhases .phase-item.shift-up {
    transform: translateY(-8px);
}

/* Tooltip burbuja */
#mascot-thought::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 12px;
    width: 10px;
    height: 10px;
    background: white;
    border-right: 1px solid #e5e7eb;
    border-bottom: 1px solid #e5e7eb;
    transform: rotate(45deg);
}

/* ============================================================
   TAB BAR — Premium Navigation
   ============================================================ */

/* Tab bar items */
.tab-bar-item {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-muted);
    white-space: nowrap;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
    -webkit-user-select: none;
}

.tab-bar-item:hover {
    color: var(--text-main);
    background: rgba(108, 92, 231, 0.06);
}

.tab-bar-item.active {
    color: var(--accent);
    font-weight: 600;
}

/* Slide underline indicator */
#tabBarIndicator {
    position: absolute;
    bottom: 0;
    height: 2.5px;
    border-radius: 2px;
    background: var(--accent);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    will-change: transform, width;
}

.dark-mode #tabBar {
    background: rgba(15, 15, 26, 0.85) !important;
}

/* Tab icon colors per type */
.tab-bar-item .tab-icon {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

/* ============================================================
   TAB CONTENT PANELS
   ============================================================ */

.tab-panel {
    /* Visible by default (INFORME needs to show even without JS) */
    /* Hidden via .tab-hide when JS switches away from INFORME */
}

.tab-panel-active {
    /* Also visible by default, redundant with above but explicit */
}

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

/* Show/hide classes for INFORME tab (never destroyed) */
.tab-show {
    display: block !important;
    animation: tabFadeIn 0.35s ease-out forwards;
}

.tab-hide {
    display: none !important;
}

/* ============================================================
   DASHBOARD PREMIUM — Charts, Hover Cards, Animations
   ============================================================ */

/* Dashboard Header */
.dashboard-header {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
}
.dashboard-header:hover {
    box-shadow: 0 4px 20px rgba(0,0,0,0.06);
}
.dash-header-icon {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 0.75rem;
    background: linear-gradient(135deg, #1F4E79, #2E75B6);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(31,78,121,0.25);
}
.dark-mode .dash-header-icon {
    background: linear-gradient(135deg, #6C5CE7, #a29bfe);
    box-shadow: 0 4px 12px rgba(108,92,231,0.3);
}
.dash-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
}
.dash-badge-success {
    background: rgba(16,185,129,0.1);
    color: #059669;
    border: 1px solid rgba(16,185,129,0.2);
}
.dark-mode .dash-badge-success {
    background: rgba(16,185,129,0.15);
    color: #34D399;
    border-color: rgba(16,185,129,0.25);
}

/* ═══ PREMIUM METRIC CARDS — con hover overlay ═══ */
.dash-metric-card {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.875rem;
    padding: 1rem 1.125rem;
    transition: all 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    cursor: default;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.dash-metric-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    border-radius: 0.875rem 0.875rem 0 0;
    transition: height 0.3s ease;
}
.dash-metric-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.08);
}
.dark-mode .dash-metric-card:hover {
    box-shadow: 0 8px 25px rgba(0,0,0,0.25);
}
.dash-metric-card:hover::before {
    height: 4px;
}
.dash-metric-card .metric-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}
.dash-metric-card .metric-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}
.dash-metric-card:hover .metric-icon {
    transform: scale(1.1);
}
.dash-metric-card .metric-value {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.03em;
    transition: all 0.3s ease;
}
.dash-metric-card .metric-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
    font-weight: 500;
}
.dash-metric-card .metric-trend {
    font-size: 0.65rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    margin-top: 0.3rem;
}

/* ── HOVER OVERLAY — detalles ocultos que aparecen al hacer hover ── */
.dash-metric-card .metric-hover-overlay {
    position: absolute;
    inset: 0;
    border-radius: 0.875rem;
    background: var(--bg-card);
    padding: 1rem 1.125rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border: 1px solid var(--border);
    box-shadow: 0 8px 30px rgba(0,0,0,0.1);
    z-index: 5;
}
.dash-metric-card:hover .metric-hover-overlay {
    opacity: 1;
    pointer-events: auto;
}
.dark-mode .dash-metric-card .metric-hover-overlay {
    background: var(--bg-card2);
    border-color: var(--accent);
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}
.metric-hover-overlay .hover-title {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.4rem;
}
.metric-hover-overlay .hover-stat {
    font-size: 0.625rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
    padding: 0.15rem 0;
    border-bottom: 1px solid var(--border);
}
.metric-hover-overlay .hover-stat:last-child {
    border-bottom: none;
}
.metric-hover-overlay .hover-stat .stat-label { color: var(--text-muted); }
.metric-hover-overlay .hover-stat .stat-value { font-weight: 700; color: var(--text-main); }
.metric-hover-overlay .hover-bar-container {
    margin-top: 0.4rem;
    height: 0.25rem;
    background: var(--border);
    border-radius: 999px;
    overflow: hidden;
}
.metric-hover-overlay .hover-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.8s ease;
}

/* ═══ CHART CARDS ═══ */
.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}
.chart-card:hover {
    box-shadow: 0 6px 24px rgba(0,0,0,0.06);
    transform: translateY(-1px);
}
.dark-mode .chart-card:hover {
    box-shadow: 0 6px 24px rgba(0,0,0,0.2);
}
.chart-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}
.chart-legend-badge {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: rgba(46,117,182,0.08);
    color: #2E75B6;
    border: 1px solid rgba(46,117,182,0.15);
}
.dark-mode .chart-legend-badge {
    background: rgba(108,92,231,0.12);
    color: #a29bfe;
    border-color: rgba(108,92,231,0.2);
}
.chart-legend-badge-purple {
    background: rgba(139,92,246,0.08);
    color: #7C3AED;
    border-color: rgba(139,92,246,0.15);
}
.dark-mode .chart-legend-badge-purple {
    background: rgba(139,92,246,0.12);
    color: #a78bfa;
    border-color: rgba(139,92,246,0.2);
}
.chart-canvas-wrapper {
    position: relative;
    width: 100%;
    min-height: 200px;
}
.chart-canvas-wrapper canvas {
    width: 100% !important;
    height: auto !important;
    max-height: 220px;
}

/* ═══ ENTRANCE ANIMATIONS ═══ */
@keyframes dashCardIn {
    0% { opacity: 0; transform: translateY(20px) scale(0.96); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes dashChartIn {
    0% { opacity: 0; transform: translateY(30px); }
    100% { opacity: 1; transform: translateY(0); }
}
@keyframes dashCountUp {
    0% { opacity: 0.3; }
    100% { opacity: 1; }
}
@keyframes dashGlowPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(46,117,182,0.15); }
    50% { box-shadow: 0 0 0 8px rgba(46,117,182,0); }
}
.dash-card-enter {
    animation: dashCardIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    opacity: 0;
}
.dash-chart-enter {
    animation: dashChartIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    opacity: 0;
}
.dash-glow-pulse {
    animation: dashGlowPulse 2.5s ease-in-out infinite;
}

/* ═══ DARK MODE SPECIFIC ═══ */
.dark-mode .chart-card {
    background: var(--bg-card2);
    border-color: var(--border);
}
.dark-mode .dash-metric-card {
    background: var(--bg-card2);
}

/* ═══ RESPONSIVE ═══ */
@media (max-width: 640px) {
    .dash-metric-card .metric-value {
        font-size: 1.3rem;
    }
    #metricCardsGrid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .chart-card {
        padding: 0.875rem;
    }
    .chart-canvas-wrapper {
        min-height: 160px;
    }
}
@media (min-width: 641px) and (max-width: 1023px) {
    #metricCardsGrid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* ============================================================
   DASHBOARD — Premium Cards (legacy styles preserved)
   ============================================================ */

/* Metric card */
.dashboard-card {
    background: var(--bg-card2);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow);
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.dashboard-card .card-icon {
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.5rem;
}

.dashboard-card .card-value {
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
}

.dashboard-card .card-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.125rem;
}

/* Mini bar chart (CSS-only) */
.dashboard-minibar {
    height: 0.375rem;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
    margin-top: 0.5rem;
}

.dashboard-minibar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Dashboard accordion */
.dashboard-accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--bg-card2);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.dashboard-accordion-header:hover {
    border-color: var(--accent);
    background: var(--bg-card);
}

.dashboard-accordion-header .accordion-arrow {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 1.25rem;
    height: 1.25rem;
    color: var(--text-muted);
}

.dashboard-accordion-header.open .accordion-arrow {
    transform: rotate(180deg);
}

.dashboard-accordion-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    opacity: 0;
}

.dashboard-accordion-body.open {
    max-height: 2000px;
    opacity: 1;
}

/* Dashboard section grid */
.dashboard-section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    padding: 0.75rem 0;
}

/* ============================================================
   DARK MODE ADAPTATIONS
   ============================================================ */

.dark-mode .dashboard-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.dark-mode .dashboard-accordion-header.open {
    border-color: var(--accent);
}

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

@media (max-width: 640px) {
    .tab-bar-item {
        padding: 0.375rem 0.625rem;
        font-size: 0.75rem;
    }
    .dashboard-card .card-value {
        font-size: 1.25rem;
    }
    #dashboardCards {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .dashboard-section-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================================
   PREFERS REDUCED MOTION
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
    .tab-panel {
        animation: none;
    }
    .tab-show {
        animation: none;
    }
    #tabBarIndicator {
        transition: none;
    }
    .dashboard-card:hover {
        transform: none;
    }
    .dashboard-accordion-body {
        transition: none;
    }
}
