/* ================================================================
   GestionMX — Flat Design Municipal sobre Metronic
   Sin sombras, sin degradados, sin efectos 3D.
   Poppins, Font Awesome y Metronic cargados localmente (offline-first).
   Variables dinámicas inyectadas por municipio vía JS.
================================================================ */

/* Forzar Poppins como fuente base (sobreescribe Metronic si usa otra) */
html, body, .fs-root { font-family: 'Poppins', sans-serif !important; }

/* ── Variables de municipio (defaults, se sobreescriben via JS) ── */
:root {
    --primary:          #1565C0;
    --primary-dark:     #0D47A1;
    --accent:           #FF6F00;
    --text-dark:        #1C1C1E;
    --text-muted:       #6B7280;
    --bg:               #FFFFFF;
    --bg-secondary:     #F5F5F5;
    --border:           #E5E7EB;
    --danger:           #DC2626;
    --success:          #16A34A;
    --warning:          #D97706;
    --radius:           8px;
    --safe-top:         env(safe-area-inset-top, 0px);
    --safe-bottom:      env(safe-area-inset-bottom, 0px);
    --safe-left:        env(safe-area-inset-left, 0px);
    --safe-right:       env(safe-area-inset-right, 0px);
    --header-h:         60px;
    --nav-h:            60px;
}

/* ── Reset ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }
body {
    font-family: 'Poppins', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text-dark);
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}
a { cursor: pointer; text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
img { display: block; }

/* ── Typography helpers ─────────────────────────────────────────── */
.fw-bold    { font-weight: 700; }
.fw-semibold{ font-weight: 600; }
.fw-medium  { font-weight: 500; }
.text-dark  { color: var(--text-dark); }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.fs-2x { font-size: 1.75rem; }
.fs-5  { font-size: 1rem; }
.fs-6  { font-size: 0.875rem; }
.fs-7  { font-size: 0.8rem; }

/* ── Spacing helpers ─────────────────────────────────────────────── */
.mt-3 { margin-top: .75rem; }  .mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.25rem; } .mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }    .mb-0 { margin-bottom: 0; }
.mb-3 { margin-bottom: .75rem; }.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem;}.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }  .mb-10{ margin-bottom: 2.5rem; }
.py-5 { padding-top: 1.25rem; padding-bottom: 1.25rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.gap-3{ gap: .75rem; }
.d-flex   { display: flex; }
.flex-1   { flex: 1; }
.gap-3    { gap: .75rem; }
.flex-wrap{ flex-wrap: wrap; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.w-100 { width: 100%; }
.text-center { text-align: center; }

/* ── Buttons (flat, sin sombra) ─────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.875rem;
    padding: .6rem 1.25rem;
    transition: background .15s, color .15s;
    outline: none;
    cursor: pointer;
}
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-lg   { padding: .85rem 1.5rem; font-size: 1rem; }
.btn-sm   { padding: .35rem .75rem; font-size: .8rem; }
.btn-icon { padding: .45rem; border-radius: 50%; width: 36px; height: 36px; }

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); }

.btn-danger  { background: var(--danger);  color: #fff; }
.btn-success { background: var(--success); color: #fff; }

.btn-light {
    background: var(--bg-secondary);
    color: var(--text-dark);
}
.btn-light:hover { background: var(--border); }

.btn-white {
    background: var(--bg);
    color: var(--text-dark);
}
.btn-dark {
    background: #000;
    color: #fff;
}

/* ── Cards (sin sombra) ─────────────────────────────────────────── */
.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.card-body { padding: 1.25rem; }
.card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

/* ── Forms ──────────────────────────────────────────────────────── */
.form-control {
    width: 100%;
    padding: .65rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: .875rem;
    color: var(--text-dark);
    background: var(--bg);
    outline: none;
    transition: border-color .15s;
}
.form-control:focus { border-color: var(--primary); }
.form-control-lg { padding: .85rem 1.2rem; font-size: 1rem; }
.form-label { display: block; font-weight: 500; font-size: .85rem; margin-bottom: .4rem; }

.input-group {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.input-group .form-control {
    border: none;
    border-radius: 0;
    flex: 1;
}
.input-group-text {
    padding: 0 1rem;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-size: .875rem;
    display: flex;
    align-items: center;
    border-right: 1px solid var(--border);
}
.input-group .btn { border-radius: 0; }

.form-check { display: flex; align-items: center; gap: .4rem; }
.form-check-inline { display: inline-flex; margin-right: .5rem; }
.form-check-input {
    width: 16px; height: 16px;
    border: 1.5px solid var(--border);
    border-radius: 3px;
    appearance: none;
    cursor: pointer;
    background: var(--bg);
    transition: background .15s, border-color .15s;
}
.form-check-input:checked {
    background: var(--primary);
    border-color: var(--primary);
}

/* ── Badge ──────────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: .25em .55em;
    border-radius: 4px;
    font-size: .7rem;
    font-weight: 600;
}
.badge-light-primary { background: rgba(21,101,192,.12); color: var(--primary); }
.badge-success { background: rgba(22,163,74,.12); color: var(--success); }
.badge-danger  { background: rgba(220,38,38,.12);  color: var(--danger);  }
.badge-warning { background: rgba(217,119,6,.12);  color: var(--warning); }

/* ── Grid ───────────────────────────────────────────────────────── */
.row { display: flex; flex-wrap: wrap; margin: -.5rem; }
.col-6 { width: 50%; padding: .5rem; }
.col-12 { width: 100%; padding: .5rem; }
.g-3 { gap: .75rem; }

/* ── Splash screen ──────────────────────────────────────────────── */
.splash-screen {
    position: fixed; inset: 0;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding-top: var(--safe-top);
}
.splash-content { text-align: center; }
.splash-logo { width: 100px; height: 100px; object-fit: contain; margin: 0 auto 2rem; }
.splash-text { color: rgba(255,255,255,.8); font-size: .9rem; margin-top: 1rem; }

.splash-spinner {
    width: 36px; height: 36px;
    border: 3px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Full-screen views (permisos, login, mantenimiento) ─────────── */
.view-fullscreen {
    position: fixed; inset: 0;
    background: var(--bg);
    z-index: 100;
    overflow-y: auto;
    padding: calc(var(--safe-top) + 2rem) 1.5rem calc(var(--safe-bottom) + 2rem);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Permission cards ───────────────────────────────────────────── */
.permission-card {
    width: 100%;
    max-width: 380px;
    text-align: center;
}
.permission-icon {
    font-size: 4rem;
    line-height: 1;
    margin-bottom: 1.5rem;
}

/* ── Maintenance ────────────────────────────────────────────────── */
.maintenance-container { text-align: center; max-width: 340px; }
.maintenance-icon { font-size: 4rem; margin-bottom: 1.5rem; }

/* ── Login ──────────────────────────────────────────────────────── */
.login-container {
    width: 100%;
    max-width: 360px;
    text-align: center;
    padding-bottom: calc(var(--safe-bottom) + 2rem);
}
.login-logo { width: 90px; height: 90px; object-fit: contain; margin: 0 auto; }

/* ── Phone verify ───────────────────────────────────────────────── */
.phone-verify-container { width: 100%; max-width: 360px; }

/* ── App header ─────────────────────────────────────────────────── */
.app-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: calc(var(--header-h) + var(--safe-top));
    padding-top: var(--safe-top);
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: calc(1rem + var(--safe-left));
    padding-right: calc(1rem + var(--safe-right));
    z-index: 50;
}
.header-left  { display: flex; align-items: center; gap: .75rem; }
.header-logo  { width: 32px; height: 32px; object-fit: contain; border-radius: 4px; }
.header-title { font-weight: 600; font-size: 1rem; }
.header-right { display: flex; align-items: center; gap: .75rem; }
.header-saldo {
    background: rgba(255,255,255,.15);
    padding: .2rem .75rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: .85rem;
}

/* ── Main content area ──────────────────────────────────────────── */
.app-main {
    position: fixed;
    top:    calc(var(--header-h) + var(--safe-top));
    bottom: calc(var(--nav-h)   + var(--safe-bottom));
    left:   var(--safe-left);
    right:  var(--safe-right);
    overflow-y: auto;
    background: var(--bg-secondary);
    -webkit-overflow-scrolling: touch;
}
.app-main .container { max-width: 600px; margin: 0 auto; padding: 1.25rem 1rem; }
.app-main .container-fluid { width: 100%; }

/* ── Views ──────────────────────────────────────────────────────── */
.view { display: none; height: 100%; overflow-y: auto; }
.view.active { display: block; }

.view-header {
    display: flex;
    align-items: center;
    gap: .75rem;
}
.view-header h3 { flex: 1; }

/* ── Bottom nav ─────────────────────────────────────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(var(--nav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--bg);
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 50;
}
.nav-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: .7rem;
    font-weight: 500;
    transition: color .15s;
    padding: 0;
}
.nav-tab.active { color: var(--primary); }
.nav-icon { font-size: 1.4rem; line-height: 1; }
.nav-label { font-size: .65rem; }

/* ── Wallet card ────────────────────────────────────────────────── */
.wallet-card {
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius);
    padding: 1.5rem;
}
.wallet-label { font-size: .8rem; opacity: .8; }
.wallet-amount { font-size: 2.5rem; font-weight: 700; letter-spacing: -1px; }
.wallet-card .btn-white { font-weight: 600; font-size: .875rem; }

/* ── Modules grid ───────────────────────────────────────────────── */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}
.module-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color .15s;
}
.module-card:hover { border-color: var(--primary); }
.module-icon { font-size: 2rem; line-height: 1; margin-bottom: .75rem; }
.module-label { font-size: .8rem; font-weight: 600; color: var(--text-dark); }

/* ── Transactions ───────────────────────────────────────────────── */
.transaction-list { display: flex; flex-direction: column; gap: .75rem; }
.transaction-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.transaction-tipo { font-weight: 600; font-size: .875rem; }
.transaction-fecha { font-size: .75rem; color: var(--text-muted); margin-top: 2px; }
.transaction-monto { font-weight: 700; font-size: 1rem; }
.transaction-monto.ingreso { color: var(--success); }
.transaction-monto.egreso  { color: var(--danger);  }

/* ── Parking ────────────────────────────────────────────────────── */
.parking-active-card {
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    margin-bottom: 1rem;
}
.parking-label  { font-size: .8rem; opacity: .8; margin-bottom: .25rem; }
.parking-placa  { font-size: 2rem; font-weight: 700; letter-spacing: 2px; }
.parking-zona   { font-size: .875rem; opacity: .8; margin-bottom: .5rem; }
.parking-timer  { display: flex; justify-content: space-between; align-items: center;
                  background: rgba(0,0,0,.15); border-radius: 6px; padding: .75rem 1rem; }
.parking-timer span:first-child { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.parking-cost  { font-size: 1.5rem; font-weight: 700; }

/* ── Policía / POS items ────────────────────────────────────────── */
.result-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.alert-item {
    border: 1px solid var(--warning);
    background: rgba(217,119,6,.06);
    border-radius: var(--radius);
    padding: .75rem 1rem;
    margin-bottom: .5rem;
}

/* ── Menu items (perfil) ────────────────────────────────────────── */
.menu-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
    font-size: .9rem;
    cursor: pointer;
}
.menu-item:last-child { border-bottom: none; }

/* ── Profile ────────────────────────────────────────────────────── */
.profile-header { display: flex; align-items: center; gap: 1rem; }
.profile-avatar { width: 64px; height: 64px; border-radius: 50%; object-fit: cover;
                  border: 2px solid var(--border); }

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 200;
    display: flex;
    align-items: flex-end;
}
.modal-sheet {
    background: var(--bg);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-height: 85vh;
    overflow-y: auto;
    padding-bottom: calc(1rem + var(--safe-bottom));
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.25rem .75rem;
    border-bottom: 1px solid var(--border);
}
.modal-body { padding: 1.25rem; }

/* ── Toast ──────────────────────────────────────────────────────── */
.toast-container {
    position: fixed;
    top: calc(var(--header-h) + var(--safe-top) + .75rem);
    left: 50%; transform: translateX(-50%);
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    width: min(90vw, 380px);
    pointer-events: none;
}
.toast {
    background: var(--text-dark);
    color: #fff;
    border-radius: var(--radius);
    padding: .75rem 1rem;
    font-size: .875rem;
    font-weight: 500;
    animation: toastIn .25s ease;
    pointer-events: all;
}
.toast.success { background: var(--success); }
.toast.danger  { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes toastIn { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:none; } }

/* ── Leaflet flat overrides ─────────────────────────────────────── */
.leaflet-bar, .leaflet-bar a {
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
}
.leaflet-bar a { background: var(--bg) !important; }

/* ── Utilities ──────────────────────────────────────────────────── */
.border         { border: 1px solid var(--border); }
.border-gray-300{ border-color: #D1D5DB; }
.border-radius  { border-radius: var(--radius); }
.overflow-hidden{ overflow: hidden; }
