/* =====================================================
   VARIABLES Y BASE
===================================================== */
:root {
    --vm-bg: #1d222e;
    --vm-text-main: #f9fafb;
    --vm-text-muted: #9ca3af;
    --vm-primary: #3068c2;
    --vm-success: #229c4f;
    --vm-danger: #ef4444;
    --vm-warning: #facc15;
    --vm-normal: gray;
}

/* RESET Y COMPORTAMIENTO GLOBAL */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: manipulation;
}

body {
    background: radial-gradient(circle at top, #101320 0, var(--vm-bg) 52%);
    color: var(--vm-text-main);
    font-family: system-ui, sans-serif;
}

h3 {
    margin: 0px;
}

/* =====================================================
   LOGIN
===================================================== */

/* CONTENEDOR PAGINA LOGIN */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

/* TARJETA LOGIN */
.login-card {
    width: 100%;
    max-width: 420px;
    padding: 24px 22px 20px;
    border-radius: 18px;
    background: radial-gradient(circle at top, #050816 0, #020617 55%);
    box-shadow:
        0 24px 60px rgba(0, 0, 0, 0.9),
        0 0 0 1px rgba(148, 163, 184, 0.28);
    border: 1px solid rgba(51, 65, 85, 0.9);
}

/* HEADER LOGIN */
.login-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 22px;
}

/* LOGO CIRCULAR */
.login-logo-circle {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--vm-primary), #4b8bff);
    color: #fff;
    font-weight: 600;
    font-size: 1.2rem;
    box-shadow: 0 0 20px rgba(48, 104, 194, 0.8);
}

/* TITULOS LOGIN */
.login-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--vm-text-main);
}

.login-subtitle {
    margin: 0;
    font-size: 0.9rem;
    color: var(--vm-text-muted);
}

/* FORMULARIO LOGIN */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* CAMPOS */
.login-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.login-label {
    font-size: 0.85rem;
    color: var(--vm-text-muted);
}

.login-input {
    padding: 9px 10px;
    border-radius: 0.55rem;
    border: 1px solid #374151;
    background: #020617;
    color: var(--vm-text-main);
    font-size: 0.95rem;
    outline: none;
    transition: border-color .15s, box-shadow .15s, background-color .15s;
}

.login-input::placeholder {
    color: #6b7280;
}

.login-input:focus {
    border-color: var(--vm-primary);
    box-shadow: 0 0 0 1px rgba(48, 104, 194, 0.6);
    background: #02081f;
}

/* ACCIONES LOGIN */
.login-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-top: 4px;
}

.login-remember {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--vm-text-muted);
}

.login-link {
    font-size: 0.8rem;
    color: var(--vm-primary);
    text-decoration: none;
}

.login-link:hover {
    text-decoration: underline;
}

/* BOTON LOGIN */
.login-submit {
    width: 100%;
    margin-top: 6px;
    padding-block: 8px;
    font-size: 1rem;
}

/* FOOTER LOGIN */
.login-footer {
    margin-top: 14px;
    text-align: center;
}

.login-footer-text {
    margin: 0;
    font-size: 0.75rem;
    color: var(--vm-text-muted);
    opacity: 0.9;
}


/* =====================================================
   LOGOUT
===================================================== */

/* PAGINA LOGOUT */
.logout-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--vm-bg);
}

/* CONTENEDOR LOGOUT */
.logout-container {
    width: 100%;
    padding: 1rem;
    display: flex;
    justify-content: center;
}

/* TARJETA LOGOUT */
.logout-card {
    max-width: 420px;
    width: 100%;
    padding: 2rem;
    border-radius: 12px;
    background: #020617;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    text-align: center;
}

/* TEXTO LOGOUT */
.logout-title {
    margin-bottom: 0.5rem;
}

.logout-text {
    margin-bottom: 1.5rem;
    opacity: 0.85;
}

.logout-card .btn {
    margin: 0 auto;
}


/* =====================================================
   LOADING
===================================================== */

/* PAGINA LOADING */
.loading-box {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--vm-bg, #0f172a);
    z-index: 9999;
}

.loading-box {
    transition: opacity 0.25s ease;
}

.loading-box[hidden] {
    opacity: 0;
    pointer-events: none;
}


.loading-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--vm-bg);
}

/* TEXTO LOADING */
.loading-text {
    font-size: 2rem;
    color: var(--vm-text-main);
    letter-spacing: 0.5px;
}

.loading-text {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0% {
        opacity: .4;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: .4;
    }
}


/* =====================================================
   LAYOUT PRINCIPAL
===================================================== */

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

.vm-page {
    height: 100vh;
    width: 100%;
    display: flex;
}

/* COLUMNA IZQUIERDA */
.tanks-list {
    width: 17%;
    height: 100%;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* LISTADO ESTANQUES */
.tanks-list-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* FOOTER LISTA */
.tanks-list-footer {
    margin-top: auto;
    padding-top: 8px;
    padding-left: 7px;
    padding-right: 7px;
    display: flex;
    flex-direction: column;
}

/* COLUMNA DERECHA */
.monitor-view {
    width: 83%;
    height: 100%;
    padding: 10px;
    display: flex;
    flex-direction: column;
}


/* =====================================================
   HEADER
===================================================== */
.vm-header {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

.vm-header-title {
    margin: 0;
    font-size: 2rem;
    font-weight: 500;
    text-align: center;
}

.vm-header-meta {
    position: absolute;
    right: 0;
    font-size: 1.2rem;
    color: var(--vm-text-muted);
}


/* =====================================================
   BOTONES
===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 6px;
    border-radius: 0.55rem;
    border: 1px solid var(--vm-normal);
    background: #0002;
    color: var(--vm-text-main);
    font-size: 1.2rem;
    cursor: pointer;
    text-decoration: none;
    text-shadow: 0 0 3px black;
    transition: transform .15s, box-shadow .15s, filter .15s, background-color .15s, border-color .15s;
}

.btn:hover {
    transform: scale(1.04);
    filter: brightness(1.05);
}

.btn:active {
    transform: scale(0.96);
    box-shadow: 0 0 4px rgba(255, 255, 255, 0.28);
    filter: brightness(0.95);
}

/* VARIANTES */
.btn-primary {
    background: var(--vm-primary);
    border-color: var(--vm-primary);
}

.btn-success {
    background: var(--vm-success);
    border-color: var(--vm-success);
}

.btn-danger {
    background: var(--vm-danger);
    border-color: var(--vm-danger);
}

.btn-normal {
    background: var(--vm-normal);
    border-color: var(--vm-normal);
}

.btn-water {
    background: #5686b2;
    border-color: #5686b2;
}

/* ESTADO ACTIVO */
.btn-active {
    transform: scale(1.05);
}

.btn-success.btn-active {
    background: #29c75a;
    border-color: #29c75a;
}

.btn-danger.btn-active {
    background: #ff5b5b;
    border-color: #ff5b5b;
}

.btn-normal.btn-active {
    background: #bfbfbf;
    border-color: #bfbfbf;
}

.btn-primary.btn-active {
    background: #4a90ff;
    border-color: #4a90ff;
}


/* =====================================================
   SCADA SVG
===================================================== */
#miniScada {
    width: 100%;
    height: 93%;
    margin-top: 10px;
    background: #ffffff0a;
    border-radius: 10px;
    box-shadow: 0 0 2px rgba(255, 255, 255, 0.18);
}

/* =====================================================
   HISTORICOS LAYOUT
===================================================== */
.historicos-header {
    flex-shrink: 0;
}

.historicos-filters {
    display: flex;
    gap: 8px;
}

.historicos-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 10px;
}


/* =====================================================
   CARDS
===================================================== */
.card {
    background: #ffffff0a;
    border-radius: 10px;
    padding: 14px;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}


/* =====================================================
   TABLA HISTORICA
===================================================== */
.table-wrapper {
    border-radius: 8px;
    overflow: visible;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.table thead th {
    position: sticky;
    top: 0;
    background: #111827;
    z-index: 1;
    text-align: left;
    padding: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.table tbody td {
    padding: 6px 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    white-space: nowrap;
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}


/* =====================================================
   PAGINACION
===================================================== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 10px;
}

.pagination button {
    font-size: 1rem;
    width: 40px;
    height: 40px;
}

/* =====================================================
   BADGES
===================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-green {
    background: rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.badge-red {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.badge-yellow {
    background: rgba(234, 179, 8, 0.2);
    color: #eab308;
}

.badge-gray {
    background: rgba(156, 163, 175, 0.2);
    color: #9ca3af;
}


/* =====================================================
   TREND ICONS
===================================================== */
.trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.trend-up {
    color: #22c55e;
    font-weight: 700;
}

.trend-down {
    color: #eab308;
    font-weight: 700;
}

.trend-equal {
    color: #3b82f6;
    font-weight: 700;
    margin-left: -5px;
}


/* =====================================================
   REGISTROS
===================================================== */
.records-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}

.records-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}


/* =====================================================
   FILTROS FECHA
===================================================== */
.records-filters {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.records-filters button {
    margin-bottom: 10px;
}

.date-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
}

.date-group label {
    font-size: 1rem;
    color: var(--vm-text-muted);
}

.date-group input {
    background: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #e5e7eb;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 1.1rem;
}


/* =====================================================
   RESPONSIVE MOBILE
===================================================== */
@media (max-width: 768px) {

    /* SCROLL NATURAL */
    html,
    body {
        height: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    body {
        min-height: 100vh;
    }

    /* LAYOUT EN COLUMNA */
    .vm-page {
        display: flex;
        flex-direction: column;
        width: 100%;
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    /* SECCIONES PRINCIPALES */
    .tanks-list,
    .monitor-view,
    .historicos-content {
        width: 100%;
        height: auto;
        max-width: 100%;
        overflow: visible;
    }

    /* ORDEN VISUAL */
    .tanks-list {
        order: 1;
    }

    .monitor-view,
    .historicos-content {
        order: 2;
    }

    /* HEADER COMPACTO */
    .vm-header {
        flex-direction: column;
        gap: 6px;
        padding: 12px 14px;
    }

    .vm-header-title {
        font-size: 1.4rem;
        line-height: 1.3;
    }

    .vm-header-meta {
        position: static;
        font-size: 1.2rem;
        color: var(--vm-text-muted);
    }

    /* LISTADO ESTANQUES */
    .tanks-list-body {
        padding: 10px 14px;
        gap: 8px;
    }

    .tank-item {
        display: grid;
        grid-template-columns: 1fr 90px;
        gap: 4px;
    }

    .tank-item .tank-main {
        width: 100%;
        justify-content: flex-start;
        padding-inline: 10px;
        font-size: 1rem;
    }

    .tank-item .tank-water {
        width: 42px;
        min-width: 42px;
        padding-inline: 0;
        font-size: 1rem;
    }

    /* BOTONES FULL WIDTH */
    .btn {
        width: 100%;
        height: 40px;
        font-size: 1.3rem;
    }

    /* CARDS */
    .card {
        padding: 12px;
        border-radius: 12px;
        margin-left: 22px;
        margin-right: 22px;
    }

    /* FILTROS */
    .records-filters {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .date-group {
        width: 100%;
    }

    .date-group input,
    .date-group label {
        width: 100%;
        font-size: 1.2rem;
    }

    /* ACCIONES */
    .records-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .records-actions {
        flex-direction: column;
        gap: 6px;
    }

    .records-actions .btn {
        width: 100%;
    }

    /* TABLA */
    .table-wrapper {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        min-width: 900px;
        font-size: 1.2rem;
    }

    /* PAGINACION */
    .pagination {
        width: 100%;
    }

    .pagination .btn {
        width: 44px;
        height: 40px;
        padding: 0;
        justify-self: center;
    }

    #page-info {
        text-align: center;
        font-size: 1.2rem;
        white-space: nowrap;
        min-width: 150px;
        text-align: center;
    }

    /* GRAFICO */
    #tankChart {
        width: 100% !important;
        height: auto !important;
    }

    .badge {
        font-size: 1rem;
    }

    .monitor-view {
        text-align: center;
    }

    #miniScada {
        margin-top: 1px;
        width: 94%;
    }
}


[hidden] {
    display: none !important;
}


