@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary-color: #006f44; /* La Paz Green */
    --secondary-color: #c8102e; /* La Paz Red */
    --accent-color: #fcc000; /* La Paz Yellow */
    --bg-color: #f8f9fa; /* Light background */
    --surface-color: #ffffff; /* White for cards */
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --border-color: #e5e7eb;
    --border-radius: 12px;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(at 0% 0%, rgba(252, 192, 0, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(200, 16, 46, 0.08) 0px, transparent 50%);
    color: var(--text-main);
    min-height: 100vh;
    padding-bottom: 50px;
    margin: 0;
}

/* Navbar Premium */
.navbar {
    background: #fcc000 !important; /* Yellow representing La Paz */
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 1rem 0;
    border-bottom: 4px solid #c8102e; /* Red border */
    border-top: 4px solid #006f44; /* Green top border */
    overflow: visible !important;
}

.navbar-collapse {
    overflow: visible !important;
}

.navbar-nav {
    overflow: visible !important;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.4rem;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 15px;
    margin-right: 3rem !important; /* Forces distance from "Inicio" */
    color: #1a1a1a !important;
}

.navbar-brand img {
    height: 45px !important;
    width: auto !important;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.navbar-nav {
    display: flex;
    align-items: center;
}

.nav-item {
    margin: 0 0.3rem;
    position: relative; /* Fixes dropdown positioning */
}

.navbar-nav .nav-link {
    font-weight: 500;
    padding: 0.6rem 1rem !important;
    border-radius: 8px;
    transition: all 0.2s ease;
    color: #1a1a1a !important; /* Dark text on yellow */
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-nav .nav-link:hover, .navbar-nav .nav-item.active .nav-link {
    background-color: rgba(0, 0, 0, 0.05);
    color: #c8102e !important; /* Red */
    transform: translateY(-1px);
}

.navbar-nav .nav-icon {
    margin-right: 0 !important; /* Reset margin since we use gap */
    opacity: 0.8;
}

/* Fix Dropdown Menu */
.dropdown-menu {
    border: none;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    padding: 0.8rem;
    background: var(--surface-color);
    margin-top: 10px;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 220px;
    z-index: 9999 !important;
}

.dropdown-item {
    border-radius: 6px;
    padding: 0.6rem 1rem;
    font-weight: 500;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.dropdown-item:hover {
    background-color: #f3f4f6;
    color: var(--secondary-color);
    transform: translateX(3px);
}

.dropdown-item .nav-icon {
    color: var(--accent-color);
}

/* Nav Pills para formularios de registro (fondo blanco) */
#registroTabs .nav-link {
    color: #4b5563 !important;
    font-weight: 600;
    padding: 0.75rem 1rem !important;
    border-radius: 8px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.25s ease;
}

#registroTabs .nav-link:hover {
    background-color: rgba(200, 16, 46, 0.08);
    color: #c8102e !important;
    transform: none;
}

#registroTabs .nav-link.active {
    background: linear-gradient(135deg, #006f44, #c8102e) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 12px rgba(200, 16, 46, 0.3);
}

/* Beautiful Centered Forms (Login/Register) */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 160px);
    padding: 2rem 1rem;
}

.auth-card {
    background: var(--surface-color);
    border-radius: 20px;
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 480px;
    padding: 3rem 2.5rem;
    border: 1px solid rgba(255, 255, 255, 0.5);
    position: relative;
    overflow: hidden;
}

/* Top accent line on auth cards */
.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, #c8102e 33%, #fcc000 33%, #fcc000 66%, #006f44 66%);
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo img {
    height: 80px;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1rem;
}

.auth-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

/* Cards used in the system */
.card {
    border: none;
    border-radius: var(--border-radius);
    background: var(--surface-color);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    margin-bottom: 1.5rem;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem;
}

.card-header h2, .card-header h3, .card-header h4, .card-header h5 {
    color: var(--primary-color);
    font-weight: 700;
    margin: 0;
}

.card-body {
    padding: 1.5rem;
}

/* Premium Form Elements */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    display: block;
}

.form-control {
    border: 2px solid var(--border-color);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
    background-color: #f9fafb;
    color: var(--text-main);
    height: auto;
}

.form-control:focus {
    border-color: var(--accent-color);
    background-color: #ffffff;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
    outline: none;
}

/* Premium Buttons */
.btn {
    border-radius: 10px;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px rgba(0, 111, 68, 0.25);
}

.btn-primary:hover, .btn-primary:focus {
    background: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(200, 16, 46, 0.3);
}

.btn-success {
    background: var(--accent-color);
    color: #1f2937;
    box-shadow: 0 4px 6px rgba(252, 192, 0, 0.25);
}

.btn-success:hover {
    background: #e5a900;
    transform: translateY(-1px);
}

/* Tables */
.table-responsive {
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 0 0 1px var(--border-color);
}

.table {
    margin-bottom: 0;
    background: white;
}

.table thead th {
    background-color: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    padding: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.table tbody td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-main);
}

/* Alerts */
.alert {
    border-radius: 10px;
    border: none;
    padding: 1rem 1.25rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-info {
    background-color: #eff6ff;
    color: #1e40af;
}

.alert-danger {
    background-color: #fef2f2;
    color: #991b1b;
}

.alert-success {
    background-color: #ecfdf5;
    color: #065f46;
}

/* Nav Tabs */
.nav-tabs {
    border-bottom: 2px solid var(--border-color);
    gap: 0.5rem;
}

.nav-tabs .nav-link {
    border: none;
    color: var(--text-muted) !important;
    font-weight: 600;
    padding: 1rem 1.5rem !important;
    border-radius: 10px 10px 0 0;
    transition: all 0.2s;
    background: transparent;
}

.nav-tabs .nav-link:hover {
    color: var(--primary-color) !important;
    background-color: #f3f4f6;
}

.nav-tabs .nav-link.active {
    color: var(--accent-color) !important;
    background-color: transparent;
    border-bottom: 3px solid var(--accent-color);
}

/* Custom File Input */
.custom-file-container {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 1.5rem;
    text-align: center;
    background: #f9fafb;
    transition: all 0.2s;
}

.custom-file-container:hover {
    border-color: var(--accent-color);
    background: #eff6ff;
}

/* Remove bubbles if they look cheap, or make them extremely subtle */
.bubbles {
    display: none; /* Hide bubbles to make it look highly professional */
}

/* Misc Utilities */
.text-muted {
    color: var(--text-muted) !important;
}

.auth-links {
    margin-top: 1.5rem;
    text-align: center;
    font-size: 0.95rem;
    color: var(--text-muted);
}

.auth-links a {
    color: var(--accent-color);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s;
}

.auth-links a:hover {
    color: var(--secondary-color);
    text-decoration: underline;
}

@media (max-width: 768px) {
    .auth-card {
        padding: 2rem 1.5rem;
    }
}

/* Evitar truncado de texto en selects largos (Fix #2) */
select.form-control, select.custom-select {
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
}

/* Asegurar que las opciones puedan mostrarse correctamente en móviles */
select.form-control option, select.custom-select option {
    white-space: normal !important;
}

/* Estética: aumentar espacio entre filtros en el formulario de Ingresos Individuales */
#filtrosForm .row {
    gap: 1rem;
}

/* Asegurar buen espaciado y alineación en dispositivos pequeños */
@media (max-width: 767px) {
    #filtrosForm .row {
        gap: 0.5rem;
    }
    #filtrosForm .col-md-3, #filtrosForm .col-md-2 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* Sidebar Premium Layout */
body {
    padding-left: 110px;
    transition: padding-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body:has(.sidebar:hover) {
    padding-left: 290px;
}

@media (max-width: 991px) {
    body {
        padding-left: 0;
        padding-top: 70px;
    }
    body:has(.sidebar:hover) {
        padding-left: 0;
    }
}
.mobile-toggle { display: none; }

.sidebar {
    position: fixed;
    top: 20px;
    left: 20px;
    bottom: 20px;
    width: 70px;
    background: var(--accent-color);
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1), inset 0 0 0 2px rgba(255,255,255,0.2);
    z-index: 1040;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 2px solid var(--primary-color);
}

.sidebar:hover {
    width: 250px;
}

.sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 15px;
    border-bottom: 2px solid var(--secondary-color);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 15px;
    text-decoration: none;
    color: #1a1a1a;
    font-weight: 700;
    font-size: 1.2rem;
    white-space: nowrap;
}

.sidebar-brand:hover {
    text-decoration: none;
    color: #1a1a1a;
}

.sidebar-brand img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}

.sidebar-nav {
    list-style: none;
    padding: 15px 5px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-grow: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.1);
    border-radius: 4px;
}

.nav-item.mt-auto {
    margin-top: auto;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-radius: 12px;
    color: #1a1a1a;
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 600;
    white-space: nowrap;
}

.sidebar .nav-link:hover, .sidebar .nav-link.active {
    background: rgba(200, 16, 46, 0.1);
    color: var(--secondary-color) !important;
}

.sidebar .nav-icon {
    width: 56px; /* 70 width - 2 border = 66, internal padding 5px offset? 56 perfectly centers icon in default width usually */
    font-size: 1.2rem;
    text-align: center;
    flex-shrink: 0;
}

/* Sidebar texts hidden by default, visible on hover */
.sidebar .sidebar-text {
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.sidebar:hover .sidebar-text {
    opacity: 1;
    pointer-events: auto;
    transition-delay: 0.1s;
}

.nav-heading {
    padding: 15px 5px 5px;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 700;
    color: rgba(0,0,0,0.5);
    display: flex;
    white-space: nowrap;
    align-items: center;
}

.nav-heading .sidebar-text {
    flex-grow: 1;
    padding-left: 10px;
}

.nav-icon-collapsed {
    text-align: center;
    width: 56px;
    color: rgba(0,0,0,0.3);
}

.sidebar:hover .nav-icon-collapsed {
    display: none;
}

/* Ocultar los submenús colapsables cuando el sidebar está cerrado (70px) */
.sidebar:not(:hover) .collapse {
    display: none !important;
}

/* Sidebar Mobile */
.mobile-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: #1a1a1a;
    cursor: pointer;
}

@media (max-width: 991px) {
    .sidebar {
        top: 0;
        left: 0;
        right: 0;
        width: 100% !important;
        height: 70px;
        bottom: auto;
        border-radius: 0;
        border: none;
        border-bottom: 4px solid var(--secondary-color);
        border-top: 4px solid var(--primary-color);
        z-index: 1040;
    }
    
    .sidebar-header {
        justify-content: space-between;
        border-bottom: none;
    }

    .mobile-toggle {
        display: block;
    }

    .sidebar-nav {
        display: none;
        background: #fcfcfc;
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 20px;
        border-right: none;
        z-index: 9999;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    body.sidebar-open .sidebar-nav {
        display: flex;
    }

    body.sidebar-open {
        overflow: hidden;
    }

    /* Overlay to close menu on outside tap */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1030;
    }
    body.sidebar-open .sidebar-overlay {
        display: block;
    }

    .sidebar .sidebar-text {
        opacity: 1;
    }

    .sidebar .nav-icon {
        width: 40px;
        text-align: left;
    }
}

/* Dashboard Premium Cards */
.dashboard-card {
    background: #ffffff;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    border: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.dashboard-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 30px rgba(0,0,0,0.1);
}

.dashboard-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 6px;
    height: 100%;
}

.card-yellow::before { background: var(--accent-color); }
.card-green::before { background: var(--primary-color); }
.card-red::before { background: var(--secondary-color); }
.card-dark::before { background: #1f2937; }

.icon-box {
    width: 55px;
    height: 55px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.bg-light-yellow { background: rgba(252, 192, 0, 0.15); color: #b45309; }
.bg-light-green { background: rgba(0, 111, 68, 0.15); color: var(--primary-color); }
.bg-light-red { background: rgba(200, 16, 46, 0.15); color: var(--secondary-color); }
.bg-light-dark { background: rgba(31, 41, 55, 0.15); color: #1f2937; }

/* Responsive Dashboard Aesthetics */
.chart-container {
    height: 350px;
    width: 100%;
    position: relative;
}

.kpi-value {
    font-size: clamp(1.8rem, 2vw + 1rem, 2.5rem);
    line-height: 1.2;
    font-weight: 700;
    color: #111827;
}

/* Dark Glowing Chart Cards */
.dark-chart-card {
    background: #0b1120;
    border-radius: 20px;
    box-shadow: 0 15px 35px rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.05);
    position: relative;
    overflow: hidden;
}
.dark-chart-card h5 { color: #f8fafc !important; }
.dark-chart-card .icon-box { background: rgba(255,255,255,0.05) !important; color: #38bdf8 !important; }

/* Global Responsive Fixes */
.table th, .table td {
    white-space: normal !important;
    word-break: normal;
}
.table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    .chart-container {
        height: 250px;
    }
    .dashboard-card, .dark-chart-card {
        padding: 1.2rem !important;
    }
    .icon-box {
        width: 45px;
        height: 45px;
        font-size: 1.2rem;
    }
    .container-fluid {
        padding-left: 15px !important;
        padding-right: 15px !important;
    }
    
    /* Fix squished form inputs on mobile */
    .input-group {
        flex-wrap: wrap !important;
    }
    .input-group-prepend {
        flex: 0 0 auto;
    }
    .input-group > .form-control {
        flex: 1 1 0%;
        min-width: 0;
        border-top-right-radius: 8px !important;
        border-bottom-right-radius: 8px !important;
    }
    .input-group-append {
        width: 100%;
        margin-top: 8px;
        margin-left: 0 !important;
    }
    .input-group-append .btn,
    .input-group-prepend .btn {
        width: 100%;
        border-radius: 8px !important;
    }
}