/* =====================================================
   PRESTAMOSCASA - ESTILOS CSS
   ===================================================== */

/* Reset y Variables */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #5b6fca;
    --primary-dark: #4a5db8;
    --primary-light: #7aa2ff;
    --secondary: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-main: #f3f6fb;
    --bg-card: #ffffff;
    --text-dark: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-dark);
    line-height: 1.6;
}

/* =====================================================
   NAVBAR
   ===================================================== */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    height: 64px;
    background: var(--bg-card);
    box-shadow: var(--shadow);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
}

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

.brand-icon {
    font-size: 24px;
}

.brand-text {
    font-size: 20px;
    font-weight: 700;
    color: var(--primary);
}

.nav-links {
    display: flex;
    gap: 8px;
}

.nav-link {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover {
    background: var(--bg-main);
    color: var(--primary);
}

.nav-link.active {
    background: var(--primary);
    color: white;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.user-role {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.role-jefe {
    background: #fef3c7;
    color: #92400e;
}

.role-empleado {
    background: #dbeafe;
    color: #1e40af;
}

.role-cliente {
    background: #d1fae5;
    color: #065f46;
}

.btn-logout {
    padding: 8px 16px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: #dc2626;
}

/* =====================================================
   CONTENIDO PRINCIPAL
   ===================================================== */
.main-content {
    padding: 88px 24px 24px;
    max-width: 1400px;
    margin: 0 auto;
}

.main-content.no-nav {
    padding-top: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

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

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
}

/* =====================================================
   FORMULARIOS
   ===================================================== */
.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-dark);
    font-size: 14px;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #f8fafc;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(91, 111, 202, 0.1);
    background: white;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

/* =====================================================
   BOTONES
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

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

.btn-secondary:hover {
    background: #059669;
}

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

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

.btn-outline {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
}

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

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

/* =====================================================
   TABLAS
   ===================================================== */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: var(--bg-main);
    font-weight: 600;
    color: var(--text-dark);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.table tr:hover {
    background: #f8fafc;
}

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

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

/* =====================================================
   BADGES
   ===================================================== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

/* =====================================================
   ESTADÍSTICAS
   ===================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.stat-label {
    font-size: 14px;
    color: var(--text-muted);
}

/* =====================================================
   LOGIN
   ===================================================== */
.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    text-align: center;
}

.login-logo {
    font-size: 48px;
    margin-bottom: 16px;
}

.login-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--text-muted);
    margin-bottom: 32px;
}

.login-card .form-group {
    text-align: left;
}

.login-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    display: none;
}

.login-error ul {
    margin: 6px 0 0 0;
    padding-left: 18px;
}

.login-error ul li {
    margin: 2px 0;
    font-size: 13px;
}

/* Ojito - toggle contraseña */
.password-input-wrapper {
    position: relative;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.5;
    transition: opacity 0.2s;
    font-size: 18px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
}

.toggle-password:hover {
    opacity: 1;
}

/* =====================================================
   MODAL
   ===================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

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

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.modal-overlay.active .modal {
    transform: scale(1);
}

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

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* =====================================================
   TOAST (NOTIFICACIONES)
   ===================================================== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 16px 24px;
    border-radius: var(--radius-sm);
    color: white;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 2000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--secondary);
}

.toast.error {
    background: var(--danger);
}

.toast.warning {
    background: var(--warning);
}

/* =====================================================
   UTILIDADES
   ===================================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--secondary); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.hidden { display: none !important; }

.flex { display: flex; }
.flex-between { justify-content: space-between; }
.flex-center { justify-content: center; }
.items-center { align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

/* =====================================================
   LOADING
   ===================================================== */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
    .navbar {
        flex-wrap: wrap;
        height: auto;
        padding: 12px;
    }

    .nav-links {
        order: 3;
        width: 100%;
        margin-top: 12px;
        overflow-x: auto;
        padding-bottom: 8px;
    }

    .main-content {
        padding: 140px 16px 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

/* =====================================================
   EMPTY STATE
   ===================================================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 8px;
}

.empty-state-text {
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* =====================================================
   MONEY FORMAT
   ===================================================== */
.money {
    font-family: 'Monaco', 'Consolas', monospace;
    font-weight: 600;
}

.money-positive {
    color: var(--secondary);
}

.money-negative {
    color: var(--danger);
}

/* =====================================================
   INPUT GRUPO CON PREFIJO ($)
   ===================================================== */
.input-money {
    display: flex; align-items: stretch; border-radius: 8px;
    border: 1px solid var(--border); overflow: hidden; background: #fff;
    transition: border-color 0.2s;
}
.input-money:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(91,111,202,0.12); }
.input-money-prefix {
    display: flex; align-items: center; justify-content: center;
    padding: 0 12px; background: #f1f5f9; color: #475569;
    font-weight: 700; font-size: 1rem; border-right: 1px solid var(--border);
    user-select: none; flex-shrink: 0;
}
.input-money input {
    border: none !important; outline: none !important; box-shadow: none !important;
    flex: 1; padding: 10px 12px; font-size: 0.95rem; background: transparent;
    min-width: 0;
}
.input-money input::placeholder { color: #94a3b8; }

/* =====================================================
   PLAN DE PAGOS - ESTILOS COMPARTIDOS
   ===================================================== */

/* Badges de estado */
.estado-badge {
    padding: 3px 12px; border-radius: 20px; font-size: 0.78rem;
    font-weight: 600; display: inline-flex; align-items: center; gap: 5px;
    letter-spacing: 0.02em;
}
.estado-pagada   { background: #dcfce7; color: #166534; }
.estado-parcial  { background: #fef9c3; color: #854d0e; }
.estado-actual   { background: #dbeafe; color: #1e40af; }
.estado-vencida  { background: #fee2e2; color: #991b1b; }
.estado-pendiente { background: #f1f5f9; color: #64748b; }

/* Filas coloreadas */
.row-pagada    { background: #f0fdf4 !important; }
.row-parcial   { background: #fffbeb !important; }
.row-actual    { background: #eff6ff !important; font-weight: 600; }
.row-vencida   { background: #fef2f2 !important; }
.row-pendiente { background: #ffffff !important; }

.row-pagada td:first-child    { border-left: 4px solid #22c55e; }
.row-parcial td:first-child   { border-left: 4px solid #eab308; }
.row-actual td:first-child    { border-left: 4px solid #3b82f6; }
.row-vencida td:first-child   { border-left: 4px solid #ef4444; }
.row-pendiente td:first-child { border-left: 4px solid #e2e8f0; }

/* Contenedor scrollable */
.plan-table-wrap {
    max-height: 480px; overflow-y: auto;
    border: 1px solid #e2e8f0; border-radius: 10px;
    scrollbar-width: thin;
}
.plan-table-wrap table { margin: 0; border-collapse: collapse; }
.plan-table-wrap thead { position: sticky; top: 0; z-index: 2; background: #f8fafc; }
.plan-table-wrap th { border-bottom: 2px solid #cbd5e1; padding: 10px 12px; font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.04em; color: #475569; }
.plan-table-wrap td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; font-size: 0.88rem; }

/* Iconos de estado */
.icon-check   { color: #22c55e; }
.icon-clock   { color: #3b82f6; }
.icon-alert   { color: #ef4444; }
.icon-wait    { color: #94a3b8; }
.icon-partial { color: #eab308; }

/* Leyenda */
.plan-legend { display: flex; gap: 16px; flex-wrap: wrap; margin: 10px 0; }
.plan-legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.78rem; color: #64748b; }
.plan-legend-dot { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

/* Progreso */
.plan-progress-row { margin-bottom: 10px; }
.plan-progress-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px; }
.plan-progress-label { font-size: 0.84rem; color: #475569; font-weight: 500; }
.plan-progress-value { font-size: 0.84rem; font-weight: 700; }
.plan-progress-track { background: #e5e7eb; border-radius: 8px; height: 10px; overflow: hidden; }
.plan-progress-fill { height: 100%; border-radius: 8px; transition: width 0.5s ease; }

/* Alerta vencidas */
.plan-alert-overdue {
    background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px;
    padding: 10px 14px; margin-bottom: 12px;
    display: flex; align-items: center; gap: 8px; color: #991b1b; font-size: 0.85rem;
}

/* Animacion highlight */
.highlight-pulse { animation: pulseHL 2s ease; }
@keyframes pulseHL {
    0% { background: inherit; } 25% { background: #bfdbfe; }
    75% { background: #bfdbfe; } 100% { background: inherit; }
}
