/* ==========================================================================
   DESIGN SYSTEM - DASHBOARD ELEITORAL (DARK / GLASSMORPHISM)
   ========================================================================== */

/* Variáveis de Cores (HSL Harmonioso) e Estilos */
:root {
    --bg-main: hsl(222, 47%, 7%);
    --bg-sidebar: hsl(222, 47%, 4%);
    --bg-card: rgba(17, 24, 39, 0.7);
    --bg-card-hover: rgba(30, 41, 59, 0.85);

    --border-color: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(59, 130, 246, 0.4);

    --primary: hsl(217, 91%, 60%);
    --primary-glow: rgba(59, 130, 246, 0.15);
    --secondary: hsl(142, 71%, 45%);
    --accent: hsl(263, 90%, 51%);
    --accent-glow: rgba(124, 58, 237, 0.2);
    --danger: hsl(350, 89%, 60%);
    --warning: hsl(45, 93%, 47%);

    --text-primary: hsl(210, 40%, 98%);
    --text-secondary: hsl(215, 20%, 75%);
    --text-muted: hsl(215, 15%, 50%);

    --font-family: 'Outfit', sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;

    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 15px rgba(59, 130, 246, 0.3);
}

/* Reset Geral e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* Scrollbar Customizada */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-sidebar);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ==========================================================================
   TELA DE LOGIN
   ========================================================================== */
.login-body {
    background: radial-gradient(circle at 10% 20%, hsl(222, 47%, 10%) 0%, hsl(222, 47%, 4%) 90%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-wrapper {
    width: 100%;
    max-width: 440px;
    animation: fadeIn 0.6s ease-out;
}

.login-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, var(--accent-glow) 0%, transparent 60%);
    pointer-events: none;
    z-index: 0;
}

.login-header {
    position: relative;
    z-index: 1;
    text-align: center;
    margin-bottom: 30px;
}

.login-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    margin-bottom: 20px;
    box-shadow: 0 8px 16px rgba(59, 130, 246, 0.3);
}

.login-header h1 {
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 8px;
    background: linear-gradient(to right, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-header p {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* Erros de Login */
.error-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 24px;
    color: hsl(350, 89%, 75%);
    font-size: 0.9rem;
    animation: shake 0.4s ease;
    position: relative;
    z-index: 1;
}

.error-banner svg {
    flex-shrink: 0;
    stroke: var(--danger);
}

/* Formulário de Login */
.login-form {
    position: relative;
    z-index: 1;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    pointer-events: none;
    transition: var(--transition-fast);
}

.input-container input {
    width: 100%;
    padding: 14px 14px 14px 44px;
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: #fff;
    font-family: var(--font-family);
    font-size: 0.95rem;
    transition: var(--transition-smooth);
}

.input-container input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(15, 23, 42, 0.85);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.input-container input:focus+.input-icon {
    color: var(--primary);
}

.btn-submit {
    width: 100%;
    padding: 14px;
    margin-top: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary));
    border: none;
    border-radius: 12px;
    color: #fff;
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.btn-submit:hover {
    background: linear-gradient(135deg, hsl(217, 91%, 65%), hsl(217, 91%, 60%));
    box-shadow: var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-submit:active {
    transform: translateY(0);
}


/* ==========================================================================
   LAYOUT DO DASHBOARD
   ========================================================================== */
.dashboard-body {
    background-color: var(--bg-main);
    min-height: 100vh;
}

.dashboard-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header Principal */
.main-header {
    height: 70px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: relative;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.2);
}

.header-brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    background: linear-gradient(to right, #fff, var(--text-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-profile {
    display: flex;
    align-items: center;
    gap: 20px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 6px 16px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.user-badge svg {
    color: var(--primary);
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 8px;
    padding: 8px 16px;
    color: hsl(350, 89%, 70%);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition-smooth);
}

.btn-logout:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

/* Área Principal Dividida (Sidebar + Main Content) */
.dashboard-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* BARRA LATERAL (SIDEBAR) */
.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-header h2 {
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.sidebar-header p {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Acordeon / Grupos de Cidades no Sidebar */
.city-group {
    margin-bottom: 16px;
}

.city-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 6px;
    margin-bottom: 6px;
}

.city-badge {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
}

.zone-list {
    list-style: none;
    padding-left: 6px;
}

.zone-item {
    margin-bottom: 4px;
}

.btn-zone {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 10px 14px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 8px;
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
    transition: var(--transition-fast);
}

.btn-zone:hover {
    background: rgba(255, 255, 255, 0.04);
    color: #fff;
}

.btn-zone.active {
    background: var(--primary-glow);
    border-color: rgba(59, 130, 246, 0.3);
    color: var(--primary);
}

.btn-zone .zone-number {
    font-size: 0.9rem;
    font-weight: 600;
}

.btn-zone .zone-summary {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    margin-top: 2px;
}

.btn-zone.active .zone-summary {
    color: var(--text-secondary);
}

/* Loaders e Spinners */
.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 0;
    color: var(--text-muted);
    gap: 12px;
}

.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ==========================================================================
   CONTEÚDO PRINCIPAL (DASHBOARD)
   ========================================================================== */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: radial-gradient(circle at top right, rgba(124, 58, 237, 0.05), transparent 40%),
        radial-gradient(circle at bottom left, rgba(59, 130, 246, 0.03), transparent 30%);
}

/* Card Informativo Superior da Zona Selecionada */
.zone-info-card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 20px 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    animation: fadeIn 0.4s ease-out;
}

.badge-status {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    margin-bottom: 10px;
    text-transform: uppercase;
}

.badge-status.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: rgba(59, 130, 246, 0.3);
    color: var(--primary);
}

.zone-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: #fff;
}

.zone-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Grid Geral do Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 24px;
    align-items: start;
}

/* Cards Genéricos */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
    transition: var(--transition-smooth);
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.card-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title svg {
    color: var(--primary);
}

.card-title h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: #fff;
}

.card-body {
    padding: 24px;
}

/* Painel do Mapa */
.map-card {
    height: 600px;
    display: flex;
    flex-direction: column;
}

.coordinates-display {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: monospace;
    background: rgba(255, 255, 255, 0.04);
    padding: 4px 8px;
    border-radius: 4px;
}

.map-container {
    flex: 1;
    padding: 0;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Dark Mode para OpenStreetMap no Leaflet */
.leaflet-tile {
    filter: invert(100%) hue-rotate(180deg) brightness(85%) contrast(90%);
}

.leaflet-container {
    background: #0f172a !important;
}

/* Coluna de Detalhes (Métricas + Agenda) */
.details-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Seção de Métricas */
.metrics-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding-left: 4px;
}

.section-title svg {
    color: var(--primary);
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 16px;
}

/* Categoria de Métricas */
.metric-category-header {
    grid-column: 1 / -1;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-top: 10px;
    margin-bottom: 2px;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 6px;
}

.metric-category-header:first-of-type {
    margin-top: 0;
}

/* Card de Métrica Individual */
.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: relative;
    overflow: hidden;
    transition: var(--transition-smooth);
    animation: slideUp 0.4s ease-out;
}

.metric-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.metric-icon-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    transition: var(--transition-smooth);
}

.metric-card:hover .metric-icon-wrapper {
    background: var(--primary-glow);
    color: var(--primary);
}

.metric-info {
    display: flex;
    flex-direction: column;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    margin-bottom: 4px;
}

.metric-label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.split-cards-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 1200px) {
    .split-cards-container {
        grid-template-columns: 1fr;
    }
}

/* Seção de Compromissos, Timeline e Atualizações */
.agenda-card,
.atualizacoes-card {
    max-height: 380px;
    display: flex;
    flex-direction: column;
}

.agenda-card .card-body,
.atualizacoes-card .card-body {
    flex: 1;
    overflow-y: auto;
    padding-right: 14px;
}

/* Timeline */
.agenda-timeline {
    position: relative;
    padding-left: 20px;
}

.agenda-timeline::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    margin-bottom: 24px;
    animation: fadeIn 0.4s ease-out;
}

.timeline-item:last-child {
    margin-bottom: 0;
}

.timeline-indicator {
    position: absolute;
    left: -20px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--bg-main);
    border: 2px solid var(--primary);
    box-shadow: 0 0 0 3px var(--bg-main);
}

.timeline-time {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.timeline-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 4px;
}

.timeline-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 6px;
}

.timeline-location {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.timeline-location svg {
    flex-shrink: 0;
}

/* Estado Vazio */
.empty-state {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-muted);
    text-align: center;
    gap: 12px;
}

.empty-state svg {
    color: var(--text-muted);
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.85rem;
}


/* ==========================================================================
   ANIMAÇÕES E KEYFRAMES
   ========================================================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}


/* ==========================================================================
   CUSTOM MAP ICONS & CLICKABLE METRICS
   ========================================================================== */
.custom-map-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.icon-banquinha {
    background-color: var(--primary);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-comite {
    background-color: var(--secondary);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-pessoa {
    background-color: var(--accent);
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-map-icon i,
.custom-map-icon svg {
    width: 16px;
    height: 16px;
}

a.clickable-metric {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    transition: var(--transition-smooth);
}

a.clickable-metric:hover {
    border-color: var(--primary);
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.2);
    transform: translateY(-4px);
}

/* ==========================================================================
   RESPONSIVIDADE (MEDIA QUERIES)
   ========================================================================== */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .map-card {
        height: 450px;
    }
}

@media (max-width: 768px) {
    .dashboard-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 240px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .main-content {
        padding: 16px;
    }
}