/* Reset e Variáveis */
:root {
    --primary-color: #1e3a5f;
    --primary-dark: #152a42;
    --primary-light: #2d4f7c;
    --secondary-color: #4a90a4;
    --accent-color: #6bb6d6;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --background: #f5f7fa;
    --surface: #ffffff;
    --border: #e1e8ed;
    --success: #27ae60;
    --error: #e74c3c;
    --warning: #f39c12;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app-container {
    min-height: 100vh;
    height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    width: 100%;
    margin: 0;
    background: var(--surface);
    box-shadow: none;
}

/* Header */
.app-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 8px var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
    flex: 1;
    text-align: center;
}

.menu-btn,
.profile-btn,
.notification-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background-color 0.2s;
    position: relative;
}

.menu-btn:hover,
.profile-btn:hover,
.notification-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.notification-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #e74c3c;
    color: white;
    border-radius: 50%;
    min-width: 18px;
    height: 18px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    padding: 0 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: -300px;
    top: 0;
    width: 300px;
    height: 100vh;
    background: var(--surface);
    box-shadow: 2px 0 10px var(--shadow);
    transition: left 0.3s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.sidebar.open {
    left: 0;
}

.sidebar-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.close-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background-color 0.2s;
}

.close-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background-color: var(--background);
    color: var(--primary-color);
}

.nav-item.active {
    background-color: rgba(30, 58, 95, 0.1);
    color: var(--primary-color);
    border-left-color: var(--primary-color);
    font-weight: 600;
}

.nav-item svg {
    flex-shrink: 0;
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    z-index: 999;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    height: calc(100vh - 60px); /* Altura total menos o header */
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.view {
    animation: fadeIn 0.3s ease;
    display: flex;
    flex-direction: column;
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.view.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-shrink: 0;
}

.view-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 2px 8px var(--shadow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-lg);
}

.btn-secondary {
    background: var(--background);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
}

.btn-back {
    background: transparent;
    color: var(--text-primary);
    padding: 0.5rem 1rem;
}

.btn-back:hover {
    background: var(--background);
}

/* Search */
.search-container {
    position: relative;
    margin-bottom: 1.5rem;
}

.search-input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

/* Filtros */
.filters-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
}

.filter-group label {
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.filter-group .search-input {
    padding-left: 1rem;
}

/* Records List */
.records-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Grid layout para lista de rede */
#redeList {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

@media (min-width: 768px) {
    #redeList {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 767px) {
    #redeList {
        grid-template-columns: 1fr;
    }
}

/* Ranking por cidade (Gerenciar Rede) */
.rede-ranking-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 0.75rem;
    align-items: stretch;
}
.rede-ranking-cidade {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    min-height: 200px;
    display: flex;
    flex-direction: column;
}
.rede-ranking-cidade .cidade-nome {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.35rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.rede-ranking-cidade .cidade-nome-link {
    cursor: pointer;
    background: none;
    border: none;
    text-align: left;
    padding: 0;
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35rem;
    font: inherit;
    color: inherit;
}
.rede-ranking-cidade .cidade-nome-link:hover {
    text-decoration: underline;
}
.rede-ranking-cidade .cidade-nome-total {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.link-cidade-ranking {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: none;
}
.link-cidade-ranking:hover {
    text-decoration: underline;
}
.rede-ranking-cidade .lider-list {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.rede-ranking-cidade .lider-item {
    font-size: 0.75rem;
    padding: 0.25rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}
.rede-ranking-cidade .lider-item .pos {
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 1.5rem;
    flex-shrink: 0;
}
.rede-ranking-cidade .lider-item .lider-nome-link {
    flex: 1;
    min-width: 0;
    cursor: pointer;
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    text-align: left;
    background: none;
    border: none;
    padding: 0;
    font-size: inherit;
}
.rede-ranking-cidade .lider-item .lider-nome-link:hover {
    text-decoration: underline;
}
.rede-ranking-cidade .lider-item .lider-count {
    font-weight: 600;
    color: var(--primary-color);
    flex-shrink: 0;
}
.rede-input-compact {
    font-size: 0.8rem !important;
    padding: 0.35rem 0.5rem !important;
}

/* Botões do header Gerenciar Rede: mesma altura */
.gerenciar-rede-header-btns {
    align-items: stretch;
}
.btn-rede-header {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: 38px;
    padding: 0.5rem 0.75rem !important;
    margin: 0 !important;
}
.btn-rede-header span {
    margin-left: 0;
}

/* Resumo hierárquico no modal Gerenciar Pessoas */
.rede-resumo-nivel {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.75rem 1rem;
}
.rede-resumo-nivel-titulo {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}
.rede-resumo-nivel-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.rede-resumo-nivel-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 160px;
}
.rede-resumo-nivel-card-muted {
    background: var(--bg-secondary);
}
.rede-resumo-nivel-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.rede-resumo-nivel-valor {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Cards menores para rede */
.rede-card {
    padding: 1rem;
    min-height: auto;
}

.rede-card .record-header {
    margin-bottom: 0.5rem;
}

.rede-card .record-actions {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: space-between;
}

.rede-card .btn {
    flex: 0 0 auto;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    white-space: nowrap;
}

.rede-card .record-badge {
    background: var(--primary-color) !important;
    color: white !important;
    padding: 0.5rem 0.75rem !important;
    border-radius: 6px !important;
    font-size: 0.875rem !important;
    font-weight: 600 !important;
    white-space: nowrap !important;
    min-width: 2.5rem;
    text-align: center;
    display: inline-block;
}

.record-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    transition: all 0.2s;
    cursor: pointer;
}

.record-card:hover {
    box-shadow: 0 4px 12px var(--shadow);
    transform: translateY(-2px);
}

.record-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.record-name {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.record-name-clickable {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: all 0.2s;
    padding: 0.25rem 0.5rem;
    margin: -0.25rem -0.5rem;
    border-radius: 6px;
}

.record-name-clickable:hover {
    background-color: rgba(30, 58, 95, 0.1);
    color: var(--primary-color);
}

.record-name-clickable svg {
    flex-shrink: 0;
}

.record-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-lideranca {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success);
}

.record-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.info-item svg {
    flex-shrink: 0;
    color: var(--primary-color);
}

.record-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    align-items: center;
    justify-content: flex-end;
}

.action-btn {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-btn:hover {
    background: var(--background);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.action-btn.delete:hover {
    border-color: var(--error);
    color: var(--error);
}

.action-btn-small {
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 0.4rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

.action-btn-small:hover {
    transform: scale(1.05);
}

.action-btn-small.delete:hover {
    background: rgba(231, 76, 60, 0.1);
}

/* Badges de status/ativo */
.badge-status-publicado {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success);
    margin-left: 0.5rem;
}

.badge-status-rascunho {
    background: rgba(243, 156, 18, 0.1);
    color: var(--warning);
    margin-left: 0.5rem;
}

.badge-ativo {
    background: rgba(39, 174, 96, 0.08);
    color: var(--success);
    margin-left: 0.5rem;
}

.badge-inativo {
    background: rgba(231, 76, 60, 0.08);
    color: var(--error);
    margin-left: 0.5rem;
}

/* Loading */
.loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Form */
.record-form {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

@media (min-width: 768px) {
    .record-form {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem 2rem;
        max-width: 1000px;
    }
    
    /* Campos que ocupam toda a largura em desktop */
    .record-form .form-group.full-width,
    .record-form .form-group:has(textarea),
    .record-form #grupoTrabalhoGroup {
        grid-column: 1 / -1;
    }
    
    /* Nome e Telefone lado a lado */
    .record-form .form-group-nome {
        grid-column: 1;
    }
    
    .record-form .form-group-telefone {
        grid-column: 2;
    }
    
    /* Instagram e Data de Nascimento lado a lado */
    .record-form .form-group-instagram {
        grid-column: 1;
    }
    
    .record-form .form-group-data {
        grid-column: 2;
    }
    
    /* CEP ocupa toda a largura (com instrução) */
    .record-form .form-group-cep {
        grid-column: 1 / -1;
    }
    
    /* Cidade e Bairro já estão em form-row, mas garantimos */
    .record-form .form-row {
        grid-column: 1 / -1;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
        margin-bottom: 0;
    }
    
    .record-form .form-row .form-group {
        margin-bottom: 0;
    }
    
    /* Checkbox de liderança ocupa toda a largura */
    .record-form .form-group-lideranca {
        grid-column: 1 / -1;
    }
    
    /* Botões de ação */
    .record-form .form-actions {
        grid-column: 1 / -1;
        margin-top: 0.5rem;
    }
}

.form-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
}

@media (min-width: 768px) {
    .record-form .form-group {
        margin-bottom: 0;
    }
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.form-group input[type="text"],
.form-group input[type="tel"],
.form-group input[type="date"],
.form-group input[type="time"] {
    width: 100%;
    padding: 0.875rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s;
    font-family: inherit;
    position: relative;
    background-color: var(--surface);
    color: var(--text-primary);
}

/* Estilização específica para input de data */
.form-group input[type="date"] {
    cursor: pointer;
}

.form-group input[type="date"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    padding: 0.25rem;
    margin-left: 0.5rem;
}

.form-group input[type="date"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.form-group input[type="date"]::-webkit-datetime-edit-text {
    color: var(--text-primary);
    padding: 0 0.25rem;
}

.form-group input[type="date"]::-webkit-datetime-edit-month-field,
.form-group input[type="date"]::-webkit-datetime-edit-day-field,
.form-group input[type="date"]::-webkit-datetime-edit-year-field {
    color: var(--text-primary);
    padding: 0 0.25rem;
}

.form-group input[type="date"]:focus::-webkit-datetime-edit-month-field,
.form-group input[type="date"]:focus::-webkit-datetime-edit-day-field,
.form-group input[type="date"]:focus::-webkit-datetime-edit-year-field {
    background-color: rgba(30, 58, 95, 0.1);
    border-radius: 4px;
}

/* Estilização específica para input de hora */
.form-group input[type="time"] {
    cursor: pointer;
}

.form-group input[type="time"]::-webkit-calendar-picker-indicator {
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    padding: 0.25rem;
    margin-left: 0.5rem;
}

.form-group input[type="time"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
}

.form-group input[type="time"]::-webkit-datetime-edit-text {
    color: var(--text-primary);
    padding: 0 0.25rem;
}

.form-group input[type="time"]::-webkit-datetime-edit-hour-field,
.form-group input[type="time"]::-webkit-datetime-edit-minute-field {
    color: var(--text-primary);
    padding: 0 0.25rem;
}

.form-group input[type="time"]:focus::-webkit-datetime-edit-hour-field,
.form-group input[type="time"]:focus::-webkit-datetime-edit-minute-field {
    background-color: rgba(30, 58, 95, 0.1);
    border-radius: 4px;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Estados do campo CEP */
.form-group input.loading {
    border-color: var(--accent-color);
    background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83' stroke='%234a90a4' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    background-size: 20px 20px;
    padding-right: 2.5rem;
    animation: pulse 1.5s ease-in-out infinite;
}

.form-group input.cep-success {
    border-color: var(--success);
    background-color: rgba(39, 174, 96, 0.05);
    background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M20 6L9 17l-5-5' stroke='%2327ae60' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    background-size: 20px 20px;
    padding-right: 2.5rem;
}

.form-group input.cep-error {
    border-color: var(--error);
    background-color: rgba(231, 76, 60, 0.05);
    background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='12' cy='12' r='10' stroke='%23e74c3c' stroke-width='2'/%3E%3Cpath d='M12 8v4M12 16h.01' stroke='%23e74c3c' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.875rem center;
    background-size: 20px 20px;
    padding-right: 2.5rem;
}

.form-group input.cep-filled {
    background-color: rgba(30, 58, 95, 0.03);
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 1rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

@media (min-width: 768px) {
    .record-form .form-actions {
        margin-top: 0.5rem;
        padding-top: 1.5rem;
    }
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
    position: relative;
    z-index: 10;
}

.pagination-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-primary);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--background);
    border-color: var(--primary-color);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.pagination-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination-info {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--text-primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
    transition: all 0.3s;
    z-index: 2000;
    max-width: 400px;
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--error);
}

.toast.warning {
    background: var(--warning);
}

.toast.info {
    background: var(--secondary-color);
}

/* Modal de Alerta/Confirmação Customizado */
#customAlertOverlay {
    z-index: 3000 !important; /* Acima de todos os outros modais */
}

.custom-alert-modal {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    max-width: 500px;
    width: 90%;
    padding: 2rem;
    text-align: center;
    animation: alertSlideIn 0.3s ease-out;
    position: relative;
    overflow: hidden;
    z-index: 3001;
}

.custom-alert-modal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
}

@keyframes alertSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.custom-alert-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    animation: iconPulse 0.5s ease-out;
}

@keyframes iconPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.custom-alert-icon.success {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success);
}

.custom-alert-icon.error {
    background: rgba(231, 76, 60, 0.1);
    color: var(--error);
}

.custom-alert-icon.warning {
    background: rgba(243, 156, 18, 0.1);
    color: var(--warning);
}

.custom-alert-icon.info {
    background: rgba(74, 144, 164, 0.1);
    color: var(--secondary-color);
}

.custom-alert-icon.question {
    background: rgba(30, 58, 95, 0.1);
    color: var(--primary-color);
}

.custom-alert-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    line-height: 1.4;
}

.custom-alert-message {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 2rem;
    white-space: pre-line;
    word-wrap: break-word;
}

.custom-alert-message strong {
    color: var(--text-primary);
    font-weight: 600;
}

.custom-alert-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

.custom-alert-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.custom-alert-btn-primary {
    background: var(--primary-color);
    color: white;
}

.custom-alert-btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.3);
}

.custom-alert-btn-secondary {
    background: var(--background);
    color: var(--text-primary);
    border: 2px solid var(--border);
}

.custom-alert-btn-secondary:hover {
    background: var(--border);
    transform: translateY(-2px);
}

.custom-alert-btn-danger {
    background: var(--error);
    color: white;
}

.custom-alert-btn-danger:hover {
    background: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.custom-alert-btn:active {
    transform: translateY(0);
}

@media (max-width: 768px) {
    .custom-alert-modal {
        padding: 1.5rem;
        width: 95%;
    }
    
    .custom-alert-icon {
        width: 60px;
        height: 60px;
        font-size: 2rem;
    }
    
    .custom-alert-title {
        font-size: 1.25rem;
    }
    
    .custom-alert-message {
        font-size: 0.9rem;
    }
    
    .custom-alert-actions {
        flex-direction: column;
    }
    
    .custom-alert-btn {
        width: 100%;
    }
}

/* Modal WhatsApp */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2100;
}

/* Modal de confirmação deve aparecer acima de outros modais */
#customAlertOverlay {
    z-index: 3000 !important;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 10px 30px var(--shadow-lg);
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-body {
    padding: 1rem 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.modal-filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.modal-input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border-radius: 8px;
    border: 2px solid var(--border);
    font-size: 0.95rem;
    font-family: inherit;
}

.modal-input-small {
    height: 32px;
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    border-radius: 4px;
}

.modal-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.modal-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.modal-counter {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.modal-list {
    max-height: 45vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
    background: var(--background);
}

.modal-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    gap: 0.75rem;
}

.modal-list-item:last-child {
    border-bottom: none;
}

.modal-list-main {
    display: flex;
    flex-direction: column;
}

.modal-list-name {
    font-weight: 500;
    color: var(--text-primary);
}

.modal-list-phone {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.modal-list-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .modal {
        max-width: 95%;
        max-height: 95vh;
    }

    .modal-filters {
        grid-template-columns: 1fr;
    }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Responsive */
@media (max-width: 768px) {
    .app-header {
        padding: 0.75rem 1rem;
    }
    
    .app-header h1 {
        font-size: 0.9rem;
    }

    .view-header {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 1rem;
    }
    
    .view-header h2 {
        font-size: 1.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .record-info {
        grid-template-columns: 1fr;
    }

    .form-actions {
        flex-direction: column-reverse;
    }

    .form-actions .btn {
        width: 100%;
        justify-content: center;
    }

    .toast {
        right: 1rem;
        left: 1rem;
        max-width: none;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .stat-card {
        padding: 0.75rem;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
    
    .stat-label {
        font-size: 0.8rem;
    }
}

/* PWA Install Banner */
.pwa-install-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem 1.5rem;
    box-shadow: 0 -4px 12px var(--shadow-lg);
    z-index: 2000;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    border-top: 3px solid var(--accent-color);
}

.pwa-install-banner.show {
    transform: translateY(0);
}

.pwa-install-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.pwa-install-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-install-text {
    flex: 1;
}

.pwa-install-text strong {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.pwa-install-text p {
    margin: 0;
    font-size: 0.9rem;
    opacity: 0.9;
}

.pwa-install-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.btn-install {
    background: white;
    color: var(--primary-color);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.btn-install:hover {
    background: var(--background);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.btn-dismiss {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-dismiss:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
}

/* PWA specific styles */
@media (display-mode: standalone) {
    .app-header {
        padding-top: env(safe-area-inset-top);
    }
    
    .pwa-install-banner {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .pwa-install-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .pwa-install-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .btn-install {
        flex: 1;
    }
    
    .pwa-install-text strong {
        font-size: 1rem;
    }
    
    .pwa-install-text p {
        font-size: 0.85rem;
    }
}

/* Dashboard Styles */
.dashboard-refresh {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.last-update {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.dashboard-container {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    min-height: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s;
    box-shadow: 0 2px 4px var(--shadow);
    position: relative;
    z-index: 1;
    isolation: isolate;
}

.stat-card:hover {
    box-shadow: 0 4px 12px var(--shadow-lg);
    transform: translateY(-2px);
}

.stat-card-interactive {
    position: relative;
    cursor: pointer;
    z-index: 2;
    isolation: isolate;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(30, 58, 95, 0.1);
    color: var(--primary-color);
    flex-shrink: 0;
}

.stat-icon.lideranca {
    background: rgba(39, 174, 96, 0.1);
    color: var(--success);
}

.stat-icon.sem-lideranca {
    background: rgba(231, 76, 60, 0.1);
    color: var(--error);
}

.stat-icon.bairros {
    background: rgba(74, 144, 164, 0.1);
    color: var(--secondary-color);
}

.stat-icon.cidades {
    background: rgba(107, 182, 214, 0.1);
    color: var(--accent-color);
}

.stat-content {
    flex: 1;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.dashboard-section {
    position: relative;
    z-index: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px var(--shadow);
    display: flex;
    flex-direction: column;
}

.dashboard-section:last-child {
    margin-bottom: 0;
}

/* Seção do mapa deve ocupar mais espaço */
.dashboard-section:has(#mapaCalorContainer) {
    flex: 1;
    min-height: 600px;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

.dashboard-section h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
    flex-shrink: 0;
}

.cidades-preview {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
    position: relative;
    z-index: 10;
}

.bairros-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.bairro-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--background);
    border-radius: 8px;
    transition: all 0.2s;
}

.bairro-item:hover {
    background: var(--border);
}

.bairro-name {
    min-width: 150px;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.bairro-bar {
    flex: 1;
    height: 24px;
    background: var(--border);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.bairro-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    border-radius: 12px;
    transition: width 0.3s ease;
}

.bairro-count {
    min-width: 40px;
    text-align: right;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

/* Popup de Cidades */
.cidades-popup {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px var(--shadow-lg);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    max-height: 400px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.cidades-popup.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.popup-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: var(--background);
    font-size: 0.9rem;
    color: var(--text-primary);
}

.popup-content {
    padding: 1rem;
    overflow-y: auto;
    max-height: 300px;
}

.cidade-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
}

.cidade-item:last-child {
    border-bottom: none;
}

.cidade-item:hover {
    background: var(--background);
}

.cidade-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
    flex: 1;
}

.cidade-count {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.95rem;
    min-width: 40px;
    text-align: right;
}

/* Mapa de Calor */
#mapaCalorContainer {
    position: relative;
    border: 2px solid var(--border);
    box-shadow: 0 4px 12px var(--shadow);
    overflow: hidden;
    background: #f0f0f0;
    z-index: 1;
    flex: 1;
    min-height: 500px;
    width: 100%;
    height: 100%;
    margin-top: 0;
    border-radius: 8px;
}

#mapaCalor {
    z-index: 1;
    cursor: grab;
    background: #f5f5f5;
    width: 100% !important;
    height: 100% !important;
    min-height: 500px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Garantir que o Leaflet não sobreponha as seções do dashboard */
#mapaCalorContainer .leaflet-container {
    z-index: 1;
    width: 100% !important;
    height: 100% !important;
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
}

#mapaCalor:active {
    cursor: grabbing;
}

/* Legenda do Mapa */
.mapa-legenda {
    position: relative;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    margin-top: 1rem;
    width: 100%;
    font-size: 0.875rem;
}

.mapa-legenda-header {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border);
    color: var(--text-primary);
    font-size: 0.95rem;
    text-align: center;
}

.mapa-legenda-items {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    align-items: center;
}

.mapa-legenda-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 6px;
    transition: background-color 0.2s;
    white-space: nowrap;
}

.mapa-legenda-item:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

.mapa-legenda-color {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mapa-legenda-label {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.85rem;
    white-space: nowrap;
}

.mapa-legenda-count {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 12px;
    min-width: 40px;
    text-align: center;
}

/* Desabilitar seleção de texto no mapa */
#mapaCalor * {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Labels das regiões no mapa */
.mapa-regiao-label {
    pointer-events: auto;
    cursor: pointer;
}

.mapa-regiao-label:hover {
    transform: scale(1.05);
    transition: transform 0.2s;
}

.mapa-municipio-tooltip {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #0066CC;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #1e3a5f;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mapa-pin-tooltip {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e74c3c;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #1e3a5f;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mapa-cidade-tooltip {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #0066CC;
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 0.875rem;
    font-weight: 500;
    color: #1e3a5f;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    white-space: nowrap;
}

.mapa-municipio-label {
    pointer-events: none;
    z-index: 1000;
}

.mapa-municipio-label div {
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.mapa-municipio-label div:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.mapa-regiao-tooltip-simple {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 1px solid #ccc !important;
    border-radius: 4px !important;
    padding: 0.25rem 0.5rem !important;
    font-size: 0.85rem !important;
    font-weight: 500 !important;
    color: #333 !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
    pointer-events: none !important;
    white-space: nowrap !important;
}

.mapa-regiao-label {
    pointer-events: none;
    z-index: 1000;
}

.mapa-regiao-label div {
    pointer-events: auto;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.mapa-regiao-label div:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.mapa-tooltip {
    position: absolute;
    background: var(--surface);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: 1000;
    pointer-events: none;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Estilos customizados para tooltips do Leaflet */
.leaflet-tooltip.mapa-tooltip-custom {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    box-shadow: 0 2px 8px var(--shadow);
}

.leaflet-popup-content-wrapper {
    border-radius: 12px;
    box-shadow: 0 4px 12px var(--shadow-lg);
}

.leaflet-popup-content {
    margin: 0;
    padding: 0;
}

/* Ajustes para responsividade do mapa */
@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
        height: calc(100vh - 56px); /* Header menor em mobile */
    }
    
    .dashboard-container {
        padding: 0.5rem;
    }
    
    .dashboard-section {
        padding: 0.75rem;
    }
    
    .dashboard-section h3 {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
    }
    
    #mapaCalorContainer {
        min-height: 300px;
    }
    
    .mapa-legenda {
        font-size: 0.8rem;
        padding: 8px 12px;
    }
    
    .mapa-legenda-items {
        flex-direction: column;
        gap: 8px;
    }
    
    .bairro-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .bairro-name {
        min-width: auto;
        width: 100%;
    }
    
    .bairro-bar {
        width: 100%;
    }
    
    .bairro-count {
        min-width: auto;
        text-align: left;
    }
    
    .dashboard-refresh {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    .dashboard-refresh .last-update {
        width: 100%;
        order: -1;
    }
    
    .dashboard-refresh .btn {
        flex: 1;
        min-width: auto;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 769px) {
    .stats-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-card {
        padding: 0.875rem;
        gap: 0.75rem;
    }
    
    .stat-icon {
        width: 40px;
        height: 40px;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
}
    
    .bairro-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .bairro-name {
        min-width: auto;
        width: 100%;
    }
    
    .bairro-bar {
        width: 100%;
    }
    
    .bairro-count {
        min-width: auto;
        text-align: left;
    }
    
    .dashboard-refresh {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .cidades-popup {
        left: -10px;
        right: -10px;
        max-height: 300px;
    }
    
    .popup-content {
        max-height: 250px;
    }
}

/* Estilos do Calendário de Eventos */
.eventos-view-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
    flex-shrink: 0;
}

.view-toggle {
    display: flex;
    gap: 0.5rem;
    background: var(--background);
    padding: 0.25rem;
    border-radius: 8px;
}

.toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    font-size: 0.9rem;
    font-weight: 500;
}

.toggle-btn:hover {
    background: var(--surface);
    color: var(--text-primary);
}

.toggle-btn.active {
    background: var(--primary-color);
    color: white;
}

.calendario-container {
    background: var(--surface);
    border-radius: 12px;
    padding: 1rem;
    box-shadow: 0 2px 8px var(--shadow);
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    flex: 1;
}

.calendario-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-shrink: 0;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.calendario-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: capitalize;
}

.calendario-nav-btn {
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-primary);
}

.calendario-nav-btn:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.calendario-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-template-rows: auto repeat(6, 1fr);
    gap: 0.4rem;
    flex: 1;
    min-height: 0;
}

.calendario-day-header {
    text-align: center;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.85rem;
    padding: 0.4rem;
    text-transform: uppercase;
    flex-shrink: 0;
}

.calendario-day {
    background: var(--background);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 0.4rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

.calendario-day:hover {
    border-color: var(--primary-color);
    background: var(--surface);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow);
}

.calendario-day.other-month {
    opacity: 0.3;
    cursor: default;
}

.calendario-day.other-month:hover {
    transform: none;
    box-shadow: none;
}

.calendario-day.today {
    background: rgba(30, 58, 95, 0.1);
    border-color: var(--primary-color);
    font-weight: 600;
}

.calendario-day-number {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.2rem;
    flex-shrink: 0;
}

.calendario-day-events {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.calendario-event-dot {
    width: 100%;
    padding: 0.2rem 0.3rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.calendario-event-dot.evento {
    background: var(--primary-color);
    color: white;
}

.calendario-event-dot.informativo {
    background: var(--secondary-color);
    color: white;
}

.calendario-event-dot:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 4px var(--shadow);
}

.calendario-event-count {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    text-align: center;
}

/* Modal de detalhes do evento no calendário */
.calendario-event-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 1rem;
}

.calendario-event-modal-content {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px var(--shadow-lg);
}

.calendario-event-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.calendario-event-modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.calendario-event-modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 8px;
    transition: all 0.2s;
}

.calendario-event-modal-close:hover {
    background: var(--background);
    color: var(--text-primary);
}

.calendario-event-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.calendario-event-item {
    padding: 1rem;
    background: var(--background);
    border-radius: 8px;
    border: 2px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.calendario-event-item:hover {
    border-color: var(--primary-color);
    transform: translateX(4px);
}

.calendario-event-item-content {
    flex: 1;
    cursor: pointer;
}

.calendario-event-item-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.calendario-event-item-details {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.calendario-event-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-shrink: 0;
}

.calendario-event-action-btn {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 0.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    min-width: 32px;
    height: 32px;
}

.calendario-event-action-btn:hover {
    background: #5a6268;
    transform: scale(1.05);
}

.calendario-event-action-btn:first-child {
    background: #4CAF50;
}

.calendario-event-action-btn:first-child:hover {
    background: #45a049;
}

.calendario-event-action-btn:last-child {
    background: #1e3a5f;
}

.calendario-event-action-btn:last-child:hover {
    background: #1a2f4d;
}

@media (max-width: 768px) {
    .eventos-view-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .view-toggle {
        width: 100%;
        justify-content: center;
    }
    
    .calendario-container {
        padding: 0.75rem;
    }
    
    .calendario-header {
        margin-bottom: 0.75rem;
        padding-bottom: 0.5rem;
    }
    
    .calendario-grid {
        gap: 0.3rem;
    }
    
    .calendario-day {
        padding: 0.3rem;
    }
    
    .calendario-day-number {
        font-size: 0.75rem;
        margin-bottom: 0.15rem;
    }
    
    .calendario-event-dot {
        font-size: 0.6rem;
        padding: 0.15rem 0.25rem;
    }
    
    .calendario-day-header {
        font-size: 0.75rem;
        padding: 0.3rem;
    }
}

/* Login View */
#loginView {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

#loginView.hidden {
    display: none !important;
}

/* Main App */
#mainApp {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

#mainApp.hidden {
    display: none !important;
}

/* Login Styles */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    background: transparent;
}

.login-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    padding: 3rem;
    width: 100%;
    max-width: 450px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.login-form .form-group {
    margin-bottom: 0;
}

.login-form .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.login-form .form-group input {
    width: 100%;
    padding: 0.875rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s;
    font-family: inherit;
    box-sizing: border-box;
}

.login-form .form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.login-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.login-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.login-error {
    background: rgba(231, 76, 60, 0.1);
    color: var(--error);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(231, 76, 60, 0.3);
    font-size: 0.9rem;
    text-align: center;
    margin-top: 0.5rem;
}

@media (max-width: 768px) {
    .login-container {
        padding: 1rem;
    }
    
    .login-card {
        padding: 2rem 1.5rem;
    }
    
    .login-header h2 {
        font-size: 1.5rem;
    }
}

/* Login Styles */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.login-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    padding: 3rem;
    width: 100%;
    max-width: 450px;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h2 {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 1rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.login-form .form-group {
    margin-bottom: 0;
}

.login-form .form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.login-form .form-group input {
    width: 100%;
    padding: 0.875rem;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s;
    font-family: inherit;
    box-sizing: border-box;
}

.login-form .form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.login-btn {
    width: 100%;
    padding: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 0.5rem;
}

.login-error {
    background: rgba(231, 76, 60, 0.1);
    color: var(--error);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 1px solid rgba(231, 76, 60, 0.3);
    font-size: 0.9rem;
    text-align: center;
    margin-top: 0.5rem;
}

@media (max-width: 768px) {
    .login-container {
        padding: 1rem;
    }
    
    .login-card {
        padding: 2rem 1.5rem;
    }
    
    .login-header h2 {
        font-size: 1.5rem;
    }
}

/* ============================================
   CHAT STYLES - WhatsApp-like Interface
   ============================================ */

/* Chat Container */
.chat-container {
    display: flex;
    height: calc(100vh - 120px);
    background: var(--surface);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px var(--shadow);
    border: 1px solid var(--border);
}

/* Chat Sidebar */
.chat-sidebar {
    width: 350px;
    min-width: 300px;
    max-width: 400px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.chat-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
}

.chat-sidebar-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

/* Chat Search */
.chat-search {
    position: relative;
    padding: 0.75rem 1rem;
    background: var(--background);
    border-bottom: 1px solid var(--border);
}

.chat-search-input {
    width: 100%;
    padding: 0.625rem 1rem 0.625rem 2.5rem;
    border: 2px solid var(--border);
    border-radius: 24px;
    font-size: 0.9rem;
    background: var(--surface);
    transition: all 0.2s;
}

.chat-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

.chat-search-icon {
    position: absolute;
    left: 1.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    pointer-events: none;
}

/* Chat List */
.chat-list {
    flex: 1;
    overflow-y: auto;
    background: var(--surface);
}

.chat-list-item {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border);
    position: relative;
}

.chat-list-item:hover {
    background: var(--background);
}

.chat-list-item.active {
    background: rgba(30, 58, 95, 0.1);
    border-left: 3px solid var(--primary-color);
}

.chat-list-item.unread {
    background: rgba(30, 58, 95, 0.05);
}

.chat-list-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    font-weight: 600;
    flex-shrink: 0;
}

.chat-list-content {
    flex: 1;
    min-width: 0;
}

.chat-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.chat-list-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-list-time {
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.chat-list-preview {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.chat-list-preview.unread {
    color: var(--text-primary);
    font-weight: 500;
}

.chat-unread-badge {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--primary-color);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.375rem;
}

.chat-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--text-secondary);
}

.chat-loading p {
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

/* Chat Main Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #e5ddd5;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d4cdc4' fill-opacity='0.4'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    min-width: 0;
    position: relative;
}

/* Chat Empty State */
.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-secondary);
    text-align: center;
    padding: 2rem;
    background: var(--background);
}

.chat-empty-icon {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--surface);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 12px var(--shadow);
}

.chat-empty-icon svg {
    color: var(--text-secondary);
    opacity: 0.5;
}

.chat-empty-state h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.chat-empty-state p {
    font-size: 1rem;
    opacity: 0.8;
}

/* Chat Header */
#chatView .chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    box-shadow: 0 2px 4px var(--shadow);
    z-index: 10;
}

.chat-back-btn {
    display: none;
    background: transparent;
    border: none;
    color: white;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.chat-back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.chat-contact-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.1rem;
}

.chat-contact-details h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.125rem 0;
}

.chat-contact-phone {
    font-size: 0.8rem;
    opacity: 0.85;
}

.chat-header-actions {
    display: flex;
    gap: 0.5rem;
}

.chat-header-actions .btn-icon {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

/* Chat Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
}

.chat-messages-loading {
    display: flex;
    justify-content: center;
    padding: 2rem;
}

.chat-messages-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 100%;
}

/* Chat Message Bubbles */
.chat-message {
    max-width: 65%;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    position: relative;
    animation: messageAppear 0.2s ease-out;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.enviada {
    align-self: flex-end;
    background: #dcf8c6;
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

.chat-message.recebida {
    align-self: flex-start;
    background: white;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
}

.chat-message-content {
    font-size: 0.9rem;
    line-height: 1.4;
    color: var(--text-primary);
    word-wrap: break-word;
}

.chat-message-media {
    margin-bottom: 0.5rem;
    border-radius: 6px;
    overflow: hidden;
    max-width: 300px;
}

.chat-message-media img {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    display: block;
    cursor: pointer;
    transition: opacity 0.2s;
}

.chat-message-media img:hover {
    opacity: 0.9;
}

.chat-message-media video {
    width: 100%;
    max-height: 300px;
    display: block;
}

.chat-message-media audio {
    width: 100%;
    max-width: 280px;
}

.chat-message-document {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-primary);
    transition: background 0.2s;
}

.chat-message-document:hover {
    background: rgba(0, 0, 0, 0.08);
}

.chat-message-document-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.chat-message-document-info {
    flex: 1;
    min-width: 0;
}

.chat-message-document-name {
    font-weight: 500;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-message-document-size {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.chat-message-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.25rem;
}

.chat-message-time {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.chat-message-status {
    display: flex;
    align-items: center;
}

.chat-message-status svg {
    width: 14px;
    height: 14px;
}

.chat-message-status.enviada svg {
    color: var(--text-secondary);
}

.chat-message-status.entregue svg {
    color: var(--text-secondary);
}

.chat-message-status.lida svg {
    color: #53bdeb;
}

.chat-message-status.erro svg {
    color: var(--error);
}

.chat-message.erro {
    opacity: 0.7;
}

.chat-message-error {
    font-size: 0.75rem;
    color: var(--error);
    margin-top: 0.25rem;
}

/* Date Separator */
.chat-date-separator {
    display: flex;
    justify-content: center;
    padding: 0.75rem 0;
}

.chat-date-separator span {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.375rem 0.75rem;
    border-radius: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Chat Input Area */
.chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--background);
    border-top: 1px solid var(--border);
}

.chat-input-wrapper {
    flex: 1;
    background: var(--surface);
    border-radius: 24px;
    border: 2px solid var(--border);
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    transition: border-color 0.2s;
}

.chat-input-wrapper:focus-within {
    border-color: var(--primary-color);
}

.chat-message-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    resize: none;
    max-height: 100px;
    line-height: 1.4;
    font-family: inherit;
}

.chat-message-input:focus {
    outline: none;
}

.chat-message-input::placeholder {
    color: var(--text-secondary);
}

.chat-attach-btn,
.chat-emoji-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-attach-btn:hover,
.chat-emoji-btn:hover {
    background: var(--border);
    color: var(--text-primary);
}

.chat-send-btn {
    background: var(--primary-color);
    border: none;
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.chat-send-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.chat-send-btn:disabled {
    background: var(--border);
    cursor: not-allowed;
    transform: none;
}

/* Chat Attach Modal Options */
.chat-attach-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    padding: 1rem 0;
}

.chat-attach-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-attach-option:hover {
    background: var(--background);
}

.chat-attach-icon {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.chat-attach-option:hover .chat-attach-icon {
    transform: scale(1.1);
}

.chat-attach-option span {
    font-size: 0.85rem;
    color: var(--text-primary);
    font-weight: 500;
}

.chat-attach-preview {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.chat-attach-preview-content {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 150px;
    background: var(--background);
    border-radius: 8px;
    overflow: hidden;
}

.chat-attach-preview-content img {
    max-width: 100%;
    max-height: 300px;
    object-fit: contain;
}

.chat-attach-preview-content video {
    max-width: 100%;
    max-height: 300px;
}

.chat-attach-preview-file {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 2rem;
    color: var(--text-secondary);
}

.chat-attach-preview-file svg {
    width: 48px;
    height: 48px;
}

.chat-attach-preview-file span {
    font-weight: 500;
    color: var(--text-primary);
}

/* New Chat Modal */
.new-chat-list {
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-top: 1rem;
}

.new-chat-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border);
}

.new-chat-item:last-child {
    border-bottom: none;
}

.new-chat-item:hover {
    background: var(--background);
}

.new-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    flex-shrink: 0;
}

.new-chat-info {
    flex: 1;
    min-width: 0;
}

.new-chat-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.125rem;
}

.new-chat-phone {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Responsive Chat */
@media (max-width: 768px) {
    .chat-container {
        height: calc(100vh - 100px);
        border-radius: 0;
    }
    
    .chat-sidebar {
        width: 100%;
        max-width: none;
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 20;
        transition: transform 0.3s ease;
    }
    
    .chat-sidebar.hidden-mobile {
        transform: translateX(-100%);
    }
    
    .chat-main {
        width: 100%;
    }
    
    .chat-back-btn {
        display: flex;
    }
    
    .chat-message {
        max-width: 85%;
    }
    
    .chat-attach-options {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .chat-empty-state {
        display: none;
    }
}

@media (max-width: 480px) {
    .chat-sidebar-header h3 {
        font-size: 1.1rem;
    }
    
    .chat-list-avatar {
        width: 45px;
        height: 45px;
    }
    
    .chat-input-area {
        padding: 0.5rem;
    }
    
    .chat-attach-btn,
    .chat-emoji-btn {
        width: 36px;
        height: 36px;
    }
    
    .chat-send-btn {
        width: 40px;
        height: 40px;
    }
}

/* ============================================
   CHAT - MELHORIAS E NOVAS FUNCIONALIDADES
   ============================================ */

/* Menu Dropdown do Chat */
.chat-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    z-index: 1000;
    overflow: hidden;
}

.chat-dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    border: none;
    background: none;
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
    text-align: left;
}

.chat-dropdown-item:hover {
    background: var(--hover-bg);
}

.chat-dropdown-item svg {
    flex-shrink: 0;
}

.chat-dropdown-item#chatDeleteBtn {
    color: #dc3545;
}

.chat-dropdown-item#chatDeleteBtn:hover {
    background: rgba(220, 53, 69, 0.1);
}

/* Botão Favorito */
#chatFavoriteBtn.active svg {
    fill: #ffc107;
    stroke: #ffc107;
}

/* Header Actions posição relativa para dropdown */
.chat-header-actions {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Emoji Picker */
.emoji-picker {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 350px;
    max-height: 400px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.emoji-picker-header {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.emoji-search-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--input-bg);
    color: var(--text-primary);
}

.emoji-picker-content {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.emoji-category {
    margin-bottom: 16px;
}

.emoji-category-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 8px;
    padding-left: 4px;
}

.emoji-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 4px;
}

.emoji-item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 22px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.emoji-item:hover {
    background: var(--hover-bg);
    transform: scale(1.2);
}

/* Conversa Favorita na Lista */
.chat-list-item.favorite {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.05) 0%, transparent 100%);
}

.chat-list-item.favorite .chat-list-name::before {
    content: '⭐ ';
    font-size: 12px;
}

/* Badge de Favorito */
.chat-favorite-badge {
    color: #ffc107;
    font-size: 14px;
    margin-left: 4px;
}

/* Membros do Grupo Selecionados */
.group-members-selected {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    min-height: 40px;
}

.group-member-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-light);
    color: var(--primary-color);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
}

.group-member-chip .remove-member {
    cursor: pointer;
    opacity: 0.7;
    font-size: 16px;
    line-height: 1;
}

.group-member-chip .remove-member:hover {
    opacity: 1;
}

/* Mensagem Recebida Estilo */
.chat-message.recebida {
    align-self: flex-start;
}

.chat-message.recebida .chat-message-bubble {
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
}

/* Indicador de Digitando */
.chat-typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    color: var(--text-secondary);
    font-size: 13px;
    font-style: italic;
}

.chat-typing-dots {
    display: flex;
    gap: 4px;
}

.chat-typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.chat-typing-dots span:nth-child(1) { animation-delay: 0s; }
.chat-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* Confirmar Exclusão */
.chat-confirm-delete {
    background: rgba(220, 53, 69, 0.1);
    border: 1px solid rgba(220, 53, 69, 0.3);
    padding: 16px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.chat-confirm-delete p {
    color: #dc3545;
    margin-bottom: 12px;
}

.chat-confirm-delete-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

/* Responsivo Emoji Picker */
@media (max-width: 480px) {
    .emoji-picker {
        width: calc(100% - 32px);
        left: 16px;
        right: 16px;
        bottom: 70px;
    }
    
    .emoji-grid {
        grid-template-columns: repeat(7, 1fr);
    }
    
    .emoji-item {
        width: 32px;
        height: 32px;
        font-size: 20px;
    }
}
