/* ============================================================
   miAuto — Dark / Elegant Theme
   Palette: deep navy, gold accent, soft neutrals
   ============================================================ */

:root {
    --bg-body: #0f1219;
    --bg-card: #181d28;
    --bg-card-hover: #1e2433;
    --bg-input: #141820;
    --border: #2a3040;
    --border-light: #353d50;
    --gold: #c9a227;
    --gold-light: #e8c84a;
    --gold-dim: rgba(201, 162, 39, 0.15);
    --text: #eaedf3;
    --text-muted: #8891a5;
    --danger: #e74c5e;
    --success: #34d399;
    --info: #60a5fa;
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Inter', sans-serif;
    --radius: 10px;
    --radius-sm: 6px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
    font-family: var(--font-body);
    background: var(--bg-body);
    color: var(--text);
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

/* ---- Typography ---- */
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; }
.gold { color: var(--gold); }
.text-muted { color: var(--text-muted); font-size: 0.87rem; }
.text-center { text-align: center; }

.logo-icon-img { display: block; margin: 0 auto 8px; }
.logo-lg { font-size: 2.4rem; letter-spacing: -1px; }
.logo-sm { font-size: 1.3rem; letter-spacing: -0.5px; white-space: nowrap; }

/* ---- Buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font-family: var(--font-body); font-weight: 500;
    padding: 10px 20px; border-radius: var(--radius-sm);
    border: none; cursor: pointer; text-decoration: none;
    font-size: 0.93rem; transition: all 0.2s;
}
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-full { width: 100%; }
.btn-primary { background: var(--gold); color: #111; }
.btn-primary:hover { background: var(--gold-light); }
.btn-gold { background: var(--gold); color: #111; }
.btn-gold:hover { background: var(--gold-light); }
.btn-outline {
    background: transparent; color: var(--text);
    border: 1px solid var(--border-light);
}
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }
.btn-danger { background: rgba(231,76,94,0.15); color: var(--danger); }
.btn-danger:hover { background: rgba(231,76,94,0.25); }

/* ---- Forms ---- */
.field { margin-bottom: 16px; }
.field label {
    display: block; font-size: 0.82rem; color: var(--text-muted);
    margin-bottom: 6px; font-weight: 500;
}
.field input, .field select, .field textarea {
    width: 100%; padding: 10px 14px; font-size: 0.93rem;
    background: var(--bg-input); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-family: var(--font-body); transition: border-color 0.2s;
}
.field input:focus, .field select:focus {
    outline: none; border-color: var(--gold);
}
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }

.error-msg {
    background: rgba(231,76,94,0.12); color: var(--danger);
    padding: 10px; border-radius: var(--radius-sm);
    font-size: 0.87rem; margin-bottom: 12px;
}

/* ---- Cards ---- */
.card {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); overflow: hidden;
    transition: border-color 0.2s;
}
.card:hover { border-color: var(--border-light); }
.card-body { padding: 20px; }
.card-body h3 { font-size: 1.1rem; margin-bottom: 4px; }
.card-sub { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 8px; }
.card-actions {
    padding: 12px 20px; border-top: 1px solid var(--border);
    display: flex; gap: 8px; flex-wrap: wrap;
}
.card-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.card.inactive { opacity: 0.5; }

.badge {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    font-size: 0.75rem; font-weight: 500;
}
.badge-ok { background: rgba(52,211,153,0.15); color: var(--success); }
.badge-off { background: rgba(231,76,94,0.15); color: var(--danger); }

.empty-state {
    text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.empty-state .hint { font-size: 0.85rem; margin-top: 8px; }

.loading { text-align: center; padding: 40px; color: var(--text-muted); }

/* ---- Modal ---- */
.modal {
    position: fixed; inset: 0; z-index: 1000;
    background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.modal.is-open { opacity: 1; pointer-events: auto; }
.modal-content {
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 28px;
    width: 90%; max-width: 460px;
}
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px;
}
.modal-header h3 { font-size: 1.15rem; }
.modal-close {
    background: none; border: none; color: var(--text-muted);
    font-size: 1.5rem; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* ---- Admin Header ---- */
.admin-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 14px 24px; border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.header-left, .header-right { display: flex; align-items: center; gap: 14px; }
.admin-user { color: var(--text-muted); font-size: 0.85rem; }

.admin-main { max-width: 960px; margin: 0 auto; padding: 28px 20px; }
.section-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 24px;
}
.section-header h2 { font-size: 1.4rem; }

/* ---- Login ---- */
.login-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100dvh;
}
.login-container { width: 90%; max-width: 380px; }
.login-logo {
    text-align: center; margin-bottom: 32px;
}
.login-logo .logo-icon { font-size: 3rem; display: block; margin-bottom: 8px; }
.login-logo h1 { font-size: 2rem; }
.login-logo .subtitle { color: var(--text-muted); margin-top: 4px; }

/* ---- Toast ---- */
.toast {
    position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
    background: var(--gold); color: #111; padding: 12px 24px;
    border-radius: var(--radius); font-weight: 500;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
    z-index: 9999;
}
.toast.show { opacity: 1; }

/* ============================================================
   USER-FACING STYLES
   ============================================================ */

.user-app {
    max-width: 480px; margin: 0 auto;
    min-height: 100dvh; display: flex; flex-direction: column;
}

.user-header {
    text-align: center; padding: 40px 20px 28px;
}
.user-header .tagline {
    color: var(--text-muted); margin-top: 6px; font-size: 1rem;
}

/* Saved car banner */
.saved-banner {
    margin: 16px; padding: 24px; text-align: center;
    background: linear-gradient(135deg, #1a1f2e, #1e2636);
    border: 1px solid var(--gold); border-radius: var(--radius);
}
.saved-icon { font-size: 3rem; margin-bottom: 12px; display: block; }
.saved-icon.pulse {
    animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(201,162,39,0.4)); }
    50% { filter: drop-shadow(0 0 20px rgba(201,162,39,0.8)); }
}
.saved-location { font-size: 1.1rem; font-weight: 600; color: var(--gold); }
.saved-spot { margin-top: 4px; font-size: 0.95rem; }
.saved-time { color: var(--text-muted); font-size: 0.82rem; margin-top: 4px; }
.saved-actions { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }

/* Parking list (user) */
.parking-list { padding: 0 16px 20px; display: flex; flex-direction: column; gap: 10px; }

.parking-card-user {
    display: flex; align-items: center; gap: 14px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    cursor: pointer; text-align: left; color: var(--text);
    width: 100%; font-family: var(--font-body);
    transition: all 0.2s;
}
.parking-card-user:hover { border-color: var(--gold); }
.pcu-icon { font-size: 1.8rem; }
.pcu-info { flex: 1; }
.pcu-info h3 { font-size: 1rem; margin-bottom: 2px; }
.pcu-info p { color: var(--text-muted); font-size: 0.82rem; }
.pcu-arrow { font-size: 1.5rem; color: var(--text-muted); }

/* Level list (user) */
.level-header {
    display: flex; align-items: center; gap: 12px;
    padding: 16px; border-bottom: 1px solid var(--border);
}
.level-header h2 { font-size: 1.1rem; }
.level-list { padding: 16px; display: flex; flex-direction: column; gap: 10px; }

.level-card-user {
    display: flex; align-items: center; gap: 14px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 16px;
    text-decoration: none; color: var(--text); transition: all 0.2s;
}
.level-card-user:hover { border-color: var(--gold); }
.lcu-icon { font-size: 1.4rem; }
.lcu-name { flex: 1; font-weight: 500; }

/* ============================================================
   MAP VIEW (USER) - Fixed header/footer, scrollable map
   ============================================================ */

body.map-page { overflow: hidden; height: 100dvh; }
body.map-page .user-app { height: 100dvh; max-width: 100%; overflow: hidden; }

.map-header {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
    background: var(--bg-card); flex-shrink: 0;
}
.map-title { flex: 1; }
.map-title h2 { font-size: 1rem; }
.map-title p { font-size: 0.78rem; }

.map-legend {
    display: flex; gap: 12px; padding: 8px 16px;
    background: var(--bg-card); border-bottom: 1px solid var(--border);
    overflow-x: auto; font-size: 0.75rem; flex-shrink: 0;
}
.legend-item { display: flex; align-items: center; gap: 4px; white-space: nowrap; color: var(--text-muted); }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }

.user-map-wrapper {
    flex: 1; overflow: auto; padding: 16px;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}
.user-map {
    position: relative; background: #0a0d14;
    border: 1px solid var(--border); border-radius: var(--radius);
    transition: transform 0.2s;
}

/* Map elements shared styles */
.map-element {
    position: absolute; border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; color: var(--text-muted);
    transition: box-shadow 0.2s, background 0.2s;
}
.el-label {
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    padding: 0 4px; max-width: 100%;
}

/* Element type styles */
.map-parking {
    background: rgba(201,162,39,0.1); border: 1px dashed rgba(201,162,39,0.35);
    color: var(--gold);
}
.map-parking.clickable { cursor: pointer; }
.map-parking.clickable:hover {
    background: rgba(201,162,39,0.2); border-color: var(--gold);
}
.map-parking.selected {
    background: rgba(201,162,39,0.3); border: 2px solid var(--gold);
    box-shadow: 0 0 16px rgba(201,162,39,0.5);
    z-index: 10;
}
.map-parking.confirmed {
    background: rgba(52,211,153,0.25); border-color: var(--success);
    box-shadow: 0 0 20px rgba(52,211,153,0.4);
}
.map-discapacitado {
    background: rgba(96,165,250,0.12); border: 2px solid rgba(96,165,250,0.5);
    color: var(--info);
}
.map-discapacitado.clickable { cursor: pointer; }
.map-discapacitado.clickable:hover {
    background: rgba(96,165,250,0.25); border-color: var(--info);
}
.map-discapacitado.selected {
    background: rgba(96,165,250,0.3); border: 2px solid var(--info);
    box-shadow: 0 0 16px rgba(96,165,250,0.5);
    z-index: 10;
}
.map-discapacitado.confirmed {
    background: rgba(52,211,153,0.25); border-color: var(--success);
    box-shadow: 0 0 20px rgba(52,211,153,0.4);
}
.map-pilar {
    background: #3a4050; border: 1px solid #4a5568; border-radius: 3px;
}
.map-muro {
    background: #2d3748; border: 1px solid #4a5568;
}
.map-pasillo {
    background: rgba(100,116,139,0.1); border: 1px dashed rgba(100,116,139,0.3);
}
.map-cebra {
    background: repeating-linear-gradient(
        90deg, rgba(255,255,255,0.3) 0px, rgba(255,255,255,0.3) 6px,
        rgba(255,255,255,0.05) 6px, rgba(255,255,255,0.05) 12px
    );
    border: 2px solid rgba(255,255,255,0.35);
    color: var(--text);
}
.map-mall {
    background: rgba(201,162,39,0.15);
    border: 3px solid rgba(201,162,39,0.6);
    border-radius: 6px; color: var(--gold);
    font-size: 0.85rem; font-weight: 700;
}
.map-escalera {
    background: rgba(100,116,139,0.18); border: 2px solid rgba(100,116,139,0.5);
    color: var(--text-muted);
}
.map-ascensor {
    background: rgba(168,85,247,0.2); border: 2px solid rgba(168,85,247,0.6);
    color: #a855f7; border-radius: 4px;
}
.map-totem {
    background: rgba(52,211,153,0.2); border: 2px solid rgba(52,211,153,0.6);
    color: var(--success); border-radius: 50%;
}
.map-texto {
    background: transparent; border: none;
    color: var(--text-muted); font-size: 0.85rem; font-weight: 500;
}

/* Action bar */
.map-action-bar {
    padding: 16px; border-top: 1px solid var(--border);
    background: var(--bg-card); text-align: center; flex-shrink: 0;
}
.action-text { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 10px; }
.action-text.highlight-text { color: var(--gold); font-weight: 600; }

/* ---- Responsive ---- */
@media (max-width: 600px) {
    html { font-size: 14px; }
    .card-grid { grid-template-columns: 1fr; }
    .admin-main { padding: 20px 12px; }
    .admin-header { padding: 10px 12px; }
    .section-header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .card-actions { flex-direction: column; }
    .card-actions .btn { width: 100%; }
}
