/* ================================================
   PANELS.CSS — Painel do Usuário, Bottom Sheet,
                FAB, Relatos Mobile e Bottom Sheet
                Nova Ocorrência
   Midnight Edition | MinhaRua App
   ================================================ */

/* ================= LOADING IA ================= */
#loading-ia {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 10000;
    background: rgba(18, 18, 18, 0.88);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
}

.lia-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; padding: 32px; }
.lia-icon  { font-size: 2.6rem; color: #39ff14; text-shadow: 0 0 20px rgba(57,255,20,0.8), 0 0 40px rgba(57,255,20,0.4); }
.lia-texto { margin: 0; font-size: 0.95rem; font-weight: 600; color: #39ff14; font-family: 'Inter', sans-serif; letter-spacing: 0.4px; text-shadow: 0 0 12px rgba(57,255,20,0.5); }

/* ================= FAB REPORTAR (MOBILE ONLY) ================= */
.fab-reportar {
    display: none;
    position: fixed;
    bottom: 90px;
    right: 22px;
    z-index: 1500;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    border: none;
    background: #39ff14;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(57,255,20,0.4);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

.fab-reportar .fab-icon-plus {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-58%, -58%);
    width: 34px; height: 34px; flex-shrink: 0;
}
.fab-reportar .fab-icon-cam {
    position: absolute;
    bottom: 9px; right: 9px;
    width: 20px; height: 20px; flex-shrink: 0;
}

.fab-reportar:hover,
.fab-reportar:focus-visible {
    transform: scale(1.1);
    box-shadow: 0 0 0 2px rgba(57,255,20,0.7), 0 0 22px 8px rgba(57,255,20,0.9), 0 0 50px 18px rgba(57,255,20,0.6), 0 0 90px 30px rgba(57,255,20,0.3), 0 4px 14px rgba(0,0,0,0.45);
    outline: none;
}
.fab-reportar:active { transform: scale(0.93); }
.fab-reportar.oculto { opacity: 0; pointer-events: none; transform: scale(0.6); }

@media (max-width: 768px) {
    .fab-reportar {
        display: flex !important;
        position: fixed !important;
        bottom: 90px !important;
        right: 20px !important;
        z-index: 9999 !important;
        transform-origin: center center;
    }
}

/* ================= FAB PERFIL ================= */
.fab-perfil {
    position: fixed !important;
    top: 80px; right: 20px;
    z-index: 9999 !important;
    background: white; color: #333;
    border: none; padding: 12px 24px; border-radius: 50px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    font-weight: bold; cursor: pointer;
    font-family: 'Inter', sans-serif;
    transition: transform 0.2s, background-color 0.2s;
    display: none;
}
.fab-perfil:hover { transform: scale(1.05); background-color: #f8f8f8; }

@media (max-width: 768px) { .fab-perfil { bottom: 20px; right: 20px; top: auto; padding: 14px 26px; font-size: 0.95rem; box-shadow: 0 6px 20px rgba(0,0,0,0.25); } }

/* ================= BOTTOM SHEET - NOVA OCORRÊNCIA ================= */
.bs-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 8000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.bs-overlay.aberto { opacity: 1; pointer-events: auto; }

.bottom-sheet {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 8001;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #121212;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 2px solid #39ff14;
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.6), 0 0 0 1px rgba(57,255,110,0.06);
    transform: translateY(110%);
    transition: transform 0.38s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
    padding-bottom: 80px;
}
.bottom-sheet.aberto { transform: translateY(0); }

.bs-handle-bar { width: 44px; height: 5px; background: #39ff14; border-radius: 10px; margin: 14px auto 0; }

.bs-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px 20px 8px;
    border-bottom: 1px solid rgba(57,255,110,0.15);
}
.bs-header h3 { margin: 0; font-size: 1rem; font-weight: 700; font-family: 'Outfit', sans-serif; color: #ffffff; display: flex; align-items: center; justify-content: center; gap: 8px; flex: 1; text-align: center; }

.bs-fechar {
    position: absolute; right: 15px; top: 50%; transform: translateY(-50%);
    background: rgba(255,255,255,0.1); border: none; color: #39ff14;
    font-size: 1.4rem; line-height: 1; width: 32px; height: 32px;
    border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s, color 0.2s; flex-shrink: 0;
}
.bs-fechar:hover { background: rgba(57,255,20,0.2); color: #39ff14; }

.bs-body {
    padding: 16px 16px 120px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.bs-body label,
.bs-body select,
.bs-body input,
.bs-body textarea,
.bs-body button { margin: 10px auto; display: block; text-align: center; }

.bs-body label { width: 100%; max-width: 400px; }
.bs-body select,
.bs-body input,
.bs-body textarea { width: calc(100% - 32px); max-width: 400px; }

.bs-body button[type="submit"],
.bs-body .btn-reportar { margin: 10px auto; display: block; width: calc(100% - 32px); max-width: 400px; text-align: center; }

@media (min-width: 769px) {
    .bottom-sheet,
    .bs-overlay { display: none !important; }
}

/* ================= BOTTOM SHEET NOVA OCORRÊNCIA (Novo Design Mobile) ================= */
@media (max-width: 768px) {
    .bs-overlay { display: none; position: fixed; width: 100%; height: 100%; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); z-index: 10001; opacity: 0; transition: opacity 0.35s ease; }
    .bs-overlay.ativo { display: block; opacity: 1; }
    .bs-content { position: fixed; bottom: 0; left: 0; width: 100%; height: 85vh; border-radius: 24px 24px 0 0; z-index: 10002; transform: translateY(100%); transition: transform 0.4s cubic-bezier(0.32,0.72,0,1); display: flex; flex-direction: column; background: rgba(18,20,26,0.95); backdrop-filter: blur(16px); border-top: 1px solid rgba(57,255,110,0.3); box-shadow: 0 -10px 40px rgba(0,0,0,0.6); color: #f1f5f9; }
    .bs-content.ativo { transform: translateY(0); }
    .bs-handle { width: 100%; height: 32px; display: flex; justify-content: center; align-items: center; cursor: grab; padding-top: 8px; }
    .bs-handle::after { content: ''; width: 48px; height: 5px; background: rgba(255,255,255,0.25); border-radius: 4px; }
    .bs-close { background: rgba(255,255,255,0.1); border: none; color: white; width: 34px; height: 34px; border-radius: 50%; font-size: 1.25rem; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: background 0.2s; }
    .bs-close:active { background: rgba(255,255,255,0.2); }
    .bs-body { padding: 24px 20px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 20px; }
    .bs-field { display: flex; flex-direction: column; gap: 8px; }
    .bs-field label { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.5px; color: #a3ff00; }
    .bs-field select, .bs-field textarea { width: 100%; font-size: 1rem; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.15); color: white; padding: 14px; border-radius: 12px; font-family: inherit; outline: none; transition: border 0.2s; }
    .bs-field select:focus, .bs-field textarea:focus { border-color: #39FF6E; box-shadow: 0 0 0 3px rgba(57,255,110,0.15); }
    .bs-field select option { background: #1e1e1e; color: white; }
    .bs-field .upload-area { border: 1px dashed rgba(255,255,255,0.25); border-radius: 14px; padding: 24px 16px; text-align: center; color: #e2e8f0; font-size: 0.95rem; cursor: pointer; background: rgba(255,255,255,0.02); transition: all 0.2s; font-weight: 600; }
    .bs-field .upload-area:active { background: rgba(255,255,255,0.05); }
    .bs-btn-reportar { margin-top: auto; width: 100%; padding: 16px; background: #a3ff00; color: #0b1a00; font-weight: 800; font-size: 1.1rem; border: none; border-radius: 14px; cursor: pointer; text-transform: uppercase; letter-spacing: 1px; box-shadow: 0 4px 16px rgba(163,255,0,0.3); transition: transform 0.2s; display: flex; justify-content: center; align-items: center; gap: 8px; margin-bottom: env(safe-area-inset-bottom); }
    .bs-btn-reportar:active { transform: scale(0.96); background: #8ce600; }
    .bs-header { display: flex; justify-content: space-between; align-items: center; padding: 0 20px 15px; border-bottom: 1px solid rgba(255,255,255,0.1); }
    .bs-header h3 { margin: 0; font-size: 1.25rem; font-weight: 700; display: flex; align-items: center; gap: 8px; color: #fff; }
    .bs-header .neon-pin-icon { color: #fe346e; font-size: 1.2rem; filter: drop-shadow(0 0 6px rgba(254,52,110,0.6)); }
}

/* ================= PAINEL DO USUÁRIO (GAVETA LATERAL) ================= */
#painel-usuario {
    position: fixed;
    top: 0; right: 0;
    width: 380px; height: 100%;
    background: #121212; color: #ffffff;
    border-left: 1px solid #1a1a1a;
    box-shadow: -5px 0 25px rgba(0,0,0,0.15);
    z-index: 10000;
    display: flex; flex-direction: column;
    padding: 0; box-sizing: border-box;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
}

.painel-fechado { transform: translateX(110%); }
.painel-aberto  { transform: translateX(0); }

/* Header hero */
.painel-header-hero {
    background: linear-gradient(180deg, #1a1a1a 0%, #121212 100%);
    color: white; padding: 30px 25px;
    position: relative; border-radius: 0; margin: 0; flex-shrink: 0;
}

.btn-fechar-absoluto {
    position: absolute; top: 15px; right: 15px;
    background: rgba(255,255,255,0.15); border: none; color: white;
    width: 32px; height: 32px; border-radius: 50%; cursor: pointer;
    font-size: 1.5rem; line-height: 1;
    display: flex; align-items: center; justify-content: center; transition: all 0.2s;
}
.btn-fechar-absoluto:hover { background: rgba(255,255,255,0.25); transform: scale(1.1); }

.perfil-flex { display: flex; align-items: center; gap: 15px; }
.avatar-simple { width: 60px; height: 60px; background: #1a1a1a; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 2rem; border: 3px solid #39ff14; flex-shrink: 0; }
.perfil-dados small { font-size: 0.8rem; opacity: 0.9; color: rgba(255,255,255,0.85); }

/* Mini stats */
.painel-stats-mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding: 20px 25px; background: #121212; border-bottom: 1px solid #1a1a1a; }
.mini-stat { background: #1a1a1a; padding: 15px 10px; border-radius: 12px; text-align: center; border: 1px solid #2a2a2a; transition: transform 0.2s, box-shadow 0.2s; }
.mini-stat:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(57,255,20,0.15); }
.mini-stat span  { display: block; font-size: 1.6rem; font-weight: 800; color: #39ff14; text-shadow: 0 0 10px rgba(57,255,20,0.5); margin-bottom: 4px; line-height: 1; }
.mini-stat small { font-size: 0.7rem; color: #a0a0a0; text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; }

/* Lista ocorrências */
.lista-ocorrencias { flex: 1; overflow-y: auto; padding: 0 25px 20px 25px; }
.lista-ocorrencias h4 { position: sticky; top: 0; background: white; padding: 15px 0 10px 0; margin: 0 0 15px 0; z-index: 10; }

.lista-timeline { list-style: none; padding: 0; margin: 0; }
.loading-item  { text-align: center; padding: 30px; color: #94a3b8; font-style: italic; }

.item-timeline { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 16px; margin-bottom: 12px; transition: all 0.2s; }
.item-timeline:hover { border-color: #cbd5e1; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }

.timeline-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-weight: 600; color: #334155; font-size: 0.9rem; }
.timeline-header small { color: #94a3b8; font-weight: 400; font-size: 0.75rem; }

/* Barra de status */
.status-track { display: flex; justify-content: space-between; align-items: center; position: relative; margin: 12px 0; padding: 0 10px; }
.status-track::before { content: ''; position: absolute; top: 50%; left: 10px; right: 10px; height: 2px; background: #e2e8f0; z-index: 0; transform: translateY(-50%); }
.step { background: white; z-index: 1; width: 32px; height: 32px; border-radius: 50%; border: 2px solid #cbd5e1; display: flex; align-items: center; justify-content: center; font-size: 0.9rem; transition: all 0.3s; position: relative; }
.step.active { border-color: #0ea5e9; background: #e0f2fe; color: #0ea5e9; transform: scale(1.15); box-shadow: 0 0 0 4px rgba(14,165,233,0.1); }
.step.done   { border-color: #22c55e; background: #22c55e; color: white; transform: scale(1.1); }
.timeline-status-text { text-align: center; font-size: 0.75rem; color: #64748b; margin-top: 8px; font-weight: 500; }

/* Rodapé do painel */
.painel-footer { border-top: 1px solid #e2e8f0; padding: 20px 25px; background: #f8fafc; flex-shrink: 0; }
#painel-usuario .btn-logout { width: 100%; padding: 12px; background: transparent; color: #475569; border: 1px solid #475569; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 0.9rem; transition: all 0.2s; }
#painel-usuario .btn-logout:hover { background: transparent; color: #ffffff; border-color: #475569; }

/* MOBILE — Painel usuario em tela cheia */
@media (max-width: 768px) {
    #painel-usuario { width: 100% !important; height: 100vh !important; height: 100dvh !important; top: 0; right: 0; border-radius: 0; overflow-y: auto; overflow-x: hidden; z-index: 9999; padding: 0; padding-bottom: env(safe-area-inset-bottom); }
    #painel-usuario.painel-fechado { transform: translateX(100%) !important; }
    #painel-usuario.painel-aberto  { transform: translateX(0) !important; }
    .painel-header-hero { padding-top: max(50px, env(safe-area-inset-top, 20px)); padding-bottom: 25px; padding-left: 20px; padding-right: 20px; margin: 0; border-radius: 0 0 24px 24px; }
    .btn-fechar-absoluto { top: max(15px, env(safe-area-inset-top, 10px)); right: 15px; width: 44px; height: 44px; font-size: 1.8rem; background: rgba(0,0,0,0.25); backdrop-filter: blur(10px); }
    .btn-fechar-absoluto:active { transform: scale(0.95); background: rgba(0,0,0,0.35); }
    .avatar-simple { width: 55px; height: 55px; font-size: 1.8rem; }
    .perfil-dados h3 { font-size: 1.15rem; }
    .perfil-dados small { font-size: 0.75rem; }
    .painel-stats-mini { grid-template-columns: repeat(3, 1fr); gap: 10px; padding: 18px 20px; }
    .mini-stat { padding: 14px 10px; border-radius: 10px; }
    .mini-stat span  { font-size: 1.5rem; }
    .mini-stat small { font-size: 0.65rem; }
    .lista-ocorrencias { padding: 0 20px 80px 20px; }
    .lista-ocorrencias h4 { padding: 10px 0 6px 0; font-size: 0.85rem; }
    
    /* Cards Compactos */
    .item-timeline { 
        padding: 12px !important; 
        margin-bottom: 10px !important; 
        border-radius: 12px !important; 
        min-height: auto !important; 
    }
    .item-timeline:active { background: #f1f5f9; transform: scale(0.98); }
    .timeline-header { font-size: 0.85rem !important; margin-bottom: 8px !important; }
    .status-track { padding: 0 10px !important; margin: 10px 0 !important; }
    .step { width: 30px !important; height: 30px !important; font-size: 0.85rem !important; }
    .step.active { transform: scale(1.15); }
    .timeline-status-text { font-size: 0.75rem !important; margin-top: 6px !important; }

    /* Rodapé Flexível */
    .painel-footer { 
        display: flex !important;
        gap: 10px !important;
        align-items: center !important;
        padding: 16px 20px !important; 
        padding-bottom: max(16px, env(safe-area-inset-bottom, 16px)) !important; 
        background: #121212 !important; 
        border-top: 1px solid rgba(255,255,255,0.1) !important; 
        position: sticky; bottom: 0; z-index: 10; 
    }

    .btn-tema-switch {
        flex: 1;
        padding: 12px 10px;
        border-radius: 10px;
        border: 1px solid rgba(255,255,255,0.15);
        background: rgba(255,255,255,0.05);
        color: #e2e8f0;
        font-size: 0.85rem;
        font-weight: 600;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        cursor: pointer;
        white-space: nowrap;
    }

    #painel-usuario .btn-logout { 
        flex: 1.5;
        padding: 12px; 
        font-size: 0.9rem; 
        border: 1px solid #475569;
        border-radius: 10px; 
        margin: 0 !important;
        -webkit-tap-highlight-color: transparent; 
    }
    #painel-usuario .btn-logout:active { transform: scale(0.98); background-color: rgba(255,255,255,0.1); }
    
    #painel-usuario::-webkit-scrollbar { width: 6px; }
    #painel-usuario::-webkit-scrollbar-track { background: #f1f5f9; }
    #painel-usuario::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
    .loading-item { padding: 40px 20px; font-size: 0.9rem; }
}

@media (max-width: 374px) {
    .painel-header-hero { padding-left: 15px; padding-right: 15px; }
    .perfil-flex { gap: 12px; }
    .avatar-simple { width: 50px; height: 50px; font-size: 1.6rem; }
    .perfil-dados h3 { font-size: 1rem; }
    .mini-stat span { font-size: 1.3rem; }
    .lista-ocorrencias { padding: 0 15px 100px 15px; }
}

/* ================= PAINEL RELATOS (Mobile Full-Screen) ================= */
.painel-relatos { display: none; position: fixed; inset: 0; z-index: 9990; background: #121212; flex-direction: column; overflow: hidden; }
.painel-relatos.aberto { display: flex; }

.pr-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 12px; border-bottom: 1px solid rgba(57,255,20,0.18); background: #121212; flex-shrink: 0; padding-top: calc(16px + env(safe-area-inset-top)); }
.pr-titulo { margin: 0; font-size: 1.05rem; font-weight: 700; color: #fff; font-family: 'Inter', sans-serif; letter-spacing: 0.3px; }
.pr-fechar { background: rgba(255,255,255,0.08); border: none; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: rgba(255,255,255,0.65); transition: background 0.2s; }
.pr-fechar svg { width: 18px; height: 18px; }
.pr-fechar:hover { background: rgba(239,68,68,0.25); color: #ff8080; }
.pr-lista { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 14px; padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
.pr-loading { display: flex; align-items: center; justify-content: center; gap: 10px; color: rgba(255,255,255,0.4); font-size: 0.9rem; padding: 40px 0; }
@keyframes pr-spin { to { transform: rotate(360deg); } }
.pr-spin { animation: pr-spin 1s linear infinite; }

.pr-card { background: #2a2a2d; border-radius: 14px; padding: 14px 16px; margin-bottom: 10px; display: flex; align-items: flex-start; gap: 12px; cursor: pointer; border: 1px solid rgba(255,255,255,0.06); transition: background 0.18s, transform 0.15s; -webkit-tap-highlight-color: transparent; }
.pr-card:active { background: #333336; transform: scale(0.98); }
.pr-card-icone { font-size: 1.5rem; flex-shrink: 0; line-height: 1; margin-top: 2px; }
.pr-card-corpo { flex: 1; min-width: 0; }
.pr-card-titulo { font-size: 0.9rem; font-weight: 700; color: rgba(255,255,255,0.9); margin: 0 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-card-desc { font-size: 0.78rem; color: rgba(255,255,255,0.45); margin: 0 0 8px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pr-card-footer { display: flex; align-items: center; justify-content: space-between; }
.pr-card-tempo  { font-size: 0.7rem; color: rgba(255,255,255,0.3); }
.pr-card-apoios { display: flex; align-items: center; gap: 5px; font-size: 0.78rem; font-weight: 700; color: #39ff14; }
.pr-card-apoios i { font-size: 0.82rem; }

@media (min-width: 769px) { .painel-relatos { display: none !important; } }

/* ================= TEMA CLARO - MOBILE ONLY ================= */
@media (max-width: 768px) {
    [data-tema="claro"] #painel-usuario {
        background-color: #ffffff;
        color: #111827;
    }

    [data-tema="claro"] .painel-header-hero {
        background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
        color: #111827;
        border-bottom: 1px solid #e2e8f0;
    }

    [data-tema="claro"] .avatar-simple {
        background-color: #f1f5f9;
        border-color: #16a34a;
    }

    [data-tema="claro"] .painel-stats-mini {
        background-color: #f8fafc;
        border-bottom: 1px solid #e2e8f0;
    }

    [data-tema="claro"] .mini-stat {
        background-color: #ffffff;
        border: 1px solid #e2e8f0;
    }

    [data-tema="claro"] .mini-stat span {
        color: #16a34a;
        text-shadow: none;
    }

    [data-tema="claro"] .mini-stat small {
        color: #64748b;
    }

    [data-tema="claro"] .lista-ocorrencias h4 {
        background-color: #ffffff;
        color: #111827;
        border-bottom: 1px solid #e2e8f0;
    }

    [data-tema="claro"] .painel-footer {
        background-color: #f8fafc !important;
        border-top: 1px solid #e2e8f0 !important;
    }

    [data-tema="claro"] .btn-tema-switch {
        background-color: #ffffff;
        border-color: #e2e8f0;
        color: #475569;
    }

    [data-tema="claro"] #painel-usuario .btn-logout {
        color: #475569;
        border-color: #cbd5e1;
    }

    [data-tema="claro"] #painel-usuario .btn-logout:active {
        background-color: #f1f5f9;
    }
}
