/* ======================================================
   SISTEMA DE ADMINISTRACIÓN DE BALANCES - TEMPLO NAZARETH
   Estilos Mobile-First
   ====================================================== */

/* ============================================ */
/* RESET Y VARIABLES */
/* ============================================ */
:root {
    --primary: #1a5276;
    --primary-light: #2980b9;
    --primary-dark: #0e2f44;
    --secondary: #7f8c8d;
    --success: #27ae60;
    --danger: #e74c3c;
    --warning: #f39c12;
    --info: #3498db;
    
    --bg: #f0f2f5;
    --bg-card: #ffffff;
    --bg-sidebar: #1a1a2e;
    --bg-sidebar-hover: #16213e;
    --bg-topbar: #ffffff;
    
    --text: #2c3e50;
    --text-light: #7f8c8d;
    --text-white: #ffffff;
    --text-sidebar: #a0a0b8;
    
    --border: #e1e5eb;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
    
    --radius: 8px;
    --radius-sm: 4px;
    --radius-lg: 12px;
    
    --sidebar-width: 260px;
    --topbar-height: 60px;
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================ */
/* LOGIN */
/* ============================================ */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    padding: 1rem;
}

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

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    animation: slideUp 0.5s ease;
}

.login-header {
    text-align: center;
    margin-bottom: 1.2rem;
}

.login-icon {
    color: var(--primary);
    margin-bottom: 0.75rem;
}

.login-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    font-size: 0.8rem;
    color: var(--text-light);
    line-height: 1.4;
}

.login-form .form-group {
    margin-bottom: 1.25rem;
}

.form-error {
    background: #fef2f2;
    color: var(--danger);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    border: 1px solid #fecaca;
}

/* ============================================ */
/* FORMULARIOS */
/* ============================================ */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.form-input, .form-select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: var(--font);
    background: var(--bg-card);
    color: var(--text);
    transition: var(--transition);
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
}
#loginForm input{
    padding: 8px 5px;
    border-radius: 5px;
    border: solid 1px #999;
}
.form-input:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary-light);
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.15);
}

.form-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='%237f8c8d'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

/* ============================================ */
/* BOTONES */
/* ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:active {
    transform: scale(0.97);
}

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

.btn-primary:hover {
    background: var(--primary-light);
}

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

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

.btn-whatsapp {
    background: #25D366;
    color: white;
}

.btn-whatsapp:hover {
    background: #1ebe5a;
}

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

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

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

.btn-secondary:hover {
    background: #6c7a7d;
}

.btn-icon {
    padding: 0.5rem;
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    border-radius: var(--radius);
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--bg);
}

.btn-full {
    width: 100%;
}

.btn-logout {
    background: transparent;
    color: var(--text-sidebar);
    padding: 0.5rem;
}

.btn-logout:hover {
    color: var(--danger);
    background: rgba(231, 76, 60, 0.1);
}

.btn-loader svg {
    animation: spin 1s linear infinite;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================ */
/* SIDEBAR */
/* ============================================ */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transform: translateX(-100%);
    transition: var(--transition);
}

.sidebar.active {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sidebar-logo {
    color: var(--primary-light);
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-white);
}

.sidebar-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--text-sidebar);
    cursor: pointer;
    padding: 0.25rem;
    display: none;
}

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

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 0;
}

.nav-section {
    padding: 0.5rem 0;
}

.nav-section-title {
    display: block;
    padding: 0.5rem 1.25rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.3);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.25rem;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 0.9rem;
    transition: var(--transition);
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    font-family: var(--font);
}

.nav-item:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-white);
}

.nav-item.active {
    background: rgba(41, 128, 185, 0.15);
    color: var(--primary-light);
    border-right: 3px solid var(--primary-light);
}

.sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-top: 1px solid rgba(255,255,255,0.05);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-white);
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-sidebar);
    text-transform: capitalize;
}

/* ============================================ */
/* OVERLAY */
/* ============================================ */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================ */
/* MAIN CONTENT */
/* ============================================ */
.main-content {
    margin-left: 0;
    min-height: 100vh;
    transition: var(--transition);
}

/* ============================================ */
/* TOP BAR */
/* ============================================ */
.top-bar {
    position: sticky;
    top: 0;
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 100;
    box-shadow: var(--shadow);
}

.page-title {
    font-size: 1.1rem;
    font-weight: 700;
    flex: 1;
}

.top-bar-actions {
    display: flex;
    gap: 0.25rem;
}

/* ============================================ */
/* CONTENT AREA */
/* ============================================ */
.content-area {
    padding: 1rem;
}

/* Welcome */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 1rem;
    min-height: 60vh;
}

.welcome-icon {
    color: var(--primary-light);
    margin-bottom: 1.5rem;
    opacity: 0.3;
}

.welcome-screen h2 {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.welcome-screen p {
    color: var(--text-light);
    max-width: 400px;
}

/* ============================================ */
/* MODULOS */
/* ============================================ */
.module-container {
    max-width: 1200px;
    margin: 0 auto;
}

.module-header {
    margin-bottom: 1.5rem;
}

.module-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.module-desc {
    color: var(--text-light);
    font-size: 0.9rem;
}

.module-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.date-selector {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.date-selector .form-select,
.date-selector .form-input {
    width: auto;
    min-width: 100px;
}

/* ============================================ */
/* FORM AGREGAR */
/* ============================================ */
.form-agregar {
    background: var(--bg-card);
    border: 2px solid var(--success);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    animation: slideDown 0.3s ease;
}

/* ============================================ */
/* TABLA */
/* ============================================ */
.table-container {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table thead {
    background: var(--primary);
    color: var(--text-white);
}

.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    white-space: nowrap;
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

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

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

.cell-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.btn-edit, .btn-delete {
    background: none;
    border: none;
    padding: 0.4rem;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
}

.btn-edit {
    color: var(--info);
}

.btn-edit:hover {
    background: rgba(52, 152, 219, 0.1);
}

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

.btn-delete:hover {
    background: rgba(231, 76, 60, 0.1);
}

.cell-monto {
    text-align: right;
    font-weight: 600;
    font-family: 'Courier New', monospace;
}

.cell-nombre {
    font-weight: 500;
}

.cell-fecha {
    color: var(--text-light);
    font-size: 0.85rem;
}

/* ============================================ */
/* TOTAL BAR */
/* ============================================ */
.total-bar {
    background: var(--bg-card);
    border: 2px solid var(--primary);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1rem;
    font-size: 1rem;
    box-shadow: var(--shadow);
}

.total-bar strong {
    font-size: 1.25rem;
    color: var(--primary);
}

/* ============================================ */
/* EMPTY STATE */
/* ============================================ */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-light);
}

/* ============================================ */
/* NOTICE */
/* ============================================ */
.notice {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.notice-success {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.notice-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* ============================================ */
/* TOAST */
/* ============================================ */
.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 380px;
    width: calc(100% - 3rem);
}

.toast {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideIn 0.3s ease;
    border-left: 4px solid var(--primary);
    font-size: 0.9rem;
}

.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }

.toast-icon {
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 0.25rem;
}

/* ============================================ */
/* POPUP CONFIRMACIÓN */
/* ============================================ */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
    animation: fadeIn 0.2s ease;
}

.popup-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    max-width: 400px;
    width: 100%;
    text-align: center;
    animation: scaleIn 0.2s ease;
}

.popup-card h3 {
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.popup-card p {
    margin-bottom: 1.5rem;
    color: var(--text-light);
}

.popup-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

/* ============================================ */
/* REPORTES */
/* ============================================ */
.reportes-container {
    max-width: 1200px;
    margin: 0 auto;
}

.reportes-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.reporte-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    overflow-x: auto;
}

.reporte-card h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.reporte-card h3 svg {
    color: var(--primary-light);
}

.reporte-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-end;
}

.reporte-result {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.reporte-result a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--success);
    color: white;
    text-decoration: none;
    border-radius: var(--radius);
    font-weight: 600;
    transition: var(--transition);
}

.reporte-result a:hover {
    background: #219a52;
}

/* Contenedor scroll horizontal para tablas de reportes (responsive móviles) */
.reporte-tabla-scroll {
    max-width: 100%;
    width: 100%;
}

.reporte-tabla-scroll::-webkit-scrollbar {
    height: 6px;
}

.reporte-tabla-scroll::-webkit-scrollbar-track {
    background: var(--border);
    border-radius: 3px;
}

.reporte-tabla-scroll::-webkit-scrollbar-thumb {
    background: var(--text-light);
    border-radius: 3px;
}

/* Tabla resumen reportes */
.tabla-resumen {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.tabla-resumen th {
    background: var(--primary);
    color: white;
    padding: 0.5rem;
    text-align: center;
    font-weight: 600;
}

.tabla-resumen td {
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--border);
    text-align: center;
}

.tabla-resumen tr:nth-child(even) {
    background: #f8f9fa;
}

.tabla-resumen .total-row {
    font-weight: 700;
    background: #e8f0fe !important;
}

/* ============================================ */
/* MODAL PARA EDITAR INLINE */
/* ============================================ */
.inline-edit input {
    width: 100%;
    padding: 0.4rem 0.5rem;
    border: 2px solid var(--primary-light);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-family: var(--font);
}

.inline-edit input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(41, 128, 185, 0.15);
}

/* ============================================ */
/* ANIMACIONES */
/* ============================================ */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(100px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================ */
/* RESPONSIVE - TABLET */
/* ============================================ */
@media (min-width: 768px) {
    .sidebar {
        transform: translateX(0);
    }
    
    .sidebar-close {
        display: none !important;
    }
    
    .sidebar.active .sidebar-close {
        display: none !important;
    }
    
    .sidebar-overlay {
        display: none !important;
    }
    
    .main-content {
        margin-left: var(--sidebar-width);
    }
    
    .content-area {
        padding: 1.5rem;
    }
    
    .form-grid {
        grid-template-columns: 1fr 1fr 1fr;
    }
    
    .reportes-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ============================================ */
/* RESPONSIVE - DESKTOP */
/* ============================================ */
@media (min-width: 1024px) {
    .content-area {
        padding: 2rem;
    }
    
    .form-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
