/*
=========================================================
 ARCHIVO: style.css (VERSIÓN FINAL 100% RESPONSIVA)
 DESCRIPCIÓN: Diseño Flexbox/Grid para Element5
 =========================================================
*/

/* 1. CONFIGURACIÓN BASE Y FUENTES */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;700&display=swap');

:root {
    /* Colores Principales */
    --primary-color: #e94e4e; /* Rojo de Element5 */
    --primary-hover: #c03939;
    --alert-color-rojo: #dc3545;
    --alert-color-amarillo: #ffc107;
    --alert-color-verde: #28a745;
    --alert-color-vino: #442c2c;

    /* Fondos y Texto */
    --background-color: #F4F7FA;
    --card-background: #ffffff;
    --text-color: #333;
    --text-color-light: #555;
    --border-color: #e0e0e0;
   
}

/* RESET OBLIGATORIO PARA RESPONSIVE */
* {
    box-sizing: border-box;
}

html, body {
    overflow-x: hidden; 
    width: 100%;      
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Poppins', 'Inter', sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    padding-bottom: 40px;
}

a {
    text-decoration: none;
    color: inherit;
}

/* 2. LOGIN */
#page-login {
    background: linear-gradient(135deg, #f0f2f5, #e6e9ed);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.login-container {
    width: 100%;
    display: flex;
    justify-content: center;
}

.login-form {
    background: var(--card-background);
    padding: 2.5rem 3rem;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    text-align: center;
    border-top: 5px solid var(--primary-color);
}

.login-logo {
    width: 80px;
    margin-bottom: 1rem;
}

.login-form h2 {
    color: var(--text-color);
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.input-group {
    text-align: left;
    margin-bottom: 1.25rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-color-light);
}

.input-group input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    transition: border-color 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(233, 78, 78, 0.2);
}

.login-button {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    background-color: var(--primary-color);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.2s;
}

.login-button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

.login-error {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--alert-color-rojo);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

/* 3. ENCABEZADO (HEADER) */
header.main-header {
    background-color: var(--card-background);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    border-bottom: 2px solid var(--primary-color);
    flex-wrap: wrap; 
}

.header-left,
.header-center,
.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-left { flex: 1; }
.header-center { flex: 2; justify-content: center; }
.header-right { flex: 1; justify-content: flex-end; }

#logo {
    width: 40px;
    height: auto;
}

.back-button {
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
    color: var(--text-color-light);
}
.back-button:hover {
    background-color: #f0f0f0;
    color: var(--text-color);
}

.header-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
    margin: 0;
    text-align: center;
}

.user-name {
    font-weight: 600;
    color: var(--text-color-light);
    font-size: 0.9rem;
}

.logout-button {
    background-color: #f1f1f1;
    color: var(--text-color-light);
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: background-color 0.2s, color 0.2s;
}
.logout-button:hover {
    background-color: var(--primary-color);
    color: white;
}

/* Títulos */
.page-title {
    font-size: 2rem;
    font-weight: 700;
    color: #333;
    text-align: center;
    margin: 30px 0 20px 0;
    letter-spacing: 1px;
    text-transform: uppercase;
}

/* 4. BUSCADOR */
.search-wrapper {
    position: relative;
    width: 100%;
    max-width: 350px;
}

.search-input {
    padding: 12px 20px;
    border: 1px solid var(--border-color);
    border-radius: 50px;
    width: 100%;
    outline: none;
    font-size: 1rem;
    font-family: 'Poppins', sans-serif;
    background-color: #f9f9f9;
    transition: all 0.3s;
}
.search-input:focus {
    background-color: #ffffff;
    border: 1px solid var(--primary-color);
    box-shadow: 0 0 0 3px rgba(233, 78, 78, 0.2);
}

#suggestionsList {
    list-style: none;
    padding: 0;
    margin-top: 8px;
    position: absolute;
    width: 100%;
    max-height: 250px;
    overflow-y: auto;
    background-color: var(--card-background);
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    z-index: 99;
    display: none;
}

#suggestionsList li {
    padding: 12px 20px;
    cursor: pointer;
    font-size: 1rem;
    border-bottom: 1px solid #eee;
}
#suggestionsList li:hover {
    background-color: var(--primary-color);
    color: white;
}

/* 5. CONTENEDORES Y GRID */
.container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
}

.menu-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 30px;
    width: 100%;
}

/* Tarjetas */
.tank-card {
    background-color: var(--card-background) !important;
    border-radius: 12px;
    overflow: hidden;
    border: 4px solid transparent; 
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.tank-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.12);
}

.tank-card.status-online { border-color: var(--alert-color-verde); }
.tank-card.status-alerta { border-color: var(--alert-color-amarillo); }
.tank-card.status-offline { border-color: var(--alert-color-rojo); }

.estado-card {
    border-color: transparent !important;
    box-shadow:  0 8px 16px rgba(84, 47, 47, 0.405);
}

.card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-bottom: 2px solid var(--primary-color);
}

.card-info {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    text-transform: uppercase;
}

.card-status {
    font-size: 0.8rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
    color: #fff;
}
.status-online { background-color: var(--alert-color-verde); }
.status-offline { background-color: var(--alert-color-rojo); }
.status-alerta { background-color: var(--alert-color-amarillo); color: #333; }

/* 6. MONITOREO - OVERVIEW (GRÁFICAS CIRCULARES) */
.tank-overview-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin: 40px auto;
    max-width: 1100px;
    padding: 0 20px;
}

/* Tarjeta Principal Medidor */
.tank-gauge-card {
    background-color: var(--card-background);
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.08);
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    min-height: auto; /* Altura flexible */
}

.tank-gauge-card h2 {
    font-size: 1.4rem;
    margin: 0 0 15px 0;
    color: var(--primary-color);
    font-weight: 700;
}

.tank-gauge-card .chart-container {
    position: relative;
    width: 100%;
    max-width: 240px;
    aspect-ratio: 1 / 1;
    margin: 10px 0;
}
.tank-gauge-card .chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Litros Totales (Arreglado: Ya no se encima) */
.gauge-liters {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-color);
    margin-top: 10px;
    display: block;
}

/* 7. MONITOREO - DETALLE */
.tanque-detalle-wrapper {
    width: 100%;
    margin-bottom: 40px;
}

/* HEADER DEL DETALLE (Nuevo: Flexbox para título y botón) */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    border-bottom: 2px dashed #ddd;
    padding-bottom: 15px;
    margin-bottom: 25px;
    gap: 15px;
}

.detail-header .section-title {
    margin: 0;
    padding: 0;
    text-align: left;
    font-size: 1.6rem;
    color: #333;
    flex-grow: 1;
}

/* Botón Borrar Profesional */
.delete-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 20px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s, transform 0.1s;
    box-shadow: 0 4px 6px rgba(233, 78, 78, 0.2);
}
.delete-button:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
}

/* Bloques de Datos (Arreglado: Grid inteligente) */
.data-blocks {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.block {
    background-color: var(--primary-color);
    padding: 20px 15px;
    border-radius: 12px;
    color: white;
    text-align: center;
    box-shadow: 0 4px 10px rgba(233, 78, 78, 0.2);
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 110px;
}

.block .value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 5px;
    word-break: break-word;
}
.block .label {
    font-size: 0.85rem;
    opacity: 0.9;
    text-transform: uppercase;
}

/* Contenedor Gráficas Detalle */
.content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 25px;
}

.card {
    background-color: var(--card-background);
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-direction: column;
    min-height: 400px;
}

.card h2 {
    text-align: center;
    font-size: 1.2rem;
    margin-bottom: 20px;
    color: #555;
}

/* Wrappers internos para Canvas */
.tank-gauge-container, 
.chart-wrapper {
    position: relative;
    flex-grow: 1;
    width: 100%;
    min-height: 250px;
}

.tank-gauge-container {
    max-width: 180px; 
    margin: 0 auto;
    border: 1px solid #eee;
    border-radius: 8px;
}

.tank-gauge-container canvas,
.chart-wrapper canvas {
    position: absolute;
    top: 0; left: 0;
    width: 100% !important;
    height: 100% !important;
}

/* 8. LOADER */
#pageLoader {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: #ffffff;
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease-out, visibility 0.5s;
}
#pageLoader.fade-out {
    opacity: 0;
    visibility: hidden;
}
#pageLoader img {
    width: 120px;
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}


/* =========================================================
   9. MEDIA QUERIES (MÓVIL Y TABLET)
   ========================================================= */

/* Móviles (hasta 600px) */
@media (max-width: 600px) {
    body { padding-bottom: 20px; }

    header.main-header {
        padding: 10px 15px;
        justify-content: center;
    }
    .header-left, .header-right {
        width: 100%;
        justify-content: center;
        margin-bottom: 10px;
    }
    .header-center { width: 100%; order: 3; }
    .user-name { display: none; }

    .page-title { font-size: 1.6rem; margin: 20px 0; }

    /* Header Detalle en Columna */
    .detail-header {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    .detail-header .section-title {
        text-align: center;
        font-size: 1.4rem;
    }
    .delete-button {
        width: 100%;
        justify-content: center;
    }

    /* Overview */
    .tank-overview-container { grid-template-columns: 1fr; padding: 0 15px; }
    
    /* Bloques Datos */
    .data-blocks { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .block { padding: 15px 5px; }
    .block .value { font-size: 1.4rem; }

    /* Detalle */
    .content-grid { grid-template-columns: 1fr; }
    .card { padding: 15px; min-height: 350px; }
}

/* Tablets (601px - 1024px) */
@media (min-width: 601px) and (max-width: 1024px) {
    .header-center { flex: 2; }
    .data-blocks { grid-template-columns: repeat(2, 1fr); }
    .tank-overview-container { grid-template-columns: repeat(2, 1fr); }
}