/* ── Reset y base ─────────────────────────────────────── */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont,
        'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    color: #333;
    font-size: 14px;
}

/* ── Páginas ──────────────────────────────────────────── */
.page { width: 100%; min-height: 100vh; }
.active { display: block; }
.hidden { display: none !important; }

/* ── LOGIN ────────────────────────────────────────────── */
#loginPage {
    background: linear-gradient(135deg, #1a1f38 0%, #0d1021 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    background: white;
    border-radius: 16px;
    padding: 40px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo h1 {
    font-size: 22px;
    color: #1a1f38;
    margin-bottom: 6px;
}

.login-logo p {
    color: #888;
    font-size: 13px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #555;
    font-size: 13px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    background: white;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #ffd700;
}

.error-msg {
    background: #fff0f0;
    color: #e53935;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
    border: 1px solid #ffcdd2;
}

/* ── Botones ──────────────────────────────────────────── */
.btn-primary {
    background: #ffd700;
    color: #1a1f38;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover { background: #f0c800; }
.btn-full { width: 100%; }

.btn-logout {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

/* ── Header ───────────────────────────────────────────── */
.app-header {
    background: #1a1f38;
    color: white;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.app-header span:first-child {
    font-weight: 700;
    font-size: 15px;
    color: #ffd700;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

#headerUsuario {
    font-size: 13px;
    color: rgba(255,255,255,0.7);
}

/* ── Navegación ───────────────────────────────────────── */
.app-nav {
    background: white;
    display: flex;
    border-bottom: 2px solid #f0f2f5;
    overflow-x: auto;
    position: sticky;
    top: 48px;
    z-index: 99;
}

.nav-btn {
    flex: 1;
    padding: 12px 8px;
    border: none;
    background: transparent;
    color: #888;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
    min-width: 70px;
}

.nav-btn.active {
    color: #1a1f38;
    border-bottom-color: #ffd700;
}

.app-content {
    padding: 20px;
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
}

/* ── Tabs ─────────────────────────────────────────────── */
.tab { display: none; }
.tab.active { display: block; }

/* ── Filtros ──────────────────────────────────────────── */
.filtros {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.filtros input,
.filtros select {
    flex: 1;
    min-width: 120px;
    padding: 9px 12px;
    border: 1.5px solid #e0e0e0;
    border-radius: 8px;
    font-size: 13px;
    background: white;
    outline: none;
}

.filtros input:focus,
.filtros select:focus {
    border-color: #ffd700;
}

/* ── Cards ────────────────────────────────────────────── */
.cards-container {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.card {
    background: white;
    border-radius: 14px;
    padding: 18px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    border-left: 5px solid #e0e0e0;
}

.card.disponible  { border-left-color: #28c76f; }
.card.alquilada   { border-left-color: #ff4f5a; }
.card.proxima     { border-left-color: #ff9f43; }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.card-codigo {
    font-weight: 700;
    color: #1a1f38;
    font-size: 17px;
}

.card-virtual {
    background: #ffd700;
    color: #1a1f38;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
}

.card-ubicacion {
    color: #555;
    font-size: 14px;
    margin-bottom: 4px;
}

.card-ciudad {
    color: #888;
    font-size: 13px;
    margin-bottom: 10px;
}

.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.badge.disponible {
    background: #e8f8f0;
    color: #28c76f;
}
.badge.alquilada {
    background: #fff0f0;
    color: #ff4f5a;
}
.badge.proxima {
    background: #fff8f0;
    color: #ff9f43;
}

.card-fecha {
    font-size: 12px;
    color: #aaa;
}

.card-anunciante {
    font-size: 13px;
    color: #666;
    font-style: italic;
    margin-top: 6px;
}

/* ── Alertas ──────────────────────────────────────────── */
.dias-badge {
    font-size: 12px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
}

.dias-urgente { background: #fff0f0; color: #ff4f5a; }
.dias-proximo { background: #fff8f0; color: #ff9f43; }
.dias-normal  { background: #f0f8ff; color: #54a0ff; }

/* ── Peticiones ───────────────────────────────────────── */
.estado-pendiente  {
    background: #fffbf0;
    color: #ffd700;
    border: 1px solid #ffd700;
}
.estado-en-estudio {
    background: #f0f8ff;
    color: #54a0ff;
    border: 1px solid #54a0ff;
}
.estado-aprobada   {
    background: #e8f8f0;
    color: #28c76f;
    border: 1px solid #28c76f;
}
.estado-descartada {
    background: #fff0f0;
    color: #ff4f5a;
    border: 1px solid #ff4f5a;
}

/* ── Mapa ─────────────────────────────────────────────── */
.mapa {
    width: 100%;
    height: calc(100vh - 120px);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.1);
}

/* ── Loading ──────────────────────────────────────────── */
.loading {
    text-align: center;
    padding: 40px;
    color: #aaa;
    font-size: 14px;
}

/* ── Vacío ────────────────────────────────────────────── */
.empty {
    text-align: center;
    padding: 40px;
    color: #bbb;
}

.empty p { font-size: 14px; margin-top: 8px; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 767px) {
    .cards-container {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

@media (min-width: 768px) {
    .cards-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 20px;
    }
}

@media (min-width: 1200px) {
    .cards-container {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
}

@media (min-width: 1400px) {
    .cards-container {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }
}

/* ── Landscape: móvil rotado (alto ≤ 500px, p.ej. iPhone) ── */
@media (orientation: landscape) and (max-height: 500px) {
    #loginPage {
        align-items: flex-start;
        padding: 8px 20px;
        overflow-y: auto;
    }
    .login-container {
        padding: 18px 24px;
        max-width: 500px;
        margin: 0 auto;
    }
    .login-logo {
        margin-bottom: 12px;
    }
    .login-logo img { max-height: 48px; }
    .login-logo h1 { font-size: 18px; }
    .form-group { margin-bottom: 10px; }
    .form-group input,
    .form-group select { padding: 9px 12px; }

    .app-header { padding: 8px 16px; }
    .app-nav { top: 38px; }
    .nav-btn { padding: 8px 6px; font-size: 11px; }

    .app-content { padding: 10px 16px; }
    .filtros { margin-bottom: 10px; }

    .cards-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .card { padding: 12px; }

    .mapa { height: calc(100vh - 82px); }
}

/* ── Landscape: tablet rotada (alto 501-767px, ancho ≤ 1024px) ── */
@media (orientation: landscape) and (min-height: 501px) and (max-width: 1024px) {
    .cards-container {
        grid-template-columns: repeat(3, 1fr);
    }
    .mapa { height: calc(100vh - 100px); }
}