/* Postulantes ingresados */
.applicant-ingresado {
    background-color: #e0ffe0 !important;
    transition: background-color 0.3s;
}
/* =========================================================================
   VARIABLES Y TOKENS DE DISEÑO
   ========================================================================= */
:root {
    /* Color Palette */
    --primary: #137fec;
    /* Azul de los diseños anteriores (STITCH) */
    --primary-hover: #0e65bc;
    --secondary: #2c3e50;
    --success: #2ecc71;
    --success-light: #d4edda;
    --danger: #e74c3c;
    --danger-hover: #c0392b;
    --warning: #f1c40f;
    --text-main: #34495e;
    --text-muted: #7f8c8d;
    --bg-main: #f8f9fc;
    --bg-white: #ffffff;
    --bg-sidebar: #ffffff;
    --border-color: #e2e8f0;

    /* Typography */
    --font-family: 'Inter', sans-serif;

    /* Shadows & Border Radius */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.05);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* =========================================================================
   RESET GENÉRICO
   ========================================================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    overflow: hidden;
    /* Para que la SPA no tenga scroll completo, solo en áreas específicas */
}

/* =========================================================================
   LAYOUT PRINCIPAL
   ========================================================================= */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* =========================================================================
   SIDEBAR
   ========================================================================= */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.sidebar-header {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    border-bottom: 1px solid var(--border-color);
}

.logo-icon {
    font-size: 28px;
    color: var(--primary);
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--secondary);
}

.sidebar-header h2 span {
    font-weight: 400;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 24px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-btn i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.nav-btn:hover {
    background-color: var(--bg-main);
    color: var(--primary);
}

.nav-btn.active {
    background-color: rgba(19, 127, 236, 0.08);
    /* Fondo primario muy transparente */
    color: var(--primary);
    border-right: 3px solid var(--primary);
}

.sidebar-footer {
    padding: 20px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
}

/* =========================================================================
   MAIN CONTENT & HEADER
   ========================================================================= */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.top-header {
    height: 70px;
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
}

.header-title h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--secondary);
}

.header-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-greeting {
    font-size: 14px;
    font-weight: 500;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =========================================================================
   VIEW SECTIONS
   ========================================================================= */
.view-section {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

.hidden {
    display: none !important;
}

/* =========================================================================
   TOGGLE SWITCH (Ver Historial)
   ========================================================================= */
.section-actions {
    margin-bottom: 20px;
    display: flex;
    justify-content: flex-end;
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
}

.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(24px);
}

.slider.round {
    border-radius: 24px;
}

.slider.round:before {
    border-radius: 50%;
}

/* =========================================================================
   TABLAS (Matriz, Postulantes, Historial)
   ========================================================================= */
.table-container {
    background-color: var(--bg-white);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    overflow-x: auto;
    /* Scroll horizontal si es necesario */
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background-color: #f1f5f9;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
}

.data-table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.015);
}

.col-name {
    min-width: 200px;
}

/* Matriz - Checkboxes y celdas pagadas */
.matrix-table th {
    text-align: center;
}

.matrix-table td:not(:nth-child(2)) {
    /* Todo centrado menos el nombre */
    text-align: center;
}

.month-cell {
    position: relative;
    transition: background-color 0.3s;
}

.month-cell.paid {
    background-color: var(--success-light);
}

.check-paid {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--success);
}

/* Inquilinos pasados (Archivados) en la matriz */
.tenant-archived {
    background-color: #f7f7f7;
    opacity: 0.6;
}

.tenant-archived td {
    color: #999;
}

.tenant-archived input {
    pointer-events: none;
    /* No se puede modificar el historial */
}

/* Footer Matriz (Totales) */
.matrix-table tfoot th {
    background-color: var(--secondary);
    color: white;
}

/* Botón/Nombre clickeable */
.tenant-name-link {
    color: var(--primary);
    font-weight: 500;
    text-decoration: underline;
    cursor: pointer;
}

.tenant-name-link:hover {
    color: var(--primary-hover);
}

/* =========================================================================
   DASHBOARD HABITACIONES
   ========================================================================= */
.rooms-dashboard {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.floor-section h2 {
    font-size: 18px;
    color: var(--secondary);
    margin-bottom: 15px;
    padding-bottom: 5px;
    border-bottom: 2px solid var(--primary);
    display: inline-block;
}

.rooms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}

.room-card {
    background-color: var(--bg-white);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.room-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.room-number {
    font-size: 24px;
    font-weight: 700;
    color: var(--secondary);
}

.room-price {
    font-size: 14px;
    color: var(--text-muted);
}

.room-status {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-free {
    background-color: var(--success-light);
    color: var(--success);
}

.status-occupied {
    background-color: #fee2e2;
    color: var(--danger);
}

.room-btn {
    margin-top: 10px;
    padding: 8px 15px;
    border: none;
    border-radius: var(--radius-sm);
    background-color: var(--primary);
    color: white;
    cursor: pointer;
    font-size: 13px;
    width: 100%;
}

.room-btn:hover {
    background-color: var(--primary-hover);
}

/* =========================================================================
   SEARCH BAR
   ========================================================================= */
.search-bar {
    margin-bottom: 20px;
    position: relative;
    max-width: 400px;
}

.search-bar i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.search-bar input {
    width: 100%;
    padding: 12px 15px 12px 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.search-bar input:focus {
    border-color: var(--primary);
}

/* =========================================================================
   MODALES
   ========================================================================= */
.modal {
    display: none;
    /* Hidden by default */
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
    /* Para centrar con flexbox */
}

.modal-content {
    background-color: var(--bg-white);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    position: relative;
    animation: modalFadeIn 0.3s;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close-modal {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
}

.close-modal:hover {
    color: var(--danger);
}

.modal-header {
    padding: 25px 30px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 18px;
}

.room-badge {
    background-color: var(--primary);
    color: white;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
}

.modal-body {
    padding: 30px;
}

.tenant-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}

.detail-group {
    display: flex;
    flex-direction: column;
}

.detail-group label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.detail-group p {
    font-size: 14px;
    color: var(--text-main);
}

.fw-bold {
    font-weight: 600;
}

hr {
    border: 0;
    border-top: 1px dashed var(--border-color);
    margin: 20px 0;
}

.checkout-section h3 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--secondary);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 500;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: var(--font-family);
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--primary);
    outline: none;
}

.mt-3 {
    margin-top: 20px;
}

/* Buttons inside forms */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.2s;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
}

.btn-danger {
    background-color: var(--danger);
    color: white;
}

.btn-danger:hover {
    background-color: var(--danger-hover);
}

/* =========================================================================
   RESPONSIVE DESIGN (Media Queries)
   ========================================================================= */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        padding: 10px;
    }

    .sidebar-header {
        padding: 5px 10px;
        border-bottom: none;
    }

    .sidebar-nav {
        flex-direction: row;
        flex-wrap: wrap;
        padding: 5px 0;
        gap: 5px;
    }

    .nav-btn {
        width: auto;
        flex: 1;
        min-width: calc(50% - 5px);
        padding: 10px;
        font-size: 13px;
        justify-content: center;
        border-radius: var(--radius-sm);
    }

    .nav-btn.active {
        border-right: none;
        border-bottom: 3px solid var(--primary);
    }

    .sidebar-footer {
        display: none;
    }

    .top-header {
        height: auto;
        min-height: 60px;
        padding: 10px 15px;
    }

    .header-user {
        display: none;
    }

    /* Ocultar en mobile para espacio */

    .view-section {
        padding: 15px;
    }

    .tenant-details {
        grid-template-columns: 1fr;
    }

    .rooms-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}