/* ==========================================================================
1. IMPORTACIONES, REBOOT & TIPOGRAFÍA
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=Archivo:ital,wght@0,700;0,900;1,900&family=Doto:wght@400;700&display=swap');

*, *::before, *::after { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
}

html {
    height: 100%;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}


/* ==========================================================================
   2. SISTEMA DE VARIABLES Y SOPORTE DE TEMAS (CLARO Y OSCURO)
   ========================================================================== */
:root, [data-theme="dark"] {
    --bg-main: #000000;
    --text-main: #e2e8f0;
    --footer-text: #9aa0a6;
    --card-bg: #121212;
    --header-bg: #000000;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --bg-hover: #262626;
    --accent-color: #60a5fa;
    --accent-hover: #93c5fd;
}

[data-theme="light"] {
    --bg-main: #ffffff;
    --text-main: #0f172a;
    --footer-text: #5f6368;
    --card-bg: #ffffff;
    --header-bg: #f8fafc;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --bg-hover: #f1f5f9;
    --accent-color: #2563eb;
    --accent-hover: #1d4ed8;
}

body { 
    font-family: Arial, Helvetica, sans-serif; 
    background-color: var(--bg-main);
    color: var(--text-main); 
    font-size: 1rem; 
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    width: 100%;
    transition: background-color 0.2s ease, color 0.2s ease;
}


/* ==========================================================================
   3. PANTALLA DE BIENVENIDA Y ANIMACIÓN INICIAL (INTRO OVERLAY)
   ========================================================================== */
.intro-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-main);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    z-index: 10000;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.intro-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.intro-title-anim {
    font-family: 'Archivo', sans-serif;
    font-weight: 900;
    font-size: 4.5rem;
    letter-spacing: 2px;
}

.intro-title-anim .type-char {
    display: inline-block;
    opacity: 0;
    transform: translateY(20px);
    animation: revealChar 0.3s ease forwards;
    animation-delay: calc(0.2s * var(--i));
}

@keyframes revealChar {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Efecto de giro tipo moneda para el arepa.png */
.intro-arepa-container {
    perspective: 1000px;
}

.intro-arepa-img {
    width: 64px;
    height: 64px;
    object-fit: contain;
    animation: coinFlip 1.2s ease-in-out infinite;
    transform-style: preserve-3d;
}

@keyframes coinFlip {
    0% {
        transform: rotateY(0deg);
    }
    100% {
        transform: rotateY(360deg);
    }
}


/* ==========================================================================
   4. LETRERO LED SUPERIOR
   ========================================================================== */
.led-banner-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 9999;
    background-color: #1a1a1a;
    border-bottom: 2px solid #333333;
    overflow: hidden;
    white-space: nowrap;
    padding: 4px 0; 
    box-sizing: border-box;
    height: 32px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

.led-banner-text {
    display: inline-block;
    font-family: 'Doto', monospace;
    font-style: normal;
    font-weight: 700;
    font-size: 1.07rem;
    color: #ffcc00;
    text-shadow: 0 0 4px rgba(255, 204, 0, 0.7);
    text-transform: uppercase;
    padding-left: 100%; 
    animation: led-scroll 25s linear infinite;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    will-change: transform;
}

.led-banner-container:hover .led-banner-text {
    animation-play-state: paused;
}

@keyframes led-scroll {
    0% { transform: translate3d(0, 0, 0); }
    100% { transform: translate3d(-100%, 0, 0); }
}


/* ==========================================================================
   5. HEADER Y BARRA SUPERIOR (STICKY)
   ========================================================================== */
.header-container {
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
    margin: 0;
    overflow: hidden;
    flex-shrink: 0;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 12px 24px;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.banner-info-bar {
    position: relative;
    z-index: 3;
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 0;
    font-size: 0.9rem; 
    gap: 12px;
}

.info-widgets-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: nowrap;
}

.header-overlay-text {
    font-family: 'Archivo', sans-serif;
    font-weight: 900;
    font-style: italic;
    font-size: 1.15rem; 
    text-transform: uppercase;
    color: var(--text-main);
    letter-spacing: 0.5px;
    line-height: 1;
    margin-right: 6px;
}

.widget-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    white-space: nowrap;
    font-size: 0.88rem;
    font-weight: 400;
}

.info-widgets-right {
    display: flex;
    align-items: center;
    margin-left: auto;
}

.header-actions {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
}

.header-link {
    color: var(--accent-color);
    font-size: 0.9rem; 
    text-decoration: none;
    font-weight: 400;
    transition: color 0.15s ease, opacity 0.15s ease;
    padding: 4px 0;
}

.header-link:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}


/* ==========================================================================
   6. LAYOUT CENTRAL Y PORTAL (DASHBOARD)
   ========================================================================== */
.central-layout {
    max-width: 1120px; 
    margin: 0 auto;
    width: 100%;
    padding: 0 24px 60px 24px;
    flex: 1 0 auto; 
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}

.page-title {
    font-family: 'Archivo', sans-serif;
    font-weight: 900;
    font-style: italic;
    text-transform: uppercase;
    font-size: 4.4rem; 
    text-align: center;
    color: var(--text-main);
    user-select: none;
    letter-spacing: -0.5px;
    transition: color 0.2s ease;
}

.page-title .flag-yellow { color: #facc15; }
.page-title .flag-blue { color: #3b82f6; }
.page-title .flag-red { color: #ef4444; }


/* ==========================================================================
   7. BOTONES DE ACCIÓN, DESPLEGABLES Y TOOLTIPS
   ========================================================================== */
.index-action-btn {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 14px;
    cursor: pointer;
    color: var(--text-main);
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: Arial, Helvetica, sans-serif;
    transition: all 0.2s ease;
    text-decoration: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.index-action-btn:hover {
    transform: translateY(-1px);
    border-color: var(--accent-color);
    background-color: var(--bg-hover);
}

.section-dropdown-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.section-action-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 5px 10px;
    cursor: pointer;
    color: var(--text-main);
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: Arial, Helvetica, sans-serif;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.section-action-btn:hover:not(:disabled) {
    background-color: var(--bg-hover);
}

.section-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 1000;
    min-width: 240px;
    list-style: none;
    padding: 6px 0;
    margin: 0;
}

.section-dropdown-menu.show {
    display: block;
}

.section-dropdown-item {
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 13px;
    padding: 8px 16px;
    text-align: left;
    cursor: pointer;
    text-decoration: none;
    display: block;
    width: 100%;
    transition: background-color 0.15s ease, color 0.15s ease;
    font-family: Arial, Helvetica, sans-serif;
}

.section-dropdown-item:hover, .section-dropdown-item.active-sub {
    background-color: var(--bg-hover);
    color: var(--accent-color);
    font-weight: 700;
}

/* Tooltips */
.tooltip-container {
    position: relative;
    display: inline-flex;
}

.custom-tooltip {
    visibility: hidden;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background-color: var(--card-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 400;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    opacity: 0;
    z-index: 1000;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.tooltip-container:hover .custom-tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}


/* ==========================================================================
   8. MODALES GENERALES (FLAT MODERN UI)
   ========================================================================== */
dialog.category-modal {
    background-color: var(--card-bg);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 0;
    margin: auto;
    width: 90%;
    max-width: 860px;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.6);
    opacity: 0;
    transform: scale(0.96) translateY(6px);
    overflow: hidden !important;
    transition: 
        opacity 0.2s ease-out, 
        transform 0.2s ease-out, 
        overlay 0.2s ease-out allow-discrete, 
        display 0.2s ease-out allow-discrete;
}

dialog.category-modal[open] {
    opacity: 1;
    transform: scale(1) translateY(0);
}

dialog::backdrop {
    background-color: rgba(0, 0, 0, 0);
    transition: background-color 0.2s ease-out, overlay 0.2s ease-out allow-discrete, display 0.2s ease-out allow-discrete;
}

dialog.category-modal[open]::backdrop {
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background-color: var(--header-bg);
}

.modal-header h3 {
    font-size: 1rem;
    color: var(--accent-color);
    margin: 0;
    font-weight: 600;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    line-height: 1;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.modal-close-btn:hover {
    background-color: var(--bg-hover);
    color: var(--text-main);
}


/* ==========================================================================
   9. DIRECTORIO Y COMPONENTES DE LISTAS
   ========================================================================== */
.directory-container {
    width: 100%;
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
}

.directory-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
    width: 100%;
    align-items: center;
}

.tab-pane {
    display: none;
    width: 100%;
    flex-direction: column;
    gap: 24px;
    align-items: center;
}

.tab-pane.active {
    display: flex;
}

.dept-categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 28px;
    width: 100%;
    justify-content: center;
    justify-items: center;
}

.dept-category-block {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: transparent;
    width: 100%;
    max-width: 380px;
}

.dept-category-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.dept-links-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dept-link-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.dept-link-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.dept-link-anchor {
    color: var(--accent-color);
    font-weight: 400;
    font-size: 14px;
    text-decoration: none;
}

.dept-link-anchor:hover {
    text-decoration: underline;
}

.dept-link-desc {
    font-size: 12px;
    color: var(--text-muted);
}

.status-badge {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    margin-left: 4px;
    background-color: #94a3b8; /* Color neutro por defecto / verificando */
    transition: background-color 0.2s ease;
}

.status-badge.checking {
    background-color: #f59e0b; /* Amarillo mientras comprueba */
}

.status-badge.online {
    background-color: #10b981; /* Verde real para servicios activos */
}

.status-badge.offline {
    background-color: #ef4444; /* Rojo estricto para servicios caídos o bloqueados */
}


/* ==========================================================================
   10. BOTÓN DE TEMA Y FOOTER
   ========================================================================== */
.theme-toggle-btn {
    background: transparent !important;
    border: none !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 4px !important;
    transition: opacity 0.15s ease, transform 0.15s ease;
    color: var(--text-muted);
    flex-shrink: 0;
}

.theme-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle-btn:hover { color: var(--text-main); opacity: 1; transform: scale(1.05); }
.theme-toggle-btn:active { transform: scale(0.95); }

.footer-theme-btn {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    text-decoration: none;
}
.footer-theme-btn:hover {
    background: none !important;
    text-decoration: underline;
}

.search-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
    padding: 6px 24px;
    margin-top: auto;
    width: 100%;
    box-sizing: border-box;
    color: var(--footer-text);
    background-color: var(--header-bg);
    border-top: 1px solid var(--border-color);
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.footer-links a, .footer-author-link {
    color: var(--footer-text);
    text-decoration: none;
}

.footer-links a:hover, .footer-author-link:hover {
    text-decoration: underline;
    color: var(--text-main);
}

.footer-author-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.brand-subtle { 
    color: var(--accent-color); 
    font-weight: 500; 
}


/* ========================================== */
/* SPINNER CIRCULAR                            */
/* ========================================== */
.circular-loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 16px;
    width: 100%;
}

.circular-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(96, 165, 250, 0.2);
    border-top-color: var(--accent-color);
    border-radius: 50%;
    animation: spinLoader 0.8s linear infinite;
}

@keyframes spinLoader {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.circular-loader-text {
    font-size: 0.88rem;
    color: var(--text-muted);
    transition: color 0.2s ease;
}


/* ========================================== */
/* MEDIA QUERIES RESPONSIVAS                   */
/* ========================================== */
@media (max-width: 768px) {
    .header-container {
        height: auto;
        min-height: 44px;
        padding: 10px 16px;
    }
     
    .banner-info-bar {
        flex-wrap: wrap;
        padding: 0;
        gap: 8px;
    }

    .info-widgets-left {
        gap: 8px;
        flex-wrap: wrap;
    }

    .info-widgets-right {
        width: 100%;
        justify-content: flex-end;
        margin-top: 4px;
        border-top: 1px solid var(--border-color);
        padding-top: 8px;
    }

    .header-actions {
        align-items: flex-end;
    }

    .central-layout {
        padding: 0 16px 60px 16px;
    }

    .category-modal { 
        max-width: 100%; 
    }
}