/* ===== BASE ===== */
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background: #F3F4F6;
    padding-bottom: 70px;
    min-height: 100vh;
    margin: 0;
}
/* Remove bottom padding when no bottom nav exists (detail/form/login pages) */
body:not(:has(.bottom-nav)) { padding-bottom: 0; }

/* ===== BOOTSTRAP OVERRIDES ===== */
/* Neutralize Bootstrap resets that conflict with our custom design */
a { text-decoration: none; }
h1,h2,h3,h4,h5,h6 { margin-bottom: 0; }
p { margin-bottom: 0; }

.app-container {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100vh;
    background: #F3F4F6;
    position: relative;
}

/* ===== COLORS ===== */
:root {
    --orange:   #F97316;
    --orange-d: #EA6C0A;
    --blue:     #3B82F6;
    --green:    #22C55E;
    --red:      #EF4444;
    --gray-50:  #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-400: #9CA3AF;
    --gray-700: #374151;
    --gray-900: #111827;
}

/* ===== TOP HEADER ===== */
.app-header {
    background: #fff;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 100;
}
.app-header .back-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--gray-700);
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.app-header h5 { margin: 0; font-weight: 600; font-size: 16px; }

/* ===== BOTTOM NAV ===== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 430px;
    background: #fff;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 62px;
    z-index: 200;
}
.bottom-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--gray-400);
    font-size: 10px;
    gap: 3px;
    padding: 8px 12px;
    flex: 1;
    transition: color .15s;
}
.bottom-nav a.active { color: var(--orange); }
.bottom-nav i { font-size: 22px; }

/* ===== BUTTONS ===== */
.btn-orange {
    background: var(--orange);
    color: #fff;
    border: none;
    border-radius: 14px;
    padding: 15px 24px;
    width: 100%;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background .15s;
}
.btn-orange:hover { background: var(--orange-d); }
.btn-orange:disabled { opacity: .6; cursor: not-allowed; }

.btn-outline-gray {
    background: #fff;
    color: var(--gray-700);
    border: 1.5px solid var(--gray-200);
    border-radius: 14px;
    padding: 12px 24px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    width: 100%;
    transition: border-color .15s;
}
.btn-outline-gray:hover { border-color: var(--gray-400); }

.btn-red {
    background: #FEE2E2;
    color: #B91C1C;
    border: none;
    border-radius: 14px;
    padding: 15px 24px;
    width: 100%;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
}

/* ===== SECTION ===== */
.section { padding: 16px; }
.section-title { font-size: 15px; font-weight: 600; color: var(--gray-900); margin-bottom: 12px; }

/* ===== CARDS ===== */
.card-white {
    background: #fff;
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}
.incident-card {
    background: #fff;
    border-radius: 14px;
    padding: 14px 14px 14px 18px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
    border-left: 4px solid transparent;
    cursor: pointer;
    transition: box-shadow .15s;
}
.incident-card:hover { box-shadow: 0 3px 8px rgba(0,0,0,.1); }
.border-urgente { border-left-color: var(--red); }
.border-media   { border-left-color: var(--orange); }
.border-baja    { border-left-color: var(--blue); }
.border-resuelto{ border-left-color: var(--green); }

/* ===== BADGES ===== */
.badge-status {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}
.badge-recibido { background: #DBEAFE; color: #1D4ED8; }
.badge-proceso  { background: #FED7AA; color: #C2410C; }
.badge-resuelto { background: #D1FAE5; color: #065F46; }
.badge-urgente  { background: #FEE2E2; color: #B91C1C; }
.badge-media    { background: #FED7AA; color: #C2410C; }
.badge-baja     { background: #DBEAFE; color: #1D4ED8; }

.text-urgente { color: var(--red); }
.text-media   { color: var(--orange); }
.text-baja    { color: var(--blue); }

/* ===== PROGRESS 3-STEP ===== */
.progress-3step {
    display: flex;
    gap: 4px;
    margin-top: 10px;
}
.step-bar-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.step-bar {
    height: 4px;
    border-radius: 3px;
    background: var(--gray-200);
    transition: background .2s;
}
.step-bar.active { background: var(--orange); }
.step-bar.done   { background: var(--green); }
.step-label { font-size: 9px; color: var(--gray-400); text-align: center; }

/* ===== TIMELINE ===== */
.timeline { padding-left: 36px; }
.timeline-item {
    position: relative;
    padding-bottom: 28px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item::before {
    content: '';
    position: absolute;
    left: -26px;
    top: 22px;
    bottom: 0;
    width: 2px;
    background: var(--gray-200);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
    position: absolute;
    left: -34px;
    top: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--gray-200);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}
.timeline-dot.done    { background: var(--orange); border-color: var(--orange); color: #fff; }
.timeline-dot.pending { background: #fff; border-color: var(--gray-200); }
.timeline-title   { font-size: 14px; font-weight: 600; color: var(--gray-900); }
.timeline-date    { font-size: 11px; color: var(--gray-400); margin-bottom: 2px; }
.timeline-desc    { font-size: 12px; color: #6B7280; }

/* ===== CATEGORY GRID ===== */
.category-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}
.category-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 4px;
    border-radius: 10px;
    cursor: pointer;
    border: 2px solid transparent;
    background: var(--gray-100);
    font-size: 9px;
    text-align: center;
    gap: 5px;
    color: var(--gray-700);
    transition: all .15s;
}
.category-item i { font-size: 22px; }
.category-item.selected {
    border-color: var(--orange);
    background: #FFF7ED;
    color: var(--orange);
}

/* ===== PHOTO UPLOAD ===== */
.photo-upload {
    border: 2px dashed var(--gray-200);
    border-radius: 14px;
    padding: 28px 16px;
    text-align: center;
    cursor: pointer;
    color: var(--gray-400);
    background: #fff;
    margin-bottom: 12px;
    transition: border-color .15s;
}
.photo-upload:hover { border-color: var(--orange); }
.photo-upload i { font-size: 28px; display: block; margin-bottom: 6px; }

/* ===== LOCATION ROW ===== */
.location-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 12px;
    border: 1px solid var(--gray-200);
}
.location-row .loc-text { font-size: 13px; color: var(--gray-700); display: flex; align-items: center; gap: 6px; }
.location-row a { font-size: 13px; color: var(--orange); font-weight: 600; text-decoration: none; }

/* ===== MAP ===== */
.map-mini { height: 180px; border-radius: 14px; overflow: hidden; }
.map-full { height: calc(100vh - 130px); width: 100%; }
#map, #map-full { width: 100%; height: 100%; }

/* ===== FILTER TABS ===== */
.filter-tabs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    scrollbar-width: none;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
    padding: 6px 16px;
    border-radius: 20px;
    border: 1.5px solid var(--gray-200);
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
    background: #fff;
    color: #6B7280;
    font-weight: 500;
    transition: all .15s;
}
.filter-tab.active {
    background: var(--orange);
    border-color: var(--orange);
    color: #fff;
}

/* ===== ALERT BANNER ===== */
.alert-banner {
    background: #FEF2F2;
    border-left: 4px solid var(--red);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 12px 16px;
    border-radius: 10px;
    font-size: 13px;
    color: #991B1B;
}
.alert-banner i { font-size: 18px; color: var(--red); }

/* ===== STATUS SELECTOR (OPERATOR) ===== */
.status-selector { display: flex; gap: 8px; }
.status-btn {
    flex: 1;
    padding: 10px 6px;
    border-radius: 10px;
    border: 2px solid var(--gray-200);
    background: #fff;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    color: var(--gray-700);
    transition: all .15s;
}
.status-btn.active-recibido { border-color: var(--blue); background: #EFF6FF; color: var(--blue); }
.status-btn.active-proceso  { border-color: var(--orange); background: #FFF7ED; color: var(--orange); }
.status-btn.active-resuelto { border-color: var(--green); background: #F0FDF4; color: var(--green); }

/* ===== AVATAR ===== */
.avatar-circle {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--orange);
    color: #fff;
    font-size: 26px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}

/* ===== PROFILE STATS ===== */
.profile-stats {
    display: flex;
    justify-content: center;
    gap: 32px;
    margin: 16px 0;
}
.stat-item { text-align: center; }
.stat-value { font-size: 22px; font-weight: 700; color: var(--orange); }
.stat-value.green { color: var(--green); }
.stat-label { font-size: 11px; color: var(--gray-400); }

/* ===== MENU LIST ===== */
.menu-list { background: #fff; border-radius: 14px; overflow: hidden; }
.menu-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 16px;
    border-bottom: 1px solid var(--gray-100);
    cursor: pointer;
    text-decoration: none;
    color: var(--gray-700);
    font-size: 14px;
    transition: background .1s;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:hover { background: var(--gray-50); }
.menu-item .menu-left { display: flex; align-items: center; gap: 12px; }
.menu-item i.lead { font-size: 18px; color: var(--gray-400); }
.menu-item i.arrow { color: var(--gray-400); font-size: 14px; }

/* ===== LOGIN ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: #fff;
    max-width: 430px;
    margin: 0 auto;
}
.login-logo { font-size: 40px; margin-bottom: 12px; }
.login-title { font-size: 22px; font-weight: 700; color: var(--gray-900); margin-bottom: 4px; }
.login-subtitle { font-size: 14px; color: var(--gray-400); margin-bottom: 32px; }

.form-group { margin-bottom: 16px; width: 100%; }
.form-label { font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; display: block; }
.form-input {
    width: 100%;
    padding: 13px 16px;
    border-radius: 12px;
    border: 1.5px solid var(--gray-200);
    font-size: 15px;
    outline: none;
    transition: border-color .15s;
    background: var(--gray-50);
}
.form-input:focus { border-color: var(--orange); background: #fff; }

.error-msg {
    background: #FEE2E2;
    color: #B91C1C;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

/* ===== GREETING ===== */
.greeting-header {
    background: #fff;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--gray-200);
}
.greeting-text { font-size: 13px; color: var(--gray-400); }
.greeting-name { font-size: 20px; font-weight: 700; color: var(--gray-900); }

/* ===== MAP BOTTOM CARD ===== */
.map-bottom-card {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 32px);
    max-width: 398px;
    background: #fff;
    border-radius: 14px;
    padding: 14px 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    z-index: 10;
}

/* ===== ASSIGNED ROW ===== */
.assigned-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--gray-50);
    border-radius: 10px;
    padding: 12px 14px;
}
.assigned-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--blue);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
}
.btn-cambiar { color: var(--orange); font-weight: 600; font-size: 13px; background: none; border: none; cursor: pointer; }

/* ===== ACTION BOTTOM BAR ===== */
.action-bar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid var(--gray-200);
}
.action-bar button {
    padding: 12px;
    border-radius: 12px;
    border: 1.5px solid var(--gray-200);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    color: var(--gray-700);
}

/* ===== MAP LEGEND ===== */
.map-legend {
    position: absolute;
    top: 12px;
    left: 12px;
    background: #fff;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
    z-index: 10;
}
.legend-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 5px;
}

/* ===== MISC ===== */
.text-muted-sm { font-size: 12px; color: var(--gray-400); }
.divider { height: 8px; background: var(--gray-100); margin: 0 -16px; }

textarea.form-input { resize: vertical; min-height: 80px; }

/* ===== ADMIN STATS WRAP ===== */
.admin-stats-wrap {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.admin-stats-wrap .stat-card:first-child {
    grid-column: 1 / -1;
}

/* ===== DESKTOP SIDEBAR ELEMENTS (hidden on mobile) ===== */
.nav-brand {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 20px 16px 16px;
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-900);
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 4px;
    flex-shrink: 0;
    text-decoration: none;
}
.nav-brand-icon { font-size: 22px; line-height: 1; }
.nav-divider { display: none; flex: 1; min-height: 16px; }
/* especificidad mayor que .bottom-nav a para ocultar en mobile */
.bottom-nav a.nav-logout-link { display: none; }
.nav-logout-link {
    display: none;
    align-items: center;
    gap: 13px;
    text-decoration: none;
    color: #B91C1C;
    font-size: 14px;
    padding: 13px 18px;
    border-radius: 10px;
    margin: 2px 10px 12px;
    transition: background .15s;
    cursor: pointer;
}
.nav-logout-link:hover { background: #FEE2E2; }
.nav-logout-link i { font-size: 18px; }

/* ===== DETAIL TWO-COLUMN (mobile: stacked, desktop: grid) ===== */
.detail-layout { display: contents; }
.detail-left   { display: contents; }
.detail-right  { display: contents; }

/* ===== DESKTOP (≥ 768px) ===== */
@media (min-width: 768px) {

    /* --- SIDEBAR OFFSET: only when nav exists --- */
    body:has(.bottom-nav) {
        padding-bottom: 0;
        padding-left: 240px;
    }

    /* --- BOTTOM-NAV → LEFT SIDEBAR --- */
    .bottom-nav {
        position: fixed;
        left: 0; top: 0;
        width: 240px; max-width: 240px;
        height: 100vh;
        transform: none;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        border-top: none;
        border-right: 1px solid var(--gray-200);
        overflow-y: auto;
        padding: 0;
        gap: 0;
    }

    .nav-brand                    { display: flex; }
    .nav-divider                  { display: flex; }
    .bottom-nav a.nav-logout-link { display: flex; }

    .bottom-nav a {
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        padding: 13px 18px;
        font-size: 14px;
        gap: 13px;
        border-radius: 10px;
        margin: 2px 10px;
        flex: none;
    }
    .bottom-nav a.active { background: #FFF7ED; }
    .bottom-nav i        { font-size: 18px; }

    /* --- APP CONTAINER --- */
    body:has(.bottom-nav) .app-container {
        max-width: 100%;
        margin: 0;
    }

    /* Detail/form pages without sidebar: readable max-width */
    body:not(:has(.bottom-nav)) .app-container {
        max-width: 1024px;
        margin: 0 auto;
    }

    /* --- SECTIONS --- */
    .section        { padding: 24px 32px; }
    .greeting-header{ padding: 20px 32px; }
    .app-header     { padding: 14px 28px; }
    .filter-tabs    { padding: 10px 32px; }
    .alert-banner   { margin: 12px 32px; }
    .divider        { margin: 0 -32px; }

    /* Dividers inside two-column detail don't need negative margins */
    .detail-left .divider,
    .detail-right .divider { margin: 0; width: 100%; }

    /* --- CARD GRIDS (panel lists) --- */
    #lista, #reportesList {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    #lista .incident-card,
    #reportesList .incident-card { margin-bottom: 0; }

    /* --- MAP --- */
    .map-mini { height: 280px; }
    .map-full { height: calc(100vh - 60px); }
    .map-wrap { height: 100vh !important; }

    /* Map bottom card: keep in bottom-left of remaining area */
    .map-bottom-card {
        max-width: 380px;
    }

    /* --- DETAIL TWO-COLUMN --- */
    .detail-layout {
        display: grid;
        grid-template-columns: 42% 58%;
        min-height: calc(100vh - 57px);
        align-items: start;
    }
    .detail-left {
        display: block;
        border-right: 1px solid var(--gray-200);
        position: sticky;
        top: 57px;
        height: calc(100vh - 57px);
        overflow-y: auto;
    }
    .detail-right {
        display: block;
        overflow-y: auto;
    }

    /* Action bar inside detail: not fixed */
    .action-bar {
        position: static;
        border-top: 1px solid var(--gray-200);
        margin-top: 8px;
    }

    /* --- LOGIN: centered card (only on login page) --- */
    body:has(.login-container) {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100vh;
        background: var(--gray-100);
    }
    body:has(.login-container) .login-container {
        min-height: auto;
        border-radius: 20px;
        box-shadow: 0 8px 32px rgba(0,0,0,.10);
        padding: 48px 44px;
    }

    /* --- CATEGORY GRID (reportar page) --- */
    .category-grid    { gap: 12px; }
    .category-item    { padding: 16px 8px; font-size: 11px; }
    .category-item i  { font-size: 28px; }

    /* --- PROFILE --- */
    .profile-stats { gap: 48px; }

    /* --- ADMIN STATS: 5 cards in one row --- */
    .admin-stats-wrap {
        grid-template-columns: repeat(5, 1fr) !important;
    }
    .admin-stats-wrap .stat-card:first-child {
        grid-column: auto !important;
    }
}

