/* style.css - Diseño Estético Premium (Glassmorphism & Responsivo) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --panel-bg: rgba(30, 41, 59, 0.7);
    --panel-border: rgba(255, 255, 255, 0.08);
    --primary-color: #f59e0b;
    --primary-hover: #ea580c;
    --accent-success: #10b981;
    --accent-danger: #ef4444;
    --accent-warning: #f59e0b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --font-family: 'Inter', sans-serif;
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    --header-bg: rgba(15, 23, 42, 0.6);
    --input-bg: rgba(15, 23, 42, 0.5);
    --input-text: #fff;
    --input-border: rgba(255, 255, 255, 0.08);
    --metric-card-bg: rgba(15, 23, 42, 0.3);
    --table-header-bg: rgba(15, 23, 42, 0.4);
    --table-text: #fff;
    --logo-glow: rgba(251, 133, 0, 0.4);
}

body.light-theme {
    --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    --panel-bg: rgba(255, 255, 255, 0.65);
    --panel-border: rgba(15, 23, 42, 0.08);
    --primary-color: #ea580c;
    --primary-hover: #c2410c;
    --text-main: #0f172a;
    --text-muted: #475569;
    --card-shadow: 0 8px 32px 0 rgba(148, 163, 184, 0.15);

    --header-bg: rgba(255, 255, 255, 0.7);
    --input-bg: rgba(255, 255, 255, 0.9);
    --input-text: #0f172a;
    --input-border: rgba(15, 23, 42, 0.12);
    --metric-card-bg: rgba(255, 255, 255, 0.5);
    --table-header-bg: rgba(15, 23, 42, 0.05);
    --table-text: #0f172a;
    --logo-glow: rgba(234, 88, 12, 0.25);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-gradient);
    font-family: var(--font-family);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.5;
}

header {
    background: var(--header-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--panel-border);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-img {
    height: 45px;
    object-fit: contain;
}

.app-logo-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-logo-svg {
    width: 60px;
    height: 60px;
    filter: drop-shadow(0 0 10px var(--logo-glow));
}

.header-logo-svg {
    width: 36px;
    height: 36px;
    filter: drop-shadow(0 0 8px var(--logo-glow));
}

.brand-title h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: #fff;
}

.brand-title p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.user-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-info {
    text-align: right;
    font-size: 0.85rem;
}

.user-role {
    color: var(--primary-color);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    gap: 0.5rem;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-color);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid var(--panel-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

main {
    flex: 1;
    padding: 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.glass-card {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 1rem;
    padding: 1.75rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
    transition: var(--transition);
}

/* Dashboard Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

@media(min-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1.1fr 1fr;
    }
}

/* Formularios */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
}

.form-control,
select,
textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    color: var(--input-text);
    font-family: var(--font-family);
    font-size: 0.9rem;
    transition: var(--transition);
    outline: none;
}

.form-control:focus,
select:focus,
textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.2);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media(min-width: 640px) {
    .form-row.two-cols {
        grid-template-columns: 1fr 1fr;
    }

    .form-row.three-cols {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

/* Tabs */
.tabs-container {
    display: flex;
    border-bottom: 1px solid var(--panel-border);
    margin-bottom: 1.5rem;
}

.tab-btn {
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    position: relative;
    transition: var(--transition);
}

.tab-btn:hover {
    color: #fff;
}

.tab-btn.active {
    color: var(--primary-color);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Métricas del Reporte */
.metrics-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.metric-card {
    background: var(--metric-card-bg);
    border: 1px solid var(--panel-border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    text-align: center;
}

.metric-card.status-cumple {
    border-left: 4px solid var(--accent-success);
}

.metric-card.status-no {
    border-left: 4px solid var(--accent-danger);
}

.metric-card h4 {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.metric-val {
    font-size: 1.5rem;
    font-weight: 700;
}

/* Tablas */
.table-responsive {
    overflow-x: auto;
    margin-top: 1.5rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

th,
td {
    padding: 0.75rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--panel-border);
}

th {
    background: var(--table-header-bg);
    color: var(--text-muted);
    font-weight: 600;
}

td {
    color: var(--table-text);
}

.badge {
    display: inline-flex;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-success {
    background: rgba(16, 185, 129, 0.2);
    color: var(--accent-success);
}

.badge-danger {
    background: rgba(239, 68, 68, 0.2);
    color: var(--accent-danger);
}

/* Gráficos Gauges */
.gauges-flex {
    display: flex;
    flex-wrap: nowrap;
    /* siempre en una sola fila */
    justify-content: space-evenly;
    align-items: flex-start;
    gap: 0.75rem;
    margin-top: 1.5rem;
    width: 100%;
}

.gauge-box {
    flex: 1 1 0;
    min-width: 120px;
    max-width: 240px;
    position: relative;
    text-align: center;
}

.gauge-box canvas {
    width: 100% !important;
    display: block;
}

.gauge-title {
    margin-top: 0.35rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Light theme – gauges */
body.light-theme .gauge-box {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 0.75rem;
    padding: 0.75rem 0.5rem 0.5rem;
    box-shadow: 0 3px 16px rgba(0, 0, 0, 0.10);
}

body.light-theme .gauge-title {
    color: #1e293b;
}

/* Light theme – tarjetas de métricas */
body.light-theme .metric-card {
    background: rgba(255, 255, 255, 0.92) !important;
    border: 1px solid rgba(15, 23, 42, 0.10) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.07);
}

body.light-theme .metric-val {
    color: #1e293b !important;
}

body.light-theme .badge-success {
    background: rgba(5, 150, 105, 0.15);
    color: #065f46;
    border: 1px solid rgba(5, 150, 105, 0.3);
}

body.light-theme .badge-danger {
    background: rgba(220, 38, 38, 0.12);
    color: #991b1b;
    border: 1px solid rgba(220, 38, 38, 0.25);
}

body.light-theme .status-cumple {
    background: rgba(5, 150, 105, 0.12) !important;
    color: #065f46 !important;
    border: 1.5px solid rgba(5, 150, 105, 0.3) !important;
}

body.light-theme .status-no {
    background: rgba(220, 38, 38, 0.10) !important;
    color: #991b1b !important;
    border: 1.5px solid rgba(220, 38, 38, 0.25) !important;
}

body.light-theme table th {
    background: rgba(30, 41, 59, 0.80) !important;
    color: #f8fafc !important;
}

body.light-theme table td {
    color: #1e293b !important;
    border-color: rgba(15, 23, 42, 0.10) !important;
}

body.light-theme table tbody tr:nth-child(even) td {
    background: rgba(15, 23, 42, 0.03) !important;
}

/* Login Page */
body:has(.login-container) {
    background-image:
        linear-gradient(135deg, rgba(10, 15, 30, 0.72) 0%, rgba(20, 30, 50, 0.80) 100%),
        url('../css/substation_bg.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

.login-container {
    max-width: 420px;
    width: 100%;
    margin: auto;
    padding: 2.5rem;
    margin-top: 5vh;
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-top: 1rem;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    margin-bottom: 1.25rem;
    border: 1px solid transparent;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.25);
}

/* Historial y Auditoría */
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

/* Estilos de Impresión */
@media print {
    body {
        background: #fff !important;
        color: #000 !important;
        font-size: 11pt !important;
    }

    header,
    .no-print,
    .btn,
    .tabs-container,
    select,
    textarea,
    input[type="submit"],
    button {
        display: none !important;
    }

    main {
        padding: 0 !important;
    }

    .glass-card {
        background: none !important;
        box-shadow: none !important;
        border: none !important;
        padding: 0 !important;
        margin-bottom: 0 !important;
    }

    .dashboard-grid {
        display: block !important;
    }

    .print-only-header {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        border-bottom: 3px solid #004b87;
        padding-bottom: 10px;
        margin-bottom: 20px;
    }

    .print-logo {
        height: 60px;
    }

    .print-title {
        color: #004b87;
        text-align: right;
    }

    .print-title h1 {
        font-size: 18pt;
        margin: 0;
    }

    .print-title p {
        font-size: 9pt;
        color: #555;
    }

    .info-grid-print {
        display: grid !important;
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
        margin-top: 15px !important;
        margin-bottom: 25px !important;
    }

    .info-item-print {
        background: #f4f4f4 !important;
        padding: 8px !important;
        border-radius: 4px !important;
        font-size: 9pt !important;
        color: #333 !important;
        border: 1px solid #ddd !important;
    }

    .status-box-print {
        display: block !important;
        text-align: center;
        padding: 12px;
        font-size: 14pt;
        font-weight: bold;
        border-radius: 6px;
        margin-bottom: 20px;
        border: 1px solid #ccc;
    }

    .status-cumple-print {
        background-color: #d4edda !important;
        color: #155724 !important;
        border-color: #c3e6cb !important;
    }

    .status-nocumple-print {
        background-color: #f8d7da !important;
        color: #721c24 !important;
        border-color: #f5c6cb !important;
    }

    .metrics-container-print {
        display: flex !important;
        justify-content: space-around !important;
        background: #eee !important;
        padding: 10px !important;
        border-radius: 6px !important;
        margin-bottom: 20px !important;
        border: 1px solid #ccc !important;
    }

    th {
        background-color: #004b87 !important;
        color: #fff !important;
        border: 1px solid #ccc !important;
    }

    td {
        color: #000 !important;
        border: 1px solid #ccc !important;
    }

    .badges-print {
        font-weight: bold;
    }

    .gauges-flex {
        page-break-inside: avoid;
        margin-top: 25px !important;
    }

    .gauge-box {
        width: 160px !important;
        height: 150px !important;
        page-break-inside: avoid;
    }
}

/* Cabecera de impresión oculta en web */
.print-only-header {
    display: none;
}