/* ============================================
   STYLE.CSS - Estilos do Sistema Delivery
   ============================================ */

:root {
    --primary: #0057a9;       /* Verde do topo do Zap */
    --primary-dark: #005c4b;
    --success: #25D366;       /* Verde claro do ícone */
    
    --bg-body: #e5e5e5;       /* Fundo padrão */
    --bg-card: #ffffff;
    
    --text-primary: #111b21;
    --text-secondary: #667781;
    
    --border: #e9edef;
}

/* Cabeçalho estilo App */
header {
    background-color: var(--primary);
    padding: 15px 0;
    margin-top: 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
header h1 { color: white !important; font-size: 1.5rem; }
header p { color: #e9edef !important; }
.connection-status { background: rgba(255,255,255,0.1); border: none; color: white; }
/* Deixar o cabeçalho escuro para contraste */
header {
    background-color: #374151; /* Chumbo */
    color: white;
    padding: 20px;
    border-radius: 0 0 15px 15px;
    margin-bottom: 30px;
    margin-top: 0;
}
header h1, header p { color: white !important; }
/* Deixar o cabeçalho escuro para contraste */
header {
    background-color: #0057a9; /* Chumbo */
    color: white;
    padding: 20px;
    border-radius: 0 0 15px 15px;
    margin-bottom: 30px;
    margin-top: 0;
}
header h1, header p { color: white !important; }

/* Reset e base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* ========== HEADER ========== */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

header h1 {
    font-size: 2.2rem;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 10px;
}

header p {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Status de conexão discreto */
.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.online {
    background: var(--success);
}

.status-indicator.offline {
    background: var(--offline);
}

.status-indicator.syncing {
    background: var(--warning);
    animation: pulse 1.5s infinite;
}

.last-sync {
    font-size: 0.8rem;
    color: var(--text-light);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ========== CARD PRINCIPAL ========== */
.card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.consulta-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    flex-wrap: wrap;
    gap: 15px;
}

.consulta-header h2 {
    font-size: 1.4rem;
    color: var(--text-primary);
    margin: 0;
}

/* ========== BOTÕES ========== */
.btn-add {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-add:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* Botão de sincronização discreto */
.btn-sync {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s;
}

.btn-sync:hover {
    background: var(--border-light);
    border-color: var(--primary);
    color: var(--primary);
}

.btn-sync:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========== FILTROS ========== */
.filtros {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.btn-filtro {
    padding: 8px 16px;
    border: 2px solid var(--border);
    background: var(--bg-card);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.btn-filtro.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-filtro:hover:not(.active) {
    border-color: var(--primary);
    color: var(--primary);
}

/* ========== BUSCA ========== */
.search-container {
    position: relative;
    margin-bottom: 25px;
}

.search-input {
    width: 100%;
    padding: 12px 16px 12px 45px;
    border: 2px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    transition: all 0.2s;
    background: var(--bg-input) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'%3E%3C/circle%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'%3E%3C/line%3E%3C/svg%3E") no-repeat 16px center;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45, 122, 247, 0.1);
}

/* ========== LISTA DE MORADORES ========== */
.moradores-container {
    min-height: 300px;
}

/* Seção de últimas entregas */
.ultimas-entregas {
    margin-bottom: 30px;
}

.ultimas-entregas h3 {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-light);
}

/* Cards de morador */
.morador-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    transition: all 0.2s;
    position: relative;
}

.morador-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.morador-card.unsynced {
    border-left: 3px solid var(--warning);
}

.morador-info {
    flex: 1;
}

.morador-info h4 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.bloco-badge {
    background: var(--primary);
    color: white;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.local-badge {
    background: var(--offline);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
}

.codigo-item {
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.codigo-label {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 70px;
}

.codigo-value {
    font-family: 'Courier New', monospace;
    background: var(--border-light);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
}

.entrega-info {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    font-size: 0.85rem;
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

.entrega-time {
    color: var(--success);
    font-weight: 600;
}

/* ========== AÇÕES DO MORADOR ========== */
.morador-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-left: 15px;
    min-width: 150px;
}

.btn-marcar-entrega, .btn-edit, .btn-delete, .btn-copiar {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    white-space: nowrap;
}

.btn-marcar-entrega {
    background: var(--primary);
    color: white;
}

.btn-marcar-entrega:hover {
    background: var(--primary-dark);
}

.btn-edit {
    background: var(--border-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-edit:hover {
    background: var(--border);
}

.btn-delete {
    background: #fee2e2;
    color: var(--danger);
    border: 1px solid #fecaca;
}

.btn-delete:hover {
    background: #fecaca;
}

.btn-copiar {
    background: #dbeafe;
    color: var(--primary);
    border: 1px solid #bfdbfe;
    padding: 6px 10px;
    font-size: 0.8rem;
}

.btn-copiar:hover {
    background: #bfdbfe;
}

.btn-copiar.copied {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

/* ========== STATES ========== */
.loading-state, .empty-state, .error-state {
    text-align: center;
    padding: 50px 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    margin: 0 auto 15px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.empty-state, .error-state {
    color: var(--text-light);
    font-size: 1rem;
}

.error-state {
    color: var(--danger);
    background: #fef2f2;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #fecaca;
}

/* ========== MODAIS ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.3rem;
    color: var(--text-primary);
    margin: 0;
}

.btn-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-light);
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.btn-close:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

/* ========== FORMULÁRIO ========== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 15px;
}

.input-group {
    margin-bottom: 15px;
}

.input-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.2s;
    background: var(--bg-input);
}

.input-group input:focus,
.input-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45, 122, 247, 0.1);
}

.codigos-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 10px;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.btn-submit, .btn-cancel {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-submit {
    background: var(--primary);
    color: white;
}

.btn-submit:hover {
    background: var(--primary-dark);
}

.btn-cancel {
    background: var(--border-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-cancel:hover {
    background: var(--border);
}

/* ========== MODAL DE CONFIRMAÇÃO ========== */
.modal-sm {
    max-width: 400px;
}

.modal-confirm-content {
    text-align: center;
    padding: 25px;
}

.modal-icon {
    font-size: 2.5rem;
    margin-bottom: 15px;
}

.modal-confirm-text {
    margin-bottom: 20px;
    line-height: 1.5;
}

.modal-confirm-actions {
    display: flex;
    gap: 10px;
}

/* ========== NOTIFICAÇÕES DISCRETAS ========== */
.toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    background: white;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-md);
    border-left: 3px solid;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideInRight 0.3s ease-out;
    min-width: 250px;
    max-width: 300px;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-left-color: var(--success);
}

.toast.warning {
    border-left-color: var(--warning);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast.info {
    border-left-color: var(--primary);
}

.toast-icon {
    font-size: 1.2rem;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    margin-bottom: 2px;
    font-size: 0.9rem;
}

.toast-message {
    font-size: 0.8rem;
    color: var(--text-light);
}

.toast-close {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-light);
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.toast-close:hover {
    background: var(--border-light);
    color: var(--text-primary);
}

/* ========== RESPONSIVIDADE ========== */
@media (max-width: 768px) {
    body {
        padding: 15px;
    }
    
    .consulta-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .btn-add {
        width: 100%;
        justify-content: center;
    }
    
    .morador-card {
        flex-direction: column;
        gap: 12px;
    }
    
    .morador-actions {
        margin-left: 0;
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
    }
    
    .morador-actions button {
        flex: 1;
        min-width: 110px;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .codigos-grid {
        grid-template-columns: 1fr;
    }
    
    .modal-confirm-actions {
        flex-direction: column;
    }
    
    .toast-container {
        left: 20px;
        right: 20px;
        bottom: 10px;
    }
    
    .toast {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.8rem;
    }
    
    .filtros {
        justify-content: center;
    }
    
    .btn-filtro {
        flex: 1;
        text-align: center;
        min-width: 70px;
        padding: 6px 12px;
        font-size: 0.85rem;
    }
    
    .morador-actions {
        flex-direction: column;
    }
    
    .morador-actions button {
        width: 100%;
    }
    
    .modal-content {
        padding: 10px;
    }
}