/* ================================================
   MODALS.CSS — Modais, Comentários, Aviso,
                PWA, Transparência e Modal Sobre
   Midnight Edition | MinhaRua App
   ================================================ */

/* ================= MODAL OVERLAY GENÉRICO ================= */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: var(--z-modal);
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    padding: 20px;
}

#painel-admin-modal.modal-overlay {
    background: rgba(0, 0, 0, 0.85);
    z-index: 20000;
    backdrop-filter: blur(5px);
}

.modal-box {
    background: white;
    width: 90%;
    max-width: 600px;
    padding: 25px;
    border-radius: var(--border-radius-lg);
    animation: modalSlideUp 0.3s ease-out;
    box-shadow: var(--shadow-xl);
    max-height: 90vh;
    overflow-y: auto;
}

@keyframes modalSlideUp {
    from { transform: translateY(40px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

/* Modal de estatísticas compacto */
#modal-estatisticas .modal-box { max-width: 400px; padding: 15px; max-height: 95vh; }
#modal-estatisticas .btn-fechar {
    width: auto; min-width: 120px; display: block; margin: 15px auto 0 auto;
    padding: 8px 20px; font-size: 0.85rem;
    background-color: #f1f5f9; color: #334155; border: 1px solid #ddd;
    border-radius: 6px; cursor: pointer; transition: background 0.2s;
}
#modal-estatisticas .btn-fechar:hover { background-color: #e2e8f0; border-color: #cbd5e1; }

/* ================= GRID DE ESTATÍSTICAS ================= */
.stats-grid-modal {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-top: 10px;
    width: 100%;
}
.stats-grid-modal .stat-card {
    background: #f8f9fa; padding: 5px; border-radius: 8px; border: 1px solid #eee;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 65px; transition: transform 0.2s;
}
.stats-grid-modal .stat-value { font-size: 1.1rem; font-weight: 800; color: #1F2937; margin: 2px 0; line-height: 1; }
.stats-grid-modal .stat-name  { font-size: 0.6rem; color: #6B7280; font-weight: 700; text-transform: uppercase; white-space: nowrap; }
.stats-grid-modal .stat-icon  { font-size: 1.2rem; margin-bottom: 2px; }
.stats-grid-modal .stat-card.total-card { grid-column: span 2; background: #e0f2fe; border-color: #bae6fd; flex-direction: row; gap: 10px; min-height: 45px; }
.stats-grid-modal .stat-card.total-card .stat-value { font-size: 1.3rem; color: #0284c7; }
.stats-grid-modal .stat-card.total-card .stat-name  { font-size: 0.7rem; color: #0369a1; }
.stats-grid-modal .stat-card.total-card .stat-icon  { font-size: 1.4rem; }

/* ================= BOTÃO FECHAR MODAL GENÉRICO ================= */
.btn-fechar {
    display: flex; justify-content: center; align-items: center;
    width: 100%; margin-top: 25px; padding: 14px;
    background-color: transparent; color: #64748b;
    border: 1px solid #e2e8f0; border-radius: 12px;
    font-weight: 600; font-size: 0.95rem; cursor: pointer; transition: all 0.2s ease;
}
.btn-fechar:hover { background-color: #f8fafc; color: #334155; border-color: #cbd5e1; transform: translateY(-2px); box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05); }
.btn-fechar:active { transform: translateY(0); }

/* ================= MODAL DE COMENTÁRIOS ================= */
.modal-comentarios { max-width: 500px; max-height: 80vh; display: flex; flex-direction: column; }
.comentarios-body { display: flex; flex-direction: column; gap: 20px; flex: 1; overflow: hidden; }
.lista-comentarios { flex: 1; overflow-y: auto; padding: 10px; background: #f8fafc; border-radius: 8px; max-height: 400px; }
.comentario-item { background: white; padding: 12px; border-radius: 8px; margin-bottom: 10px; border-left: 3px solid #3b82f6; }
.comentario-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.comentario-autor { font-weight: 600; color: #1e293b; font-size: 0.9rem; }
.comentario-data  { font-size: 0.75rem; color: #94a3b8; }
.comentario-texto { color: #475569; font-size: 0.9rem; line-height: 1.5; word-wrap: break-word; }
.comentario-vazio { text-align: center; padding: 40px 20px; color: #94a3b8; }
.comentario-vazio i { font-size: 3rem; display: block; margin-bottom: 10px; opacity: 0.5; }
.comentario-vazio p { margin: 5px 0; font-size: 0.9rem; }
.comentario-form { border-top: 1px solid #e2e8f0; padding-top: 15px; }
.comentario-form textarea { width: 100%; padding: 12px; border: 1px solid #e2e8f0; border-radius: 8px; font-family: inherit; font-size: 0.9rem; resize: vertical; transition: border-color 0.2s; }
.comentario-form textarea:focus { outline: none; border-color: #3b82f6; }
.form-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.form-footer small { color: #94a3b8; font-size: 0.75rem; }
.btn-enviar-comentario { display: flex; align-items: center; gap: 6px; padding: 10px 20px; background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); color: white; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.btn-enviar-comentario:hover { transform: translateY(-2px); }
.btn-enviar-comentario:active { transform: translateY(0); }

/* Modal de comentários (versão nova) */
.modal-content {
    background: white; width: 90%; max-width: 500px;
    border-radius: 15px; padding: 20px; display: flex;
    flex-direction: column; max-height: 80vh; box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}
@media (min-width: 768px) { .modal-content { height: 90vh; max-height: 90vh; } }

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; padding-bottom: 15px; border-bottom: 2px solid #e2e8f0; }
.modal-header h3 { margin: 0; font-size: 1.3rem; color: #1e293b; }

.close-btn {
    background: none; border: none; font-size: 2rem; color: #94a3b8;
    cursor: pointer; line-height: 1; padding: 0; width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center; border-radius: 50%; transition: all 0.2s;
}
.close-btn:hover { background: #f1f5f9; color: #ef4444; }

.comments-list { flex: 1; overflow-y: auto; margin-bottom: 15px; padding-right: 5px; }
.comment-item { border-bottom: 1px solid #e2e8f0; padding: 12px 0; }
.comment-item:last-child { border-bottom: none; }
.comment-item strong { color: #1e293b; font-size: 0.9rem; display: block; margin-bottom: 5px; }
.comment-item small  { color: #94a3b8; font-size: 0.75rem; margin-left: 5px; }
.comment-item p      { margin: 5px 0 0 0; color: #475569; font-size: 0.9rem; line-height: 1.5; word-wrap: break-word; }

.comment-input-area { border-top: 1px solid #e2e8f0; padding-top: 15px; }
.comment-input-area textarea { width: 100%; border-radius: 8px; border: 1px solid #cbd5e1; padding: 12px; font-family: inherit; font-size: 0.9rem; resize: vertical; min-height: 80px; transition: border-color 0.2s; }
.comment-input-area textarea:focus { outline: none; border-color: #3b82f6; }

.input-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.input-footer small { color: #94a3b8; font-size: 0.75rem; }

.send-btn { display: flex; align-items: center; gap: 6px; padding: 10px 20px; background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%); color: white; border: none; border-radius: 8px; font-weight: 600; cursor: pointer; transition: all 0.2s; font-size: 0.9rem; }
.send-btn:hover { transform: translateY(-2px); }
.send-btn:active { transform: translateY(0); }
.send-btn i { font-size: 0.9rem; }

@keyframes slideIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

.comments-list::-webkit-scrollbar { width: 6px; }
.comments-list::-webkit-scrollbar-track  { background: #f1f5f9; border-radius: 10px; }
.comments-list::-webkit-scrollbar-thumb  { background: #cbd5e1; border-radius: 10px; }
.comments-list::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ================= TABS DO PAINEL ================= */
.painel-tabs { display: flex; gap: 8px; padding: 15px 20px 0; border-bottom: 2px solid #e2e8f0; background: #f8fafc; }
.tab-btn { flex: 1; padding: 12px 16px; background: transparent; border: none; border-bottom: 3px solid transparent; color: #64748b; font-weight: 600; font-size: 0.9rem; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center; gap: 6px; }
.tab-btn:hover { color: #334155; background: rgba(59,130,246,0.05); }
.tab-btn.active { color: #3b82f6; border-bottom-color: #3b82f6; background: white; }
.tab-content { display: none; padding: 20px; animation: fadeInTab 0.3s ease; }
.tab-content.active { display: block; }
@keyframes fadeInTab { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.tab-content .lista-timeline { margin: 0; padding: 0; }

/* ================= MODAL SOBRE - MIDNIGHT NEON ================= */
.modal-sobre-midnight {
    background: #121212 !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 2px solid #39ff14 !important;
    box-shadow: 0 0 30px rgba(57,255,20,0.3), 0 8px 32px rgba(0,0,0,0.8) !important;
    color: #ffffff !important;
}
.modal-sobre-midnight h2,
.modal-sobre-midnight h3  { color: #39ff14 !important; text-shadow: 0 0 10px rgba(57,255,20,0.5); }
.modal-sobre-midnight p,
.modal-sobre-midnight span,
.modal-sobre-midnight li  { color: #ffffff !important; }

.btn-fechar-midnight { width: 100%; padding: 12px 24px; background: transparent !important; color: #39ff14 !important; border: 2px solid #39ff14 !important; border-radius: 8px; font-size: 0.9rem; font-weight: 600; cursor: pointer; transition: all 0.3s ease; text-transform: uppercase; letter-spacing: 0.5px; }
.btn-fechar-midnight:hover  { background: rgba(57,255,20,0.1) !important; box-shadow: 0 0 20px rgba(57,255,20,0.4); transform: translateY(-2px); }
.btn-fechar-midnight:active { transform: translateY(0); }

/* ================= MODAL DE AVISO DE OTIMIZAÇÃO ================= */
.modal-aviso-box {
    max-width: 500px; width: 90%; height: auto !important; min-height: auto !important;
    text-align: center; padding: 40px 30px; border-radius: 20px;
    background: rgba(18,20,26,0.90); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(163,255,0,0.2); box-shadow: 0 16px 40px rgba(0,0,0,0.6);
}
.aviso-icone { font-size: 3.5rem; margin-bottom: 20px; }
.aviso-titulo { color: #a3ff00; font-size: 1.6rem; font-weight: 700; margin-bottom: 15px; }
.aviso-texto  { color: #e2e8f0; font-size: 1.05rem; line-height: 1.6; margin-bottom: 15px; }
.aviso-link   { color: #39ff14; font-weight: 600; text-decoration: underline; }
.aviso-link:hover { color: #a3ff00; }
.btn-aviso-entendi { background-color: #a3ff00; color: #0b1a00; font-weight: 800; font-size: 1.1rem; padding: 14px 28px; border: none; border-radius: 12px; cursor: pointer; width: 100%; margin-top: 10px; transition: transform 0.2s, background 0.3s; box-shadow: 0 4px 15px rgba(163,255,0,0.3); }
.btn-aviso-entendi:hover  { background-color: #8ce600; transform: translateY(-2px); }
.btn-aviso-entendi:active { transform: translateY(0); }
@media (max-width: 600px) { .modal-aviso-box { padding: 30px 20px; max-width: 95%; } .aviso-titulo { font-size: 1.4rem; } .aviso-texto { font-size: 0.95rem; } .btn-aviso-entendi { padding: 12px 20px; } }

/* ================= MODAL PWA MOBILE ================= */
.modal-pwa-mobile { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); z-index: 10000; align-items: flex-end; justify-content: center; }
.modal-pwa-mobile.ativo { display: flex; }

.pwa-sheet {
    background: #121212; border-top: 3px solid #39ff14;
    border-radius: 20px 20px 0 0; padding: 30px 20px 40px;
    width: 100%; max-width: 500px; box-shadow: 0 -4px 20px rgba(57,255,20,0.3);
    animation: slideUp 0.3s ease-out;
}
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.pwa-titulo  { color: #39ff14; font-size: 1.4rem; font-weight: 700; margin-bottom: 25px; text-align: center; }
.pwa-acoes   { display: flex; flex-direction: column; gap: 12px; }
.pwa-btn-adicionar { background: #39ff14; color: #000; border: none; border-radius: 8px; padding: 14px 20px; font-size: 1rem; font-weight: 700; cursor: pointer; transition: all 0.2s ease; text-transform: uppercase; }
.pwa-btn-adicionar:hover { background: #2ecc11; }
.pwa-btn-agora-nao  { background: transparent; color: #888; border: none; padding: 12px 20px; font-size: 0.95rem; cursor: pointer; transition: color 0.2s ease; text-transform: uppercase; }
.pwa-btn-agora-nao:hover { color: #aaa; }

/* ================= PÁGINA DE TRANSPARÊNCIA ================= */
.transparencia-page { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); overflow-y: auto; }
.transparencia-container { max-width: 1200px; margin: 0 auto; padding: 40px 20px; min-height: calc(100vh - 70px); }
.dashboard-header { text-align: center; margin-bottom: 40px; color: white; }
.dashboard-header h2 { font-size: 2.5rem; font-weight: 800; margin-bottom: 10px; text-shadow: 0 2px 10px rgba(0,0,0,0.2); letter-spacing: -0.5px; }
.dashboard-header p  { font-size: 1.1rem; opacity: 0.95; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-bottom: 40px; }
.stat-card { background: white; padding: 30px; border-radius: var(--border-radius-lg); box-shadow: 0 10px 30px rgba(0,0,0,0.15); text-align: center; transition: transform 0.3s ease; border-left: 5px solid var(--primary-blue); }
.stat-card:hover { transform: translateY(-5px); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.success { border-left-color: var(--success); }
.stat-card .label { display: block; font-size: 0.9rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.stat-card h3 { font-size: 3rem; font-weight: 800; color: var(--text-dark); margin: 0; line-height: 1; }
.loading-spinner { display: inline-block; font-size: 1rem; color: var(--text-muted); animation: pulse 1.5s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.charts-section { display: grid; grid-template-columns: repeat(auto-fit, minmax(400px, 1fr)); gap: 30px; margin-bottom: 40px; }
.chart-container { background: white; padding: 30px; border-radius: var(--border-radius-lg); box-shadow: 0 10px 30px rgba(0,0,0,0.15); transition: transform 0.3s ease; }
.chart-container:hover { transform: translateY(-3px); }
.chart-container h3 { margin: 0 0 20px 0; color: var(--primary-blue); font-size: 1.3rem; font-weight: 700; text-align: center; padding-bottom: 15px; border-bottom: 2px solid #f0f0f0; }
.chart-wrapper { position: relative; height: 300px; display: flex; align-items: center; justify-content: center; }
.chart-wrapper canvas { max-height: 100%; }
.action-footer { text-align: center; margin-top: 50px; padding: 30px; background: rgba(255,255,255,0.1); border-radius: var(--border-radius-lg); backdrop-filter: blur(10px); }
.btn-download { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; border: none; padding: 16px 40px; border-radius: 50px; font-size: 1.1rem; font-weight: 700; cursor: pointer; box-shadow: 0 8px 20px rgba(102,126,234,0.4); transition: all 0.3s ease; display: inline-flex; align-items: center; gap: 10px; }
.btn-download:hover  { transform: translateY(-3px); }
.btn-download:active { transform: translateY(-1px); }
.last-update { margin-top: 20px; color: white; font-size: 0.9rem; opacity: 0.9; }
.last-update time { font-weight: 600; }
@media (max-width: 768px) { .transparencia-container { padding: 20px 15px; } .dashboard-header h2 { font-size: 1.8rem; } .stats-grid { grid-template-columns: 1fr; gap: 15px; } .stat-card { padding: 20px; } .stat-card h3 { font-size: 2.5rem; } .charts-section { grid-template-columns: 1fr; gap: 20px; } .chart-container { padding: 20px; } .chart-wrapper { height: 250px; } .btn-download { padding: 14px 30px; font-size: 1rem; width: 100%; } }
@media (max-width: 480px) { .dashboard-header h2 { font-size: 1.5rem; } .stat-card h3 { font-size: 2rem; } .chart-container h3 { font-size: 1.1rem; } .chart-wrapper { height: 220px; } }

/* ================= MODAL LEGAL (TERMOS / PRIVACIDADE) ================= */
.modal-legal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 20000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    padding: 20px;
}

.modal-legal-box {
    background: #ffffff;
    color: #1e293b;
    width: 100%;
    max-width: 800px;
    max-height: 85vh;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
    animation: modalSlideUp 0.3s ease-out;
}

/* Suporte ao tema escuro para o modal legal */
[data-tema="escuro"] .modal-legal-box {
    background: #111827;
    color: #f1f5f9;
    border: 1px solid rgba(255,255,255,0.1);
}

.modal-legal-header {
    padding: 20px 25px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: inherit;
}

[data-tema="escuro"] .modal-legal-header {
    border-bottom-color: rgba(255,255,255,0.1);
}

.modal-legal-titulo {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: inherit;
}

.modal-legal-fechar {
    background: transparent;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #94a3b8;
    line-height: 1;
    transition: color 0.2s, transform 0.2s;
}

.modal-legal-fechar:hover {
    color: #ef4444;
    transform: scale(1.1);
}

.modal-legal-body {
    padding: 25px;
    overflow-y: auto;
    line-height: 1.6;
    font-size: 0.95rem;
}

/* Estilização básica do conteúdo legal injetado */
.modal-legal-body h1 { font-size: 1.5rem; margin-bottom: 15px; }
.modal-legal-body h2 { font-size: 1.25rem; margin-top: 25px; margin-bottom: 10px; color: var(--primary-blue); }
.modal-legal-body h3 { font-size: 1.1rem; margin-top: 20px; margin-bottom: 8px; }
.modal-legal-body p { margin-bottom: 15px; }
.modal-legal-body ul, .modal-legal-body ol { margin-bottom: 15px; padding-left: 20px; }
.modal-legal-body li { margin-bottom: 8px; }

[data-tema="escuro"] .modal-legal-body h2 { color: #39ff14; }

.modal-legal-body .last-update { font-size: 0.85rem; color: #64748b; font-style: italic; margin-bottom: 20px; }
.modal-legal-body .highlight { background: #f8fafc; padding: 15px; border-radius: 8px; border-left: 4px solid var(--primary-blue); margin-bottom: 20px; }
.modal-legal-body .warning { background: #fff7ed; padding: 15px; border-radius: 8px; border-left: 4px solid #f97316; margin-bottom: 20px; }

[data-tema="escuro"] .modal-legal-body .highlight { background: rgba(57, 255, 20, 0.05); border-left-color: #39ff14; }
[data-tema="escuro"] .modal-legal-body .warning { background: rgba(249, 115, 22, 0.1); border-left-color: #f97316; }
