/* ==================================================
   DISEÑO PREMIUM - SISTEMA DE ALQUILERES
   ================================================== */

:root {
    /* Paleta de Colores Moderna (Acentos y Neutros) */
    --primary: #6366f1;         /* Indigo */
    --primary-hover: #4f46e5;
    --primary-light: rgba(99, 102, 241, 0.1);
    
    --success: #10b981;         /* Verde esmeralda */
    --success-light: rgba(16, 185, 129, 0.1);
    
    --warning: #f59e0b;         /* Ambar */
    --warning-light: rgba(245, 158, 11, 0.1);
    
    --danger: #ef4444;          /* Rojo coral */
    --danger-light: rgba(239, 68, 68, 0.1);
    
    --info: #06b6d4;            /* Cyan */
    --info-light: rgba(6, 182, 212, 0.1);

    --dark-bg: #0f172a;         /* Fondo azul muy oscuro */
    --dark-card: #1e293b;       /* Gris azulado de tarjetas */
    --dark-border: rgba(255, 255, 255, 0.08);
    --dark-text: #f8fafc;
    --dark-text-muted: #94a3b8;

    /* Light Theme (Por defecto en el panel administrativo para máxima legibilidad) */
    --body-bg: #f8fafc;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --text-color: #0f172a;
    --text-muted: #64748b;
    --sidebar-bg: #0f172a;      /* Sidebar siempre oscuro por elegancia */
    
    /* Estados de Equipos HSL */
    --color-disponible: #10b981;    /* Verde */
    --color-alquilado: #3b82f6;     /* Azul */
    --color-reservado: #06b6d4;     /* Celeste */
    --color-vencido: #ef4444;       /* Rojo */
    --color-mantenimiento: #f59e0b; /* Naranja */
    --color-danado: #991b1b;        /* Rojo oscuro */
    --color-revision: #eab308;      /* Amarillo */
    --color-devuelto: #64748b;      /* Gris */
    --color-debaja: #1e293b;        /* Gris oscuro/negro */
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--body-bg);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

/* --- Layout Estructura --- */
#wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
    min-height: 100vh;
}

#sidebar {
    min-width: 260px;
    max-width: 260px;
    background: var(--sidebar-bg);
    color: #ffffff;
    transition: all 0.3s ease;
    box-shadow: 4px 0 10px rgba(0, 0, 0, 0.15);
    z-index: 999;
}

#sidebar.active {
    margin-left: -260px;
}

#content {
    width: 100%;
    min-height: 100vh;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* --- Sidebar Elementos --- */
.sidebar-header {
    padding: 24px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: #ffffff;
}

.sidebar-brand-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

.sidebar-brand-icon i {
    font-size: 20px;
}

.sidebar-user {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user-avatar {
    width: 42px;
    height: 42px;
    background: var(--primary-light);
    border: 2px solid var(--primary);
    color: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.sidebar-menu {
    padding: 15px 0;
    list-style: none;
    margin: 0;
}

.menu-header {
    padding: 10px 24px 5px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: rgba(255, 255, 255, 0.3);
    font-weight: 700;
}

.sidebar-menu li a {
    padding: 12px 24px;
    display: flex;
    align-items: center;
    gap: 15px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 4px solid transparent;
}

.sidebar-menu li a:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.03);
    border-left-color: var(--primary);
}

.sidebar-menu li.active a {
    color: #ffffff;
    background: rgba(99, 102, 241, 0.1);
    border-left-color: var(--primary);
    font-weight: 600;
}

/* --- Top Navbar --- */
.top-navbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 15px 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.btn-toggle-sidebar {
    background: none;
    border: none;
    font-size: 22px;
    color: var(--text-color);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
}

.global-search-container {
    width: 100%;
    max-width: 400px;
}

.search-input-group {
    position: relative;
}

.search-input-group .form-control {
    padding-left: 40px;
    border-radius: 30px;
    border-color: var(--border-color);
    background-color: #f1f5f9;
    font-size: 14px;
    height: 40px;
    transition: all 0.3s ease;
}

.search-input-group .form-control:focus {
    background-color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.search-input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 15px;
}

/* --- Tarjetas Premium --- */
.card-premium {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 24px;
    overflow: hidden;
}

.card-premium:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    transform: translateY(-2px);
}

.card-premium-header {
    padding: 20px 24px;
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-premium-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: var(--text-color);
}

.card-premium-body {
    padding: 24px;
}

/* --- Tarjetas del Dashboard --- */
.metric-card {
    position: relative;
    padding: 24px;
}

.metric-card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 15px;
}

.metric-card-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 5px;
}

.metric-card-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

/* --- Badges de Estado Customizados --- */
.badge-status {
    padding: 6px 12px;
    border-radius: 50px;
    font-size: 12px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-transform: capitalize;
}

.badge-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

/* Disponible */
.badge-disponible {
    background: #e6f4ea;
    color: var(--color-disponible);
}
.badge-disponible::before { background: var(--color-disponible); }

/* Alquilado */
.badge-alquilado {
    background: #e8f0fe;
    color: var(--color-alquilado);
}
.badge-alquilado::before { background: var(--color-alquilado); }

/* Reservado */
.badge-reservado {
    background: #e0f7fa;
    color: var(--color-reservado);
}
.badge-reservado::before { background: var(--color-reservado); }

/* Vencido */
.badge-vencido {
    background: #fce8e6;
    color: var(--color-vencido);
}
.badge-vencido::before { background: var(--color-vencido); }

/* En mantenimiento */
.badge-mantenimiento {
    background: #fef3c7;
    color: var(--color-mantenimiento);
}
.badge-mantenimiento::before { background: var(--color-mantenimiento); }

/* Dañado */
.badge-danado {
    background: #fee2e2;
    color: var(--color-danado);
}
.badge-danado::before { background: var(--color-danado); }

/* En revisión */
.badge-revision {
    background: #fef9c3;
    color: var(--color-revision);
}
.badge-revision::before { background: var(--color-revision); }

/* Devuelto */
.badge-devuelto {
    background: #f1f5f9;
    color: var(--color-devuelto);
}
.badge-devuelto::before { background: var(--color-devuelto); }

/* Dado de baja */
.badge-debaja {
    background: #cbd5e1;
    color: var(--color-debaja);
}
.badge-debaja::before { background: var(--color-debaja); }

/* --- Tablas Modernas --- */
.table-responsive {
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.table-custom {
    margin-bottom: 0;
}

.table-custom th {
    background-color: #f1f5f9;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.table-custom td {
    padding: 16px 20px;
    vertical-align: middle;
    font-size: 14px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-color);
}

.table-custom tr:last-child td {
    border-bottom: none;
}

.table-custom tr {
    transition: background-color 0.2s ease;
}

.table-custom tr:hover {
    background-color: #f8fafc;
}

/* --- Formularios --- */
.form-label-custom {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 8px;
}

.form-control-custom-admin {
    border-radius: 10px;
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-control-custom-admin:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* --- Timeline de Movimientos --- */
.timeline {
    position: relative;
    padding-left: 30px;
    list-style: none;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 5px;
    bottom: 5px;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 24px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -25px;
    top: 5px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--primary);
    border: 3px solid var(--body-bg);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.timeline-date {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    margin-bottom: 4px;
}

.timeline-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-color);
}

.timeline-desc {
    font-size: 13px;
    color: var(--text-muted);
}

/* --- CSS para Impresión (Actas PDF) --- */
@media print {
    body {
        background-color: #ffffff;
        color: #000000;
        font-size: 12px;
    }
    #sidebar, .top-navbar, .btn, footer, .no-print {
        display: none !important;
    }
    #content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }
    .card-premium {
        border: none !important;
        box-shadow: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    .print-header {
        display: block !important;
        border-bottom: 2px solid #000000;
        padding-bottom: 15px;
        margin-bottom: 20px;
    }
    .print-footer {
        display: block !important;
        position: fixed;
        bottom: 0;
        width: 100%;
        border-top: 1px solid #cccccc;
        padding-top: 10px;
    }
    .signature-area {
        margin-top: 80px !important;
        display: flex !important;
        justify-content: space-between;
    }
    .signature-line {
        border-top: 1px solid #000000;
        width: 200px;
        text-align: center;
        padding-top: 5px;
    }
    .table th {
        background-color: #f1f5f9 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

.print-header, .print-footer {
    display: none;
}

/* --- Clases de Utilidad de Fondos Claros Premium --- */
.bg-primary-light { background-color: var(--primary-light) !important; }
.bg-success-light { background-color: var(--success-light) !important; }
.bg-warning-light { background-color: var(--warning-light) !important; }
.bg-danger-light { background-color: var(--danger-light) !important; }
.bg-info-light { background-color: var(--info-light) !important; }

/* ==================================================
   DISEÑO PREMIUM DE SEGUIMIENTO DE FACTURAS (KPI & TABS)
   ================================================== */
.card-metric {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05), 0 1px 2px -1px rgba(0, 0, 0, 0.05) !important;
    border-radius: 12px !important;
}
.card-metric:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.05) !important;
    border-color: #cbd5e1 !important;
}
.circle-icon {
    transition: transform 0.2s ease;
}
.card-metric:hover .circle-icon {
    transform: scale(1.08);
}

/* Píldoras de Filtro Rápido */
.tab-pill-btn {
    border-radius: 50px;
    font-weight: 500;
    font-size: 13px;
    padding: 8px 18px;
    border: 1px solid #e2e8f0;
    background-color: #ffffff;
    color: #64748b;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}
.tab-pill-btn:hover {
    background-color: #f8fafc;
    color: #0f172a;
    border-color: #cbd5e1;
}
.tab-pill-btn.active {
    background-color: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
    font-weight: 600;
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.08);
}
.badge-tab {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 50px;
    line-height: 1;
}

/* Badges de Estado Modernizados */
.badge-status-modern {
    padding: 4px 10px !important;
    border-radius: 50px; /* Pill shaped like the mockup */
    font-size: 10.5px !important;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 85px !important;
    text-transform: none;
}
.badge-modern-vencida {
    background-color: #fee2e2 !important;
    color: #ef4444 !important;
}
.badge-modern-por-vencer {
    background-color: #fef9c3 !important; /* Soft yellow background */
    color: #a16207 !important; /* Dark yellow/gold text */
}
.badge-modern-pago-parcial {
    background-color: #e0f2fe !important;
    color: #0284c7 !important;
}
.badge-modern-pagada {
    background-color: #e0f2fe !important; /* Celeste / soft blue background for paid */
    color: #0284c7 !important; /* Blue text */
}
.badge-modern-anulada {
    background-color: #f1f5f9 !important;
    color: #475569 !important;
}
.badge-modern-pendiente {
    background-color: #dcfce7 !important; /* Soft green for not yet due */
    color: #15803d !important; /* Green text */
}

/* Colores de Fila según Estado (Mockup) */
.row-state-vencida {
    background-color: #fff5f5 !important; /* Soft red */
}
.row-state-por-vencer {
    background-color: #fffdf0 !important; /* Soft yellow */
}
.row-state-pago-parcial {
    background-color: #f0f9ff !important;
}
.row-state-pagada {
    background-color: #f0f9ff !important; /* Celeste / soft blue for paid */
}
.row-state-pagada td:not([data-label="Acciones"]),
.row-state-pagada td:not([data-label="Acciones"]) a,
.row-state-pagada td:not([data-label="Acciones"]) span,
.row-state-pagada td:not([data-label="Acciones"]) div {
    color: #0284c7 !important;
}
.row-state-pendiente {
    background-color: #f5fdf7 !important; /* Soft green for not yet due */
}
.row-state-anulada {
    background-color: #fafbfc !important;
    opacity: 0.85;
}

/* Colores Personalizados para Saldos */
.text-info-custom {
    color: #0284c7 !important; /* Blue/celeste */
}
.text-warning-custom {
    color: #a16207 !important; /* Gold/yellow */
}
.text-success-custom {
    color: #15803d !important; /* Green */
}

/* Tabla - Rediseño de Marcos y Encabezados */
.table-custom th {
    text-transform: uppercase !important;
    font-weight: 700 !important;
    color: #64748b !important;
    font-size: 10.5px !important;
    background-color: #f8fafc !important;
    border-bottom: 2px solid #e2e8f0 !important;
    padding: 10px 12px !important; /* Compact padding like mockup */
    letter-spacing: 0.5px;
}
.table-custom td {
    border-bottom: 1px solid #f1f5f9 !important;
    padding: 10px 12px !important; /* Compact padding like mockup */
    font-size: 11px !important;
}

/* Typography styles matching high-fidelity mockup */
.invoice-code {
    font-weight: 700;
    color: #2563eb;
    font-size: 11px;
    text-decoration: none;
}
.invoice-code:hover {
    text-decoration: underline;
}
.invoice-ref {
    font-size: 9.5px;
    color: #94a3b8;
    margin-top: 1px;
}
.client-name {
    font-weight: 700;
    color: #1e293b;
    font-size: 11px;
    text-transform: uppercase;
    line-height: 1.2;
}
.client-ruc {
    font-size: 9.5px;
    color: #94a3b8;
    margin-top: 1px;
}
.invoice-date {
    font-size: 11px;
    font-weight: 600;
    color: #1e293b;
}
.days-relative {
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
}
.days-state-label {
    font-size: 9.5px;
    color: #94a3b8;
    font-weight: 500;
}
.amount-total {
    font-size: 11px;
    font-weight: 700;
    color: #0f172a;
}
.amount-paid {
    font-size: 11px;
    font-weight: 600;
    color: #16a34a;
}
.amount-balance {
    font-size: 11px;
    font-weight: 700;
}
.status-text {
    font-size: 11px;
    font-weight: 500;
}
.abono-date {
    font-weight: 600;
    color: #1e293b;
    font-size: 11px;
}
.abono-amount {
    font-size: 9.5px;
    color: #16a34a;
}
.contact-name {
    font-weight: 600;
    color: #1e293b;
    font-size: 11px;
    line-height: 1.2;
}
.contact-phone {
    font-size: 9.5px;
    color: #64748b;
    margin-top: 1px;
}
.action-icon {
    font-size: 14px;
}


/* Pestañas de Filtro Rápido - Badges Circulares de Colores Sólidos */
.badge-tab-count {
    width: 18px;
    height: 18px;
    border-radius: 50% !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    font-size: 10px !important;
    font-weight: 700 !important;
    line-height: 1;
    color: #ffffff !important;
    text-shadow: none;
}
.badge-tab-vencidas { background-color: #ef4444 !important; }
.badge-tab-por-vencer { background-color: #f97316 !important; }
.badge-tab-pago-parcial { background-color: #2563eb !important; }
.badge-tab-pagadas { background-color: #16a34a !important; }
.badge-tab-anuladas { background-color: #64748b !important; }

/* Paginación Circular */
.page-link-btn {
    border: 1px solid #e2e8f0 !important;
    color: #64748b !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    transition: all 0.2s ease !important;
}
.page-link-btn:hover {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
    border-color: #cbd5e1 !important;
}
.page-link-btn.active {
    background-color: #eff6ff !important;
    color: #2563eb !important;
    border-color: #bfdbfe !important;
    font-weight: 600 !important;
    box-shadow: none !important;
}

