/* --- SISTEMA DE DISEÑO PREMIUM - FAQUA --- */

:root {
    /* Fondos */
    --bg-primary: #090d16;
    --bg-secondary: #111827;
    --bg-card: rgba(21, 29, 43, 0.7);
    --bg-input: #1f2937;
    
    /* Acentos - Temática Agua/Acueducto */
    --accent-primary: #0284c7;    /* Azul Agua */
    --accent-secondary: #0d9488;  /* Turquesa */
    --accent-cyan: #06b6d4;       /* Cian Brillante */
    --accent-gradient: linear-gradient(135deg, #0284c7 0%, #0d9488 100%);
    --accent-gradient-glow: linear-gradient(135deg, rgba(2, 132, 199, 0.4) 0%, rgba(13, 148, 136, 0.4) 100%);
    
    /* Estados */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    /* Textos */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #4b5563;
    
    /* Bordes y Sombras */
    --border-color: rgba(255, 255, 255, 0.08);
    --card-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --glow-shadow: 0 0 20px rgba(2, 132, 199, 0.2);
    
    /* Tipografía */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
}

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

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    line-height: 1.6;
    overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

a {
    color: var(--accent-cyan);
    text-decoration: none;
    transition: all 0.2s ease;
}

a:hover {
    color: var(--text-primary);
    text-shadow: 0 0 8px rgba(6, 182, 212, 0.5);
}

/* --- SCROLLBAR --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
    background: var(--bg-input);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--accent-secondary);
}

/* --- DISEÑO DE CONTENEDORES --- */
.page-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 280px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    z-index: 100;
    flex-shrink: 0;
    overflow-y: auto;
}

.main-content {
    flex-grow: 1;
    padding: 2rem 2.5rem;
    overflow-y: auto;
    height: 100%;
    position: relative;
    z-index: 105;
    background: radial-gradient(circle at top right, rgba(13, 148, 136, 0.05), transparent 600px);
}

.mobile-nav-toggle {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    padding: 0.5rem;
    margin-right: 1rem;
    cursor: pointer;
}

/* --- LOGO Y MARCA --- */
.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
    padding-left: 0.5rem;
}

.brand-icon {
    font-size: 1.75rem;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    filter: drop-shadow(0 2px 8px rgba(2, 132, 199, 0.4));
}

.brand-name {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 800;
    background: linear-gradient(120deg, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* --- MENÚ DE NAVEGACIÓN --- */
.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

.nav-item-link {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-item-link i {
    font-size: 1.15rem;
    width: 20px;
    text-align: center;
}

.nav-item-link:hover, .nav-item-link.active {
    background: rgba(2, 132, 199, 0.1);
    color: var(--text-primary);
    border-left: 3px solid var(--accent-primary);
}

.nav-item-link.active {
    background: var(--accent-gradient);
    border-left: none;
    box-shadow: 0 4px 15px -3px rgba(2, 132, 199, 0.4);
}

/* --- TARJETAS PREMIUM (GLASSMORPHISM) --- */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: var(--card-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--card-shadow), 0 10px 20px -5px rgba(2, 132, 199, 0.1);
    border-color: rgba(2, 132, 199, 0.25);
}

/* Tarjeta de métrica con barra de carga o efecto */
.metric-card {
    position: relative;
    overflow: hidden;
}

.metric-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--accent-gradient);
}

.metric-card.danger::after { background: var(--danger); }
.metric-card.success::after { background: var(--success); }
.metric-card.warning::after { background: var(--warning); }

.metric-value {
    font-size: 2.25rem;
    font-weight: 700;
    font-family: var(--font-heading);
    margin: 0.5rem 0;
    background: linear-gradient(120deg, #ffffff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.metric-label {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- BOTONES PREMIUM --- */
.btn-premium {
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-family: var(--font-heading);
    box-shadow: 0 4px 14px 0 rgba(2, 132, 199, 0.4);
    transition: all 0.3s ease;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-premium:hover {
    box-shadow: 0 6px 20px 0 rgba(2, 132, 199, 0.6);
    transform: translateY(-2px);
    color: #fff;
}

.btn-premium:active {
    transform: translateY(1px);
}

.btn-secondary-premium {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-family: var(--font-heading);
    transition: all 0.3s ease;
}

.btn-secondary-premium:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--text-secondary);
}

/* --- TABLAS ESTILIZADAS --- */
.table-responsive-premium {
    overflow-x: auto;
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.table-premium {
    width: 100%;
    border-collapse: collapse;
    background: rgba(17, 24, 39, 0.4);
    text-align: left;
}

.table-premium th {
    background: rgba(21, 29, 43, 0.8);
    padding: 1rem 1.25rem;
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color);
}

.table-premium td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    color: var(--text-primary);
    vertical-align: middle;
}

.table-premium tr:hover td {
    background: rgba(2, 132, 199, 0.04);
}

/* --- BADGES/PASTILLAS DE ESTADO --- */
.badge-premium {
    padding: 0.35em 0.75em;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.badge-success {
    background-color: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.badge-warning {
    background-color: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badge-danger {
    background-color: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.badge-info {
    background-color: rgba(59, 130, 246, 0.15);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

/* --- FORMULARIOS --- */
.form-group-premium {
    margin-bottom: 1.25rem;
}

.label-premium {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85rem;
}

.input-premium {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: all 0.3s ease;
}

.input-premium:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: var(--glow-shadow);
}

/* --- FEED EN TIEMPO REAL --- */
.feed-container {
    max-height: 380px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding-right: 0.5rem;
}

.feed-item {
    padding: 0.9rem 1.1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border-left: 3px solid var(--accent-secondary);
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
    animation: fadeInUp 0.4s ease-out;
}

.feed-item.lectura { border-left-color: var(--accent-primary); }
.feed-item.pago { border-left-color: var(--success); }
.feed-item.cliente { border-left-color: var(--info); }
.feed-item.alerta { border-left-color: var(--warning); }

.feed-icon {
    font-size: 1.1rem;
    padding-top: 0.1rem;
}
.feed-item.lectura .feed-icon { color: var(--accent-primary); }
.feed-item.pago .feed-icon { color: var(--success); }
.feed-item.cliente .feed-icon { color: var(--info); }
.feed-item.alerta .feed-icon { color: var(--warning); }

.feed-content {
    flex-grow: 1;
}

.feed-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 0.15rem;
}

.feed-desc {
    font-size: 0.825rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.feed-time {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    align-self: center;
}

/* --- GRÁFICOS --- */
.chart-container {
    height: 300px;
    position: relative;
}

/* --- RECIBO DE FACTURA (ESTILO AGUA FISICA PREMIUM) --- */
.receipt-wrapper {
    background: #ffffff;
    color: #1e293b;
    border-radius: 16px;
    padding: 2.5rem;
    font-family: 'Courier New', Courier, monospace;
    box-shadow: var(--card-shadow);
    max-width: 650px;
    margin: 0 auto;
    position: relative;
    border-top: 8px solid var(--accent-primary);
}

.receipt-header {
    text-align: center;
    border-bottom: 2px dashed #cbd5e1;
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
}

.receipt-logo {
    font-size: 2rem;
    font-weight: 800;
    font-family: var(--font-heading);
    color: var(--accent-primary);
}

.receipt-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.receipt-label {
    font-weight: bold;
    color: #64748b;
}

.receipt-value {
    text-align: right;
    font-weight: bold;
}

.receipt-section-title {
    font-weight: bold;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.25rem;
    margin: 1.5rem 0 0.75rem 0;
    text-transform: uppercase;
    color: var(--accent-primary);
}

.receipt-total {
    border-top: 2px dashed #cbd5e1;
    margin-top: 1.5rem;
    padding-top: 1rem;
    font-size: 1.25rem;
    font-weight: bold;
}

/* --- LOGIN / AUTHENTICATION PAGE (PREMIUM DEGRADADO) --- */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-image: radial-gradient(circle at bottom left, rgba(2, 132, 199, 0.15), transparent 800px),
                      radial-gradient(circle at top right, rgba(13, 148, 136, 0.15), transparent 800px);
    background-color: var(--bg-primary);
    transition: background-color 0.3s ease;
}

.auth-card {
    width: 100%;
    max-width: 450px;
    background: var(--bg-card);
    backdrop-filter: blur(15px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: var(--card-shadow);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* --- ANIMACIONES --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.animated-fade-in {
    animation: fadeInUp 0.4s ease-out forwards;
}

/* --- PERMISOS / USUARIO COMPILACIÓN --- */
.user-pill {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.8rem;
    border-radius: 9999px;
    font-size: 0.85rem;
}

.user-pill i {
    color: var(--accent-cyan);
}

.role-badge {
    background: var(--accent-gradient);
    font-size: 0.7rem;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-weight: 700;
    text-transform: uppercase;
}

/* --- ESTILOS RESPONSIVE PARA MÓVILES --- */
@media (max-width: 1199.98px) {
    .page-container {
        flex-direction: column;
    }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 280px !important;
        z-index: 1045;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        border-right: 1px solid var(--border-color) !important;
        box-shadow: 5px 0 15px rgba(0,0,0,0.5);
    }
    .sidebar.sidebar-open {
        transform: translateX(0);
    }
    .sidebar-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(0,0,0,0.5);
        z-index: 1040;
        display: none;
        backdrop-filter: blur(2px);
    }
    .sidebar-backdrop.sidebar-open {
        display: block;
    }
    .main-content {
        padding: 1.25rem !important;
        max-height: none !important;
    }
    /* Mostrar botón hamburguesa en móviles */
    .mobile-nav-toggle {
        display: block !important;
    }
    
    /* Ocultar elementos de la barra superior que no caben */
    .desktop-only {
        display: none !important;
    }

    /* Barra Superior Pegajosa en Móviles */
    .top-bar-sticky {
        position: sticky;
        top: -1.25rem;
        z-index: 1020;
        background-color: var(--bg-primary);
        padding-top: 1.25rem;
        margin-left: -1.25rem;
        margin-right: -1.25rem;
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    /* Ocultar UI de Errores de Blazor en móviles */
    #blazor-error-ui {
        display: none !important;
    }

    /* Transformar Tablas en Tarjetas en Móviles */
    .table-responsive-cards table, 
    .table-responsive-cards thead, 
    .table-responsive-cards tbody, 
    .table-responsive-cards th, 
    .table-responsive-cards td, 
    .table-responsive-cards tr {
        display: block;
    }
    
    .table-responsive-cards table {
        background: transparent !important;
    }
    
    .table-responsive-cards.table-responsive-premium,
    .table-responsive-cards.table-responsive {
        border: none !important;
        overflow-x: hidden !important;
    }

    .table-responsive-cards thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }
    .table-responsive-cards tr {
        background-color: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: 12px;
        margin-bottom: 1rem;
        padding: 1rem;
        box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    }
    .table-responsive-cards td {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        text-align: left !important;
        padding: 0.75rem 1rem !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        word-break: break-word;
        white-space: normal !important;
    }
    .table-responsive-cards td:last-child {
        border-bottom: none;
    }
    .table-responsive-cards td:before {
        content: attr(data-label);
        font-weight: bold;
        color: var(--text-secondary);
        text-transform: uppercase;
        font-size: 0.75rem;
        margin-bottom: 0.25rem;
    }
    
    /* Mejoras a botones de acciones (íconos con texto) */
    .table-responsive-cards td[data-label="Acciones"] .d-flex,
    .table-responsive-cards td[data-label="Acción"] .d-flex {
        flex-direction: column;
        align-items: stretch !important;
        width: 100%;
        gap: 0.5rem !important;
    }
    .table-responsive-cards td[data-label="Acciones"] button,
    .table-responsive-cards td[data-label="Acción"] button,
    .table-responsive-cards td[data-label="Acciones"] a,
    .table-responsive-cards td[data-label="Acción"] a {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0.75rem !important;
        background: var(--bg-card-hover, rgba(0, 0, 0, 0.3)) !important;
        border-radius: 8px;
        width: 100%;
        text-decoration: none;
    }
    .table-responsive-cards td[data-label="Acciones"] button::after,
    .table-responsive-cards td[data-label="Acción"] button::after,
    .table-responsive-cards td[data-label="Acciones"] a::after,
    .table-responsive-cards td[data-label="Acción"] a::after {
        content: attr(title);
        margin-left: 0.75rem;
        font-family: var(--font-body, 'Outfit', sans-serif);
        font-size: 0.9rem;
    }
}

/* --- ESTILOS DE IMPRESIÓN (PDF) --- */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
    }
    .sidebar, .top-row, .btn, .btn-close, .alert, .receipt-wrapper + button, form, .main-content > div:first-child {
        display: none !important;
    }
    .main-content {
        padding: 0 !important;
        margin: 0 !important;
        background: none !important;
    }
    .receipt-wrapper {
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
    }
}

/* --- MODO CLARO - VARIABLE OVERRIDES & ESTILOS PREMIUM --- */
body.light-theme {
    --bg-primary: #f8fafc;        /* Slate 50 */
    --bg-secondary: #ffffff;      /* Slate 100 */
    --bg-card: rgba(255, 255, 255, 0.8);
    --bg-input: #f1f5f9;          /* Slate 200 */
    
    /* Textos */
    --text-primary: #0f172a;      /* Slate 900 */
    --text-secondary: #475569;    /* Slate 600 */
    --text-muted: #94a3b8;        /* Slate 400 */
    
    /* Bordes y Sombras */
    --border-color: rgba(15, 23, 42, 0.08);
    --card-shadow: 0 10px 30px -10px rgba(15, 23, 42, 0.08);
    --glow-shadow: 0 0 20px rgba(2, 132, 199, 0.08);
}

body.light-theme .brand-name {
    background: linear-gradient(120deg, #0f172a, #475569);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.light-theme .nav-item-link {
    color: #475569;
}

body.light-theme .nav-item-link:hover {
    background: rgba(2, 132, 199, 0.08);
    color: #0284c7;
}

body.light-theme .nav-item-link.active {
    background: var(--accent-gradient);
    color: #ffffff;
}

body.light-theme .glass-card {
    border-color: rgba(15, 23, 42, 0.08);
}

body.light-theme .glass-card:hover {
    border-color: rgba(2, 132, 199, 0.2);
}

body.light-theme .text-white {
    color: #0f172a !important;
}

body.light-theme h1, body.light-theme h2, body.light-theme h3, body.light-theme h4, body.light-theme h5, body.light-theme h6 {
    color: #0f172a !important;
}

body.light-theme .metric-value {
    background: linear-gradient(120deg, #0f172a, #475569);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.light-theme .table-premium {
    background: rgba(255, 255, 255, 0.6);
}

body.light-theme .table-premium th {
    background: #f1f5f9;
    color: #475569;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

body.light-theme .table-premium td {
    color: #0f172a;
    border-bottom: 1px solid rgba(15, 23, 42, 0.04);
}

body.light-theme .table-premium tr:hover td {
    background: rgba(2, 132, 199, 0.04);
}

body.light-theme .input-premium {
    color: #0f172a;
}

body.light-theme .user-pill {
    background: rgba(15, 23, 42, 0.03);
    border-color: rgba(15, 23, 42, 0.06);
}

body.light-theme .user-pill span.text-white {
    color: #0f172a !important;
}

body.light-theme .main-content {
    background: radial-gradient(circle at top right, rgba(13, 148, 136, 0.03), transparent 600px);
}

