/* ==========================================================================
   Portal EDI — hoja de estilos base
   Mobile-first: la mayoría de los usuarios entra desde el celular.
   ========================================================================== */

:root {
    --navy: #1a2332;
    --navy-light: #2a3548;
    --bg: #f4f4f1;
    --surface: #ffffff;
    --border: #e2e2dc;
    --text: #1f2430;
    --text-muted: #6b7280;
    --accent: #2563eb;
    --accent-light: #eff4ff;
    --success-bg: #dcfce7;
    --success-text: #166534;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --info-bg: #dbeafe;
    --info-text: #1e40af;
    --neutral-bg: #f1f1ea;
    --neutral-text: #6b6b60;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(20, 20, 15, 0.06), 0 1px 2px rgba(20, 20, 15, 0.04);
}

* { box-sizing: border-box; }

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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Barra superior / navegación ---------- */

.topbar {
    background: var(--navy);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
}

.topbar-brand {
    font-weight: 700;
    font-size: 17px;
    letter-spacing: -0.01em;
    white-space: nowrap;
}

.topbar-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    padding: 4px 8px;
    cursor: pointer;
}

.topbar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 0 12px 10px;
}

.topbar-nav a {
    color: rgba(255, 255, 255, 0.82);
    text-decoration: none;
    font-size: 13.5px;
    padding: 7px 11px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease;
}

.topbar-nav a:hover,
.topbar-nav a:focus-visible {
    background: rgba(255, 255, 255, 0.10);
    color: #fff;
}

.topbar-nav a.logout {
    margin-left: auto;
    color: rgba(255, 255, 255, 0.55);
}

@media (max-width: 640px) {
    .topbar-toggle { display: block; }
    .topbar-nav {
        display: none;
        flex-direction: column;
        gap: 2px;
        padding: 4px 12px 12px;
    }
    .topbar-nav.is-open { display: flex; }
    .topbar-nav a { padding: 10px 12px; }
    .topbar-nav a.logout { margin-left: 0; border-top: 1px solid rgba(255,255,255,0.12); margin-top: 6px; padding-top: 12px; }
}

/* ---------- Contenido ---------- */

.content {
    max-width: 960px;
    margin: 0 auto;
    padding: 24px 16px 64px;
}

h1 {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0 0 18px;
    color: var(--navy);
}

h2 {
    font-size: 15px;
    font-weight: 600;
    margin: 28px 0 12px;
    color: var(--navy);
}

.content > p:first-of-type { margin-top: 0; }

a { color: var(--accent); }

/* Enlaces de acción tipo botón fantasma (ej. "+ Nueva unidad") */
.content > p > a:only-child,
.content a.accion {
    display: inline-block;
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    color: var(--accent);
    background: var(--accent-light);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
}

/* ---------- Tarjeta de login ---------- */

.login-box {
    max-width: 380px;
    margin: 48px auto;
    background: var(--surface);
    padding: 28px 24px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.login-box h1 { margin-bottom: 4px; }

/* ---------- Formularios ---------- */

.formulario {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--surface);
    padding: 18px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    max-width: 480px;
}

.formulario label {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.formulario input,
.formulario select,
.formulario textarea {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: inherit;
    color: var(--text);
    background: var(--surface);
}

.formulario input:focus,
.formulario select:focus,
.formulario textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.formulario button,
button[type="submit"] {
    margin-top: 4px;
    padding: 11px 16px;
    background: var(--navy);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14.5px;
    font-weight: 600;
    transition: background 0.15s ease;
}

.formulario button:hover,
button[type="submit"]:hover { background: var(--navy-light); }

/* Botones pequeños sueltos (ej. dentro de tablas: "Marcar pagada", "Cancelar") */
button:not(.formulario button):not([type="submit"]) {
    padding: 6px 10px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    cursor: pointer;
}

button:not(.formulario button):not([type="submit"]):hover {
    background: var(--bg);
}

/* ---------- Tablas ---------- */

.tabla {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    font-size: 13.5px;
}

.tabla th {
    text-align: left;
    padding: 10px 12px;
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border);
}

.tabla td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.tabla tbody tr:last-child td { border-bottom: none; }
.tabla tbody tr:hover { background: var(--bg); }

.tabla tfoot td {
    padding: 11px 12px;
    background: var(--bg);
    border-top: 2px solid var(--border);
}

/* Tablas anchas dentro de una pantalla angosta: scroll horizontal en vez de romper el layout */
@media (max-width: 640px) {
    .tabla { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ---------- Badges de estado ---------- */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
}

.badge-ocupada { background: var(--success-bg); color: var(--success-text); }
.badge-vacia { background: var(--neutral-bg); color: var(--neutral-text); }
.badge-en_venta { background: var(--warning-bg); color: var(--warning-text); }
.badge-en_arriendo { background: var(--info-bg); color: var(--info-text); }

/* ---------- Alertas ---------- */

.alerta-error {
    background: #fee2e2;
    color: #991b1b;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    border: 1px solid #fecaca;
}

/* ---------- Vacíos / estados sin datos ---------- */

.content > p:only-of-type {
    color: var(--text-muted);
    font-size: 14px;
}

/* ---------- Dashboard ---------- */

.dash-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.dash-header select {
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.dash-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 6px;
}

@media (min-width: 560px) {
    .dash-stats { grid-template-columns: repeat(4, 1fr); }
}

.dash-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: border-color 0.15s ease;
}

.dash-stat:hover { border-color: var(--accent); }

.dash-stat-valor {
    font-size: 26px;
    font-weight: 700;
    color: var(--navy);
    letter-spacing: -0.02em;
}

.dash-stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.dash-stat-alerta .dash-stat-valor { color: #b91c1c; }

.dash-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

@media (min-width: 560px) {
    .dash-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 860px) {
    .dash-grid { grid-template-columns: repeat(3, 1fr); }
}

.dash-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-decoration: none;
    box-shadow: var(--shadow);
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.dash-card:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
}

.dash-card-titulo {
    font-weight: 700;
    font-size: 14.5px;
    color: var(--navy);
}

.dash-card-desc {
    font-size: 12.5px;
    color: var(--text-muted);
}
