/* CRM Styles */
@import url('../styles.css');

.crm-body {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background-color: #f8fafc; /* Lighter background for dashboard */
    color: var(--text-dark);
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--primary);
    color: var(--text-light);
    height: 100%;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--base);
    text-decoration: none;
    margin-bottom: 3rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-logo span { color: var(--secondary); }

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 1rem;
    border-radius: 12px;
    color: var(--text-muted);
    text-decoration: none;
    transition: var(--transition);
    font-weight: 500;
}

.nav-item:hover, .nav-item.active {
    background: rgba(46, 212, 245, 0.1);
    color: var(--secondary);
}

.nav-item i {
    font-size: 1.2rem;
}

/* Main Content */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 3rem;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

/* Dashboard Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--base);
    padding: 1.5rem;
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-info h4 {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.2rem;
}

.stat-info p {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

/* Table */
.table-container {
    background: var(--base);
    border-radius: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.table-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e2e8f0;
}

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

th, td {
    padding: 1rem 1.5rem;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

th {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    background: #f8fafc;
}

td {
    font-size: 0.95rem;
    color: var(--primary);
    font-weight: 500;
}

tr:hover {
    background: #f8fafc;
}

/* Status Badges */
.badge {
    padding: 0.4rem 0.8rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
}
.badge-pendiente { background: #fef08a; color: #854d0e; }
.badge-aprobada { background: #bbf7d0; color: #166534; }
.badge-rechazada { background: #fecaca; color: #991b1b; }
.badge-revision { background: #bfdbfe; color: #1e40af; }
.badge-desembolsado { background: #e0e7ff; color: #3730a3; }

/* Table Action Buttons */
.btn-view {
    background: transparent;
    color: var(--primary);
    border: 1px solid var(--primary);
    padding: 0.4rem 0.8rem; 
    font-size: 0.8rem;
    border-radius: 6px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn-view:hover {
    background: rgba(46, 212, 245, 0.1);
    border-color: var(--secondary);
    box-shadow: 0 0 8px rgba(46, 212, 245, 0.4);
    color: var(--secondary);
}

/* Modal Detail */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(16, 7, 49, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--base);
    width: 100%;
    max-width: 800px;
    border-radius: 20px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 2rem;
}

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

.detail-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #f1f5f9;
}

.detail-section h4 {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    text-transform: uppercase;
}

.info-item {
    margin-bottom: 0.8rem;
}
.info-item label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.info-item span {
    font-weight: 600;
    color: var(--primary);
}

.notes-container {
    background: #f8fafc;
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1rem;
    max-height: 200px;
    overflow-y: auto;
}

.note-item {
    background: var(--base);
    padding: 0.8rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    border-left: 3px solid var(--secondary);
}

/* Login */
.login-body {
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
}

/* --- SPA Views --- */
.crm-view {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.crm-view.active {
    display: block;
}

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

/* --- Configuration Tabs & Inputs --- */
.config-tabs {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.config-tab {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
}

.config-tab:hover {
    background: rgba(0,0,0,0.02);
    color: var(--primary);
}

.config-tab.active {
    background: var(--primary);
    color: var(--base);
    box-shadow: 0 4px 10px rgba(16, 7, 49, 0.2);
}

.cfg-section {
    animation: fadeIn 0.3s ease forwards;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--primary);
}

.config-input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: #f8fafc;
}

.config-input:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(46, 212, 245, 0.2);
    background: var(--base);
}

/* Toggle Switch (iOS style) */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: #cbd5e1;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
}

input:checked + .slider {
    background-color: #10b981;
}

input:checked + .slider:before {
    transform: translateX(22px);
}

.slider.round {
    border-radius: 34px;
}

.slider.round:before {
    border-radius: 50%;
}

/* --- PRINT STYLES --- */
@media print {
    /* Hide everything except the modal content */
    body > *:not(#modal-detalle) {
        display: none !important;
    }
    
    #modal-detalle {
        display: block !important;
        position: relative !important;
        background: white !important;
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
        height: auto !important;
        box-shadow: none !important;
    }
    
    .modal-content {
        box-shadow: none !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    /* Hide modal UI elements */
    .modal-actions, #btn-close-modal, .change-status, #note-form, .sidebar, .topbar {
        display: none !important;
    }
    
    /* Adjust grid for print */
    .detail-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }
    
    .detail-section {
        background: white !important;
        border: 1px solid #e2e8f0 !important;
        page-break-inside: avoid;
    }

    h2, h3, h4 {
        color: #000 !important;
    }
}
