/* --- Reset Básico y Variables Globales --- */
:root {
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-main: #f5f5f5;
    --text-muted: #a0a0a0;
    --accent-red: #d32f2f;
    --accent-red-hover: #b71c1c;
    --accent-blue: #2196F3;
    --accent-blue-hover: #1976D2;
    --border-color: #333333;
    --input-bg: #121212;
}

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

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    font-size: 16px;
    min-height: 100vh;
    padding: 12px;
}

a {
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--accent-red);
    color: white;
    min-height: 50px;
    margin-top: 20px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 8px;
    padding: 10px 20px;
    transition: background-color 0.3s;
}

a:hover {
    background-color: var(--accent-red-hover);
}

.hidden {
    display: none !important;
}

/* --- Animación de Carga --- */
#loader-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(18, 18, 18, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease;
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 90%;
    max-width: 350px;
}

.loader-logo {
    width: 160px;
    height: 160px;
    margin-bottom: 25px;
    animation: pulse-logo 1.8s infinite ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loader-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform: scale(1.6);
}

@keyframes pulse-logo {
    0% {
        transform: scale(0.95);
        opacity: 0.8;
    }

    50% {
        transform: scale(1.05);
        opacity: 1;
        filter: drop-shadow(0 0 12px rgba(211, 47, 47, 0.6));
    }

    100% {
        transform: scale(0.95);
        opacity: 0.8;
    }
}

.loader-progress-container {
    width: 100%;
    height: 6px;
    background-color: #333333;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 15px;
    position: relative;
}

.loader-progress-bar {
    width: 40%;
    height: 100%;
    background: linear-gradient(90deg, #b71c1c, #ff5252, #b71c1c);
    border-radius: 10px;
    position: absolute;
    left: 0;
    animation: loading-bar 1.5s infinite linear;
    transition: width 0.4s ease;
}

@keyframes loading-bar {
    0% {
        left: -40%;
        width: 40%;
    }

    50% {
        left: 30%;
        width: 60%;
    }

    100% {
        left: 100%;
        width: 40%;
    }
}

.loader-title {
    color: #ffffff;
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 8px 0;
    text-align: center;
    letter-spacing: 0.5px;
}

.loader-text {
    color: #a0a0a0;
    font-size: 14px;
    text-align: center;
    margin: 0;
    line-height: 1.4;
    white-space: pre-line;
}

/* --- Contenedor Principal --- */
.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 550px;
}

/* --- Cabecera y Logo --- */
.container-logo {
    background-color: var(--card-bg);
    margin: 60px auto 25px auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 25px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    width: 100%;
}

header {
    text-align: center;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
}

#logoAnimado {
    width: 100%;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
    overflow: visible;
}

#logoAnimado img {
    height: 100%;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    transform: scale(1.5);
}

header p {
    color: var(--text-muted);
    font-size: 14px;
    margin: 10px 0 0 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* --- Botón Volver Inicio --- */
.btn-back-home {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #a0a0a0;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    transition: color 0.2s;
    z-index: 100;
    background-color: transparent !important;
    padding: 0 !important;
    min-height: auto !important;
    margin: 0 !important;
}

.btn-back-home:hover {
    color: #fff;
}

/* --- Pestañas (Tabs) Optimizadas --- */
.tabs-container {
    display: flex;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 6px;
    margin-bottom: 25px;
    width: 100%;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    gap: 6px;
}

.tab {
    flex: 1;
    padding: 10px 4px;
    font-size: 12px;
    border: none;
    background: transparent;
    border-radius: 6px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.tab span.material-symbols-outlined {
    font-size: 22px;
}

.tab:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.05);
}

.tab.active {
    background: var(--bg-color);
    color: var(--accent-red);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
    border: 1px solid var(--border-color);
}

/* --- Formularios --- */
#incidencia-form,
#form-edicion {
    background-color: var(--card-bg);
    padding: 18px;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    width: 100%;
    display: flex;
    flex-direction: column;
    text-align: left;
    box-sizing: border-box;
}

#incidencia-form>div,
#form-edicion>div {
    margin-bottom: 20px;
}

label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}

input[type="datetime-local"],
input[type="date"],
input[type="text"],
select,
textarea {
    width: 100%;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px;
    color: var(--text-main);
    outline: none;
    transition: all 0.3s ease;
    font-size: 16px;
    box-sizing: border-box;
    font-family: inherit;
}

textarea {
    min-height: 100px;
    resize: vertical;
    line-height: 1.4;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent-red);
    background-color: #1a1a1a;
}

input[type="date"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
    opacity: 0.6;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

/* --- Botones Genéricos --- */
.btn {
    width: 100%;
    font-weight: bold;
    padding: 14px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    text-align: center;
    transition: all 0.3s ease;
    font-size: 16px;
    box-sizing: border-box;
}

.btn-primary {
    background-color: var(--accent-blue);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: var(--accent-blue-hover);
}

.btn-secondary {
    flex: 1;
    min-width: 120px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    color: var(--text-main);
}

.btn-secondary:hover {
    background-color: #2c2c2c;
    border-color: #555;
}

/* --- Botón Unificado de IA y Ondas de Sonido --- */
.ia-panel {
    background: rgba(106, 27, 154, 0.1);
    border: 1px dashed #6a1b9a;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.btn-ia-circle {
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: #6a1b9a;
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(106, 27, 154, 0.4);
    transition: all 0.3s ease;
    margin: 10px auto 0 auto;
}

.btn-ia-circle span {
    font-size: 28px;
}

.btn-ia-circle.recording {
    background: #ef4444;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.6);
}

.btn-ia-circle.processing {
    background: #f59e0b;
    animation: spin-sparkle 1.5s infinite;
}

/* Ondas de Sonido (Estilo Gemini) */
.voice-wave {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 24px;
}

.voice-wave .bar {
    width: 4px;
    background-color: white;
    border-radius: 2px;
    animation: wave 1s infinite ease-in-out;
}

.voice-wave .bar:nth-child(1) {
    height: 40%;
    animation-delay: -1.2s;
}

.voice-wave .bar:nth-child(2) {
    height: 80%;
    animation-delay: -1.0s;
}

.voice-wave .bar:nth-child(3) {
    height: 100%;
    animation-delay: -0.8s;
}

.voice-wave .bar:nth-child(4) {
    height: 80%;
    animation-delay: -0.6s;
}

.voice-wave .bar:nth-child(5) {
    height: 40%;
    animation-delay: -0.4s;
}

@keyframes wave {

    0%,
    100% {
        transform: scaleY(0.4);
    }

    50% {
        transform: scaleY(1);
    }
}

@keyframes spin-sparkle {
    0% {
        transform: scale(0.95);
        filter: hue-rotate(0deg);
    }

    50% {
        transform: scale(1.1);
        filter: hue-rotate(45deg);
        box-shadow: 0 0 20px #f59e0b;
    }

    100% {
        transform: scale(0.95);
        filter: hue-rotate(0deg);
    }
}

/* --- Historial / Bitácora --- */
.grid-historial {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    width: 100%;
}

.miniatura-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    text-align: left;
    position: relative;
    padding-right: 40px;
    /* Espacio para el botón eliminar */
}

.miniatura-card:hover {
    transform: translateY(-3px);
    border-color: var(--accent-red);
    box-shadow: 0 6px 12px rgba(211, 47, 47, 0.2);
}

.miniatura-card img,
.miniatura-card>div:first-child {
    width: 100px;
    height: 100px;
    object-fit: cover;
    flex-shrink: 0;
    border-right: 1px solid var(--border-color);
}

.miniatura-info {
    padding: 12px 10px;
    flex: 1;
}

.miniatura-info h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    color: var(--text-main);
    font-weight: 600;
}

.miniatura-info p {
    margin: 0;
    font-size: 14px;
    color: var(--text-muted);
}

/* --- Botón Eliminar Tarjeta --- */
.btn-delete-card {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(220, 38, 38, 0.85);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    transition: background 0.3s, transform 0.2s;
}

.btn-delete-card:hover {
    background: #b91c1c;
    transform: scale(1.1);
}

.badge-offline {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #f59e0b;
    color: #000;
    font-size: 10px;
    font-weight: bold;
    padding: 4px 6px;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 10;
    line-height: 1;
    white-space: nowrap;
}

/* --- Modal Edición (Flotante) --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
}

.modal-content {
    background: var(--card-bg);
    width: 100%;
    max-width: 500px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    padding: 20px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    margin-top: 0;
    color: #eab308;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

/* --- Autocompletado Oscuro --- */
.custom-dropdown-container {
    position: relative;
    width: 100%;
}

.custom-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-top: 5px;
    max-height: 220px;
    overflow-y: auto;
    z-index: 1000;
    list-style: none;
    padding: 0;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
}

.custom-dropdown li {
    padding: 14px 16px;
    cursor: pointer;
    color: var(--text-main);
    font-size: 15px;
    border-bottom: 1px solid var(--border-color);
    transition: all 0.2s ease;
}

.custom-dropdown li:last-child {
    border-bottom: none;
}

.custom-dropdown li:hover {
    background-color: var(--accent-red);
    color: white;
    font-weight: 600;
}

/* --- Reportes --- */
.report-section {
    margin-top: 25px;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}

.report-section h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-main);
}

.report-section p {
    color: var(--text-muted);
    margin-bottom: 20px;
    font-size: 15px;
}




/* ==========================================================================
   BOTÓN ENCABEZADO SUPERIOR DERECHO (ESTILO DISQUETE)
   ========================================================================== */
.btn-cache-header {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--input-bg, #2c2c2c);
    border: 1px solid var(--input-border, #444);
    color: var(--accent-blue, #2196F3);
    padding: 8px 12px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    z-index: 100;
    transition: all 0.2s ease;
}

.btn-cache-header:hover {
    background: #383838;
    border-color: var(--accent-blue, #2196F3);
    transform: scale(1.05);
}

.badge-cache {
    background: var(--accent-blue, #2196F3);
    color: #ffffff;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
}

/* ==========================================================================
   MODAL FLOTANTE DE AUDITORÍA DE CACHÉ
   ========================================================================== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
}

.modal-cache-content {
    background: var(--card-bg, #1e1e1e);
    border: 1px solid var(--input-border, #444);
    border-radius: 12px;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.8);
}

.modal-cache-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    border-bottom: 1px solid var(--input-border, #444);
}

.modal-cache-header h3 {
    font-size: 16px;
    color: var(--text-main, #fff);
    margin: 0;
}

.btn-close-modal {
    background: none;
    border: none;
    color: var(--text-muted, #a0a0a0);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
}

.btn-close-modal:hover {
    color: var(--accent-red, #ef4444);
}

/* PESTAÑAS (TABS) */
.cache-tabs {
    display: flex;
    background: #141414;
    border-bottom: 1px solid var(--input-border, #444);
    overflow-x: auto;
}

.cache-tab {
    flex: 1;
    min-width: 90px;
    padding: 10px 8px;
    background: transparent;
    border: none;
    color: var(--text-muted, #a0a0a0);
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.cache-tab.active {
    color: var(--accent-blue, #2196F3);
    border-bottom-color: var(--accent-blue, #2196F3);
    background: rgba(33, 150, 243, 0.08);
}

.cache-body {
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    min-height: 240px;
}

.cache-tab-pane {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* METRICAS */
.cache-metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.metric-card {
    background: var(--input-bg, #2c2c2c);
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #3a3a3a;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.metric-card small {
    font-size: 10px;
    color: var(--text-muted, #a0a0a0);
}

.metric-card strong {
    font-size: 14px;
}

.cache-log-box {
    background: #121212;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 10px;
    max-height: 160px;
    overflow-y: auto;
}

.log-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-family: monospace;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.log-item {
    color: #ccc;
    border-bottom: 1px dashed #222;
    padding-bottom: 4px;
}

.cache-data-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
}

.cache-item-card {
    background: var(--input-bg, #2c2c2c);
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    padding: 10px;
    font-size: 12px;
}

.cache-item-card strong {
    color: #fff;
    display: block;
    margin-bottom: 2px;
}

.cache-item-card small {
    color: #aaa;
    display: block;
}

/* FOOTER / BOTONES DE ACCIÓN */
.cache-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--input-border, #444);
    display: flex;
    gap: 10px;
    background: #181818;
}

.btn-action-resync,
.btn-action-wipe {
    flex: 1;
    padding: 10px;
    border-radius: 6px;
    border: none;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.btn-action-resync {
    background: var(--accent-blue, #2196F3);
    color: white;
}

.btn-action-wipe {
    background: transparent;
    border: 1px solid var(--accent-red, #ef4444);
    color: var(--accent-red, #ef4444);
}


/* Animación para que las tarjetas de caché parezcan botones clickeables */
.cache-item-card {
    background: var(--input-bg, #2c2c2c);
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    padding: 10px;
    font-size: 12px;
    cursor: pointer;
    /* <--- Agregamos cursor pointer */
    transition: all 0.2s ease;
}

.cache-item-card:hover {
    background: #383838;
    border-color: var(--accent-blue, #2196F3);
    transform: translateX(4px);
    /* Pequeño salto a la derecha */
}



/* ==========================================================================
   BADGES DE CONTEO TOTAL Y TRAFICO IO (LECTURAS / ESCRITURAS)
   ========================================================================== */
.btn-cache-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.badge-cache {
    background: var(--accent-blue, #2196F3);
    color: #ffffff;
    font-size: 11px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
}

.badge-io {
    font-size: 10px;
    font-weight: bold;
    padding: 2px 5px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.badge-reads {
    background: rgba(33, 150, 243, 0.2);
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, 0.4);
}

.badge-writes {
    background: rgba(74, 222, 128, 0.2);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.4);
}