/* ============================================
   RESET Y ESTILOS BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --light-color: #ecf0f1;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f0f2f5;
    color: #333;
    min-height: 100vh;
    padding-top: 56px;
}

a {
    text-decoration: none;
}

/* ============================================
   TOP NAVBAR - FIJO ARRIBA
   ============================================ */
.top-navbar {
    background: #2c3e50;
    color: white;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: 56px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.top-nav-container {
    max-width: 100%;
    padding: 0 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
}

.top-nav-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.menu-toggle-btn {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 6px;
    border-radius: 4px;
    transition: background 0.2s;
}

.menu-toggle-btn:hover {
    background: rgba(255,255,255,0.1);
}

.menu-toggle-btn span {
    display: block;
    width: 24px;
    height: 2.5px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s;
}

.top-brand {
    display: flex;
    align-items: center;
    color: white;
    text-decoration: none;
    font-size: 18px;
    font-weight: bold;
}

.top-brand .brand-icon {
    font-size: 24px;
    margin-right: 8px;
}

.top-brand .brand-name {
    font-size: 16px;
}

.top-nav-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-name-top {
    font-size: 13px;
    color: rgba(255,255,255,0.85);
}

.user-role-top {
    background: #3498db;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

/* ============================================
   SIDEBAR - MENU LATERAL
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.sidebar-overlay.active {
    display: block;
}

.sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 270px;
    height: 100%;
    background: #ffffff;
    z-index: 1001;
    transition: left 0.3s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar.active {
    left: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #2c3e50;
    color: white;
    flex-shrink: 0;
    min-height: 56px;
}

.sidebar-brand {
    font-size: 18px;
    font-weight: bold;
}

.sidebar-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    transition: color 0.2s;
}

.sidebar-close:hover {
    color: #e74c3c;
}

/* Sidebar Menu */
.sidebar-menu {
    list-style: none;
    padding: 8px 0;
    margin: 0;
    flex: 1;
}

.sidebar-menu li {
    list-style: none;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 11px 20px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-menu a:hover {
    background: #f0f2f5;
    border-left-color: #3498db;
}

.sidebar-menu .menu-icon {
    margin-right: 12px;
    font-size: 18px;
    width: 24px;
    text-align: center;
}

/* Sidebar Dropdown */
.sidebar-dropdown > a {
    cursor: pointer;
}

.sidebar-dropdown .arrow {
    margin-left: auto;
    transition: transform 0.3s;
    font-size: 11px;
    color: #95a5a6;
}

.sidebar-dropdown.open .arrow {
    transform: rotate(90deg);
}

.sidebar-submenu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: #f8f9fa;
}

.sidebar-dropdown.open .sidebar-submenu {
    max-height: 400px;
}

.sidebar-submenu li {
    list-style: none;
}

.sidebar-submenu a {
    padding: 9px 20px 9px 56px;
    font-size: 13px;
    color: #333;
    text-decoration: none;
    transition: background 0.2s;
    border-left: none;
}

.sidebar-submenu a:hover {
    background: #e9ecef;
}

.sidebar-submenu .submenu-title {
    padding: 8px 20px 4px 56px;
    font-size: 10px;
    font-weight: 700;
    color: #7f8c8d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-submenu .submenu-divider {
    height: 1px;
    background: #dee2e6;
    margin: 5px 20px 5px 56px;
}

.sidebar-divider {
    height: 1px;
    background: #dee2e6;
    margin: 8px 20px;
}

.logout-link {
    color: #e74c3c !important;
}

.logout-link:hover {
    background: #fde8e8 !important;
    border-left-color: #e74c3c !important;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px 20px;
    border-top: 1px solid #dee2e6;
    background: #f8f9fa;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #555;
}

.role-badge {
    background: #3498db;
    color: white;
    padding: 2px 12px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
}

.role-badge.admin {
    background: #e74c3c;
}

/* ============================================
   LOGIN
   ============================================ */
.login-page {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding-top: 0;
}

.login-container {
    background: white;
    padding: 40px 50px;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 28px;
    color: var(--primary-color);
}

.login-header p {
    color: #7f8c8d;
    font-size: 14px;
    margin-top: 5px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: #555;
}

.login-form input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
}

.login-form input:focus {
    border-color: var(--secondary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    color: #95a5a6;
    font-size: 12px;
}

/* ============================================
   CONTAINER Y PAGINA
   ============================================ */
.container {
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 20px;
    flex: 1;
    width: 100%;
}

.page-header {
    margin-bottom: 25px;
}

.page-header h1 {
    font-size: 28px;
    color: var(--primary-color);
}

.page-header p {
    color: #7f8c8d;
    font-size: 14px;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
    font-size: 18px;
}

.card-footer {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    text-align: right;
}

/* Dashboard Cards */
.dashboard-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.dashboard-cards .card {
    display: flex;
    align-items: center;
    padding: 25px;
    transition: var(--transition);
}

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

.card-icon {
    font-size: 48px;
    margin-right: 20px;
}

.card-content {
    flex: 1;
}

.card-content h3 {
    font-size: 14px;
    text-transform: uppercase;
    color: #7f8c8d;
    margin-bottom: 5px;
}

.card-number {
    font-size: 32px;
    font-weight: bold;
    color: var(--primary-color);
}

.card-label {
    color: #95a5a6;
    font-size: 13px;
    margin: 3px 0 8px 0;
}

.card-deuda {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 15px;
}

.card-deuda .label {
    font-weight: normal;
}

.card-deuda.deuda-roja {
    background: #fde8e8;
    color: var(--danger-color);
}

.card-deuda.deuda-verde {
    background: #e8f8ed;
    color: var(--success-color);
}

/* ============================================
   TABLAS
   ============================================ */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table thead {
    background: #f8f9fa;
}

.table th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    color: #555;
    border-bottom: 2px solid #dee2e6;
}

.table td {
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
}

.table tbody tr:hover {
    background: #f8f9fa;
}

.table-small th,
.table-small td {
    padding: 8px 12px;
    font-size: 13px;
}

.table .text-right {
    text-align: right;
}

.table .text-center {
    text-align: center;
}

.table-responsive {
    overflow-x: auto;
}

/* ============================================
   BADGES
   ============================================ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

.badge-info {
    background: #d1ecf1;
    color: #0c5460;
}

.badge-warning {
    background: #fff3cd;
    color: #856404;
}

/* ============================================
   FORMULARIOS
   ============================================ */
.form-container {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    max-width: 700px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: #555;
}

.form-group .required {
    color: var(--danger-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--secondary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 60px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   BOTONES
   ============================================ */
.btn {
    display: inline-block;
    padding: 10px 25px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--secondary-color);
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 3px 10px rgba(52, 152, 219, 0.3);
}

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

.btn-success:hover {
    background: #219a52;
}

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

.btn-danger:hover {
    background: #c0392b;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
}

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

.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 15px;
}

/* ============================================
   MENSAJES
   ============================================ */
.error-message {
    background: #f8d7da;
    color: #721c24;
    padding: 12px 15px;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--danger-color);
    margin-bottom: 20px;
}

.success-message {
    background: #d4edda;
    color: #155724;
    padding: 12px 15px;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--success-color);
    margin-bottom: 20px;
}

.warning-message {
    background: #fff3cd;
    color: #856404;
    padding: 12px 15px;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--warning-color);
    margin-bottom: 20px;
}

/* ============================================
   FILTROS
   ============================================ */
.filtros {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.filtros-form {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    width: 100%;
    align-items: center;
}

.filtros-group {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
}

.filtros-buscar {
    display: flex;
    gap: 5px;
    flex: 1;
    min-width: 200px;
}

.filtros-buscar input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 14px;
    min-width: 150px;
}

.filtros-buscar input:focus {
    border-color: var(--secondary-color);
    outline: none;
}

/* ============================================
   DETALLE PERSONA
   ============================================ */
.detalle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

.detalle-saldo {
    font-size: 18px;
}

.detalle-saldo .label {
    color: #7f8c8d;
}

.detalle-saldo .monto {
    font-weight: bold;
    font-size: 22px;
}

.detalle-datos {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 30px;
}

.detalle-item {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}

.detalle-item .label {
    color: #7f8c8d;
    font-size: 13px;
    display: block;
}

.detalle-item .valor {
    font-weight: 500;
    font-size: 15px;
    display: block;
    margin-top: 2px;
}

/* ============================================
   RESUMEN ITEMS
   ============================================ */
.resumen-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.resumen-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: var(--border-radius);
}

.resumen-item .label {
    color: #7f8c8d;
}

.resumen-item .value {
    font-weight: 600;
    font-size: 16px;
}

.color-verde {
    color: var(--success-color);
    font-weight: bold;
}

.color-rojo {
    color: var(--danger-color);
    font-weight: bold;
}

.color-gris {
    color: #95a5a6;
}

/* ============================================
   ROW / COLUMNS
   ============================================ */
.row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.col-6 {
    width: 100%;
}

@media (max-width: 992px) {
    .row {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    background: var(--primary-color);
    color: rgba(255,255,255,0.7);
    text-align: center;
    padding: 15px;
    margin-top: 30px;
    font-size: 13px;
}

/* ============================================
   UTILITIES
   ============================================ */
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.mt-30 { margin-top: 30px; }
.mb-30 { margin-bottom: 30px; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.hidden { display: none; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .container {
        padding: 0 10px;
        margin: 10px auto;
    }
    
    .dashboard-cards {
        grid-template-columns: 1fr;
    }
    
    .login-container {
        padding: 25px;
        margin: 0 15px;
    }
    
    .form-container {
        padding: 20px;
    }
    
    .table {
        font-size: 12px;
    }
    
    .table th,
    .table td {
        padding: 8px 10px;
    }
    
    .user-name-top {
        display: none;
    }
    
    .detalle-datos {
        grid-template-columns: 1fr;
    }
    
    .detalle-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 480px) {
    .top-brand .brand-name {
        font-size: 14px;
    }
    
    .sidebar {
        width: 260px;
        left: -280px;
    }
}