:root { 
    --primary: #2563eb; 
    --accent: #10b981; 
    --success: #4caf50; 
    --warning: #ff9800; 
    --danger: #f44336; 
    --bg: #f8fafc;
    --card: #ffffff; 
    --text: #0f172a; 
    --muted: #64748b; 
    --border: #e5e7eb;
}

[data-theme="dark"] {
    --primary: #3d5afe;
    --accent: #00d4aa;
    --bg: #0f172a;
    --card: #1e293b;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --border: #334155;
}

body { 
    font-family: 'Inter', sans-serif; 
    background: var(--bg); 
    color: var(--text); 
    margin: 0; 
    padding: 0; 
    overflow-x: hidden; 
    font-size: 14px; 
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background 0.3s, color 0.3s;
    /* Mobile optimization */
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
    /* Safe area para dispositivos com notch */
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* HEADER SIMPLIFICADO MAS MODERNO */
.header { 
    background: var(--primary); 
    position: sticky; 
    top: 0; 
    z-index: 1000; 
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    padding: 0;
    /* Safe area para notch */
    padding-top: env(safe-area-inset-top);
}

.nav-top { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    padding: 12px 15px; 
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.brand { 
    font-size: 1rem; 
    font-weight: 700; 
    color: white; 
    letter-spacing: -0.3px; 
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand i {
    font-size: 1.1rem;
    color: var(--accent);
}

.brand-empresa {
    font-weight: 400; 
    font-size: 0.8rem; 
    margin-left: 5px; 
    opacity: 0.9;
}

.btn-logout { 
    background: rgba(255,255,255,0.15); 
    border: none; 
    padding: 6px 12px; 
    border-radius: 6px; 
    color: white; 
    cursor: pointer; 
    font-size: 0.8rem; 
    font-weight: 600; 
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.theme-toggle {
    background: rgba(255,255,255,0.1);
    border: none;
    padding: 8px 10px;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-size: 1rem;
    transition: background 0.2s;
    margin-right: 10px;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.2);
} 
    cursor: pointer; 
    font-size: 0.85rem; 
    color: white; 
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.25);
}

/* FILTROS - MANTIDO FUNCIONAL */
.filters { 
    padding: 12px 15px; 
    display: flex; 
    gap: 8px; 
    align-items: center; 
    background: white;
}

.filters input { 
    background: #f1f5f9; 
    border: 1px solid transparent; 
    padding: 8px 12px; 
    border-radius: 8px; 
    font-size: 0.85rem; 
    outline: none; 
    transition: 0.2s; 
}

.filters input:focus { 
    background: #fff; 
    border-color: var(--accent); 
    box-shadow: 0 0 0 2px rgba(0, 184, 148, 0.1); 
}

#filtroData { width: 135px; flex-shrink: 0; }
#buscaNF { width: 80px; flex-shrink: 0; }
#buscaM { flex-grow: 1; }

/* Mobile: inputs de filtro ocupam 100% */
@media (max-width: 768px) {
    #filtroData,
    #buscaNF,
    #buscaM {
        width: 100%;
    }
}

/* TABS MELHORADAS */
.tabs { 
    display: flex; 
    background: white; 
    padding: 0 15px; 
    gap: 20px; 
    border-bottom: 1px solid var(--border); 
    overflow-x: auto; 
    /* Mobile scroll otimizado */
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

.tabs::-webkit-scrollbar {
    height: 3px;
}

.tabs::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 10px;
}

.tabs::-webkit-scrollbar-track {
    background: transparent;
}

.tab-btn { 
    padding: 12px 0; 
    border: none; 
    background: none; 
    font-size: 0.8rem; 
    font-weight: 600; 
    color: var(--muted); 
    border-bottom: 3px solid transparent; 
    cursor: pointer; 
    white-space: nowrap; 
    display: flex;
    align-items: center;
    gap: 6px;
}

.tab-btn.active { 
    color: var(--accent); 
    border-bottom-color: var(--accent); 
}

.tab-btn i {
    font-size: 0.9rem;
}

.container { 
    max-width: 600px; 
    margin: 0 auto; 
    padding-bottom: 40px; 
}

/* DASHBOARD ELEGANTE */
.dash { 
    padding: 15px; 
    display: grid; 
    grid-template-columns: repeat(3, 1fr); 
    gap: 10px; 
}

.dash-item { 
    background: var(--card); 
    padding: 15px 10px; 
    border-radius: 12px; 
    text-align: center; 
    border: 1px solid var(--border); 
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    position: relative;
    overflow: hidden;
}

.dash-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.dash-item:first-child::before {
    background: var(--primary);
}

.dash-item:nth-child(2)::before {
    background: var(--warning);
}

.dash-item:nth-child(3)::before {
    background: var(--success);
}

.dash-item span { 
    font-size: 0.65rem; 
    font-weight: 700; 
    color: var(--muted); 
    text-transform: uppercase; 
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 5px;
}

.dash-item b { 
    font-size: 1.3rem; 
    color: var(--text);
    font-weight: 700;
}

.dash-item #d-pen { color: var(--warning) !important; }
.dash-item #d-ok { color: var(--success) !important; }

/* CARDS MODERNOS */
.card { 
    background: white; 
    margin: 10px 15px; 
    border-radius: 14px; 
    padding: 20px; 
    border: 1px solid #f1f5f9; 
    box-shadow: 0 2px 12px rgba(0,0,0,0.06); 
    position: relative;
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 6px 20px rgba(0,0,0,0.1);
    transform: translateY(-2px);
    border-color: #e2e8f0;
}

.badge { 
    float: right; 
    padding: 4px 10px; 
    border-radius: 20px; 
    font-size: 0.65rem; 
    font-weight: 700; 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
    border: none;
}

.badge-p { background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%); color: #78350f; text-shadow: 0 1px 2px rgba(255,255,255,0.2); } 
.badge-s { background: linear-gradient(135deg, #4caf50 0%, #2e7d32 100%); color: white; text-shadow: 0 1px 2px rgba(0,0,0,0.2); } 
.badge-r { background: linear-gradient(135deg, #60a5fa 0%, #3b82f6 100%); color: #eff6ff; text-shadow: 0 1px 2px rgba(0,0,0,0.2); }

.card h3 { 
    margin: 0 0 15px 0; 
    font-size: 1.15rem; 
    width: 75%; 
    line-height: 1.3; 
    color: var(--primary); 
    font-weight: 700;
    letter-spacing: -0.3px;
}

.details { 
    border-top: 1px dashed #e2e8f0; 
    padding-top: 15px; 
    font-size: 0.875rem; 
    display: grid; 
    gap: 8px; 
}

.line { 
    display: flex; 
    gap: 8px; 
    align-items: flex-start; 
    color: #475569; 
} 

.line b { 
    color: var(--text); 
    min-width: 25px; 
    font-weight: 600; 
}

.line i {
    width: 18px;
    font-size: 0.95rem;
}

/* Ícones coloridos específicos */
.fa-file-invoice { color: #3b82f6; }
.fa-map-marker-alt { color: #ef4444; }
.fa-user-hard-hat { color: #8b5cf6; }
.fa-box { color: #f59e0b; }
.fa-clock { color: var(--accent); }
.fa-whatsapp { color: #25D366; }
.fa-sticky-note { color: #f59e0b; }

/* BOTÕES MELHORADOS */
.actions { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 8px; 
    margin-top: 15px; 
}

.btn { 
    padding: 10px; 
    border-radius: 8px; 
    border: none; 
    font-weight: 600; 
    font-size: 0.75rem; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    gap: 6px; 
    transition: 0.2s;
}

.btn:active { transform: scale(0.98); }

.btn-p { 
    background: linear-gradient(135deg, var(--primary) 0%, #0d1a6b 100%); 
    color: #fff; 
    grid-column: span 2;
    box-shadow: 0 2px 8px rgba(26, 35, 126, 0.3);
}

.btn-p:hover {
    background: linear-gradient(135deg, #0d1a6b 0%, #060f3d 100%);
    box-shadow: 0 4px 12px rgba(26, 35, 126, 0.4);
}

.btn-s { 
    background: #fff; 
    color: var(--text); 
    border: 1px solid var(--border); 
}

.btn-s:hover {
    border-color: var(--accent);
    background: #f8fafc;
}

.btn-w { 
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%); 
    color: white;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
}

.btn-w:hover {
    background: linear-gradient(135deg, #128C7E 0%, #075E54 100%);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

.btn-black { 
    background: #1e293b; 
    color: white; 
}

.btn-info { 
    background: #3b82f6; 
    color: white; 
}

.btn i {
    font-size: 0.85rem;
}

.page { display: none; } 
.page.active { display: block; }

.admin-controls { display: none; }

/* Utilitários mobile */
.hide-mobile-text {
    display: inline;
}

@media (max-width: 768px) {
    .hide-mobile-text {
        display: none;
    }
}

.form-input { 
    width: 100%; 
    padding: 12px; 
    margin-bottom: 10px; 
    border: 1px solid var(--border); 
    border-radius: 8px; 
    box-sizing: border-box;
    /* Mobile optimization */
    font-size: 16px; /* Previne zoom automático no iOS */
    -webkit-appearance: none; /* Remove estilo padrão iOS */
    appearance: none;
}

.form-input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

textarea { 
    width: 100%; 
    border-radius: 10px; 
    padding: 12px; 
    border: 1px solid var(--border); 
    box-sizing: border-box; 
    font-family: inherit;
    /* Mobile optimization */
    font-size: 16px; /* Previne zoom automático no iOS */
    -webkit-appearance: none;
    appearance: none;
    resize: vertical; /* Permite resize apenas vertical */
}

textarea:focus {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.empty-state { 
    padding: 40px 20px; 
    text-align: center; 
    color: var(--muted); 
}

.empty-state h3 { 
    color: var(--text); 
    margin-bottom: 5px; 
}

/* LOGIN ATUALIZADO */
#tela-login { 
    position: fixed; 
    inset: 0; 
    background: var(--primary); 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    z-index: 10000; 
    transition: opacity 0.3s; 
}

.login-box { 
    background: #fff; 
    padding: 30px; 
    border-radius: 12px; 
    width: 85%; 
    max-width: 350px; 
    text-align: center; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.login-box h2 {
    margin-bottom: 5px; 
    font-size: 1.2rem; 
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.login-box p {
    margin-top: 0; 
    font-size: 0.8rem; 
    color: var(--muted); 
    margin-bottom: 20px;
}

/* MODAIS - MANTIDOS FUNCIONAIS */
.modal-custom { 
    display: none; 
    position: fixed; 
    inset: 0; 
    background: rgba(0, 0, 0, 0.8); 
    z-index: 20000; 
    justify-content: center; 
    align-items: center; 
    backdrop-filter: blur(2px); 
}

.modal-content-custom { 
    background: white; 
    padding: 20px; 
    border-radius: 12px; 
    width: 90%; 
    max-width: 380px; 
    text-align: center; 
}

#modal-foto { 
    display: none; 
    position: fixed; 
    inset: 0; 
    background: black; 
    z-index: 30000; 
    justify-content: center; 
    align-items: center; 
}

#img-view { 
    max-width: 100%; 
    max-height: 80vh; 
    border-radius: 8px; 
}

.btn-fechar-modal { 
    position: absolute; 
    top: 20px; 
    right: 20px; 
    background: rgba(255,255,255,0.2); 
    color: white; 
    border: none; 
    padding: 10px 15px; 
    border-radius: 50%; 
    cursor: pointer; 
}

#lgpd-banner { 
    display: none; 
    position: fixed; 
    bottom: 0; 
    left: 0; 
    right: 0; 
    background: white; 
    padding: 20px; 
    z-index: 30000; 
    box-shadow: 0 -5px 20px rgba(0,0,0,0.1); 
}

/* BADGES MODERNOS */
.whatsapp-badge { 
    display: inline-flex; 
    align-items: center; 
    gap: 4px; 
    background: #25D366; 
    color: white; 
    padding: 3px 8px; 
    border-radius: 12px; 
    font-size: 0.7rem; 
    margin-left: 8px; 
    font-weight: 600; 
}

.observacao-badge { 
    background: #8b5cf6; 
    color: white; 
    padding: 3px 8px; 
    border-radius: 12px; 
    font-size: 0.7rem; 
    margin-left: 8px; 
    font-weight: 600; 
}

/* ESTILOS PARA NOTIFICAÇÕES */
.badge-noti {
    position: absolute;
    top: 2px;
    right: 2px;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 0.7rem;
    display: none;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

/* BOTÃO FLUTUANTE ENTREGAS */
#floating-delivery-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, #667eea 0%, #00b894 100%);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 12px 20px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 9999;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

#floating-delivery-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.25);
    background: linear-gradient(135deg, #00b894 0%, #667eea 100%);
}

#floating-delivery-btn i {
    font-size: 1.1rem;
}

#floating-delivery-btn span {
    display: none;
}

@media (min-width: 768px) {
    #floating-delivery-btn span {
        display: inline;
    }
}

/* ESTILOS RESPONSIVOS */
@media (max-width: 480px) {
    .container {
        max-width: 100%;
    }
    
    .dash {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 12px;
    }
    
    .card {
        margin: 8px 12px;
        padding: 14px;
    }
    
    .tabs {
        gap: 15px;
        padding: 0 12px;
    }
    
    .tab-btn {
        font-size: 0.75rem;
        padding: 10px 0;
    }
}

/* ===== LOADING STATES ===== */
.loading-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
    font-size: 0.9rem;
}

.loading-state i {
    font-size: 2rem;
    margin-bottom: 10px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.card {
    animation: fadeIn 0.3s ease-out;
}

/* ===== BADGES MELHORADOS ===== */
.whatsapp-badge {
    position: absolute;
    top: 42px;
    right: 10px;
    background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
    color: white;
    padding: 3px 7px;
    border-radius: 10px;
    font-size: 0.55rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    box-shadow: 0 2px 4px rgba(37, 211, 102, 0.3);
    letter-spacing: 0.3px;
}

.observacao-badge {
    position: absolute;
    top: 12px;
    right: 150px;
    background: #f59e0b;
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* ===== BOTÕES DE AÇÃO MELHORADOS ===== */
.btn:active {
    transform: scale(0.95);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--bg);
    color: var(--primary);
}

/* ===== SCROLL SUAVE ===== */
html {
    scroll-behavior: smooth;
}

/* ===== RESPONSIVIDADE MOBILE ADICIONAL ===== */
@media (max-width: 768px) {
    .dash {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    /* Header mobile - compacto */
    .nav-top {
        flex-direction: row;
        gap: 8px;
        padding: 10px 12px;
        flex-wrap: wrap;
    }
    
    .brand {
        font-size: 0.9rem;
        flex: 1;
        min-width: 120px;
    }
    
    .brand i {
        font-size: 1rem;
    }
    
    .brand-empresa {
        display: none; /* Oculta nome da empresa em mobile */
    }
    
    /* Botões do header mobile - mais compactos */
    .nav-top > div:last-child {
        display: flex;
        gap: 6px;
        align-items: center;
    }
    
    /* Oculta botão entregas em mobile (pode acessar via menu) */
    .nav-top button[onclick*="entregas.html"] {
        display: none !important;
    }
    
    .theme-toggle {
        padding: 8px;
        margin-right: 0;
        font-size: 0.9rem;
    }
    
    .btn-logout {
        font-size: 0.8rem;
        padding: 8px 10px;
    }
    
    .btn-logout i {
        margin-right: 0;
    }
    
    /* Oculta texto "Sair" em mobile, mostra só ícone */
    .btn-logout {
        gap: 0;
    }
    
    /* Filtros responsivos */
    .filters {
        flex-direction: column;
        gap: 8px;
        padding: 10px 12px;
        background: var(--card);
    }
    
    .filters input {
        width: 100%;
        font-size: 16px; /* Evita zoom iOS */
        padding: 12px;
        border-radius: 8px;
    }
    
    .filters button {
        width: 100%;
        font-size: 0.9rem;
        padding: 12px;
        min-height: 44px;
    }
    
    /* Esconde botões de ordenação em mobile */
    .filters .btn-icon {
        display: none;
    }
    
    /* Tabs mobile - scrollável horizontal */
    .tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Oculta scrollbar */
        gap: 5px;
        padding: 8px 12px;
    }
    
    .tabs::-webkit-scrollbar {
        display: none; /* Oculta scrollbar no webkit */
    }
    
    .tab-btn {
        flex-shrink: 0;
        min-width: auto;
        padding: 10px 12px;
        font-size: 0.8rem;
        white-space: nowrap;
    }
    
    /* Cards de serviço mobile */
    .pedido-card {
        padding: 12px;
    }
    
    .pedido-card h4 {
        font-size: 0.9rem;
    }
    
    .pedido-card p {
        font-size: 0.8rem;
        line-height: 1.4;
    }
    
    /* Botões de ação mobile - stack vertical */
    .actions {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .btn {
        font-size: 0.85rem;
        padding: 10px 14px;
        width: 100%;
    }
    
    /* Modais mobile */
    .modal-content-custom {
        width: 95%;
        max-width: 400px;
        margin: 20px auto;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    /* Formulários mobile */
    .form-input,
    .form-textarea {
        font-size: 16px; /* Evita zoom no iOS */
        padding: 12px;
    }
    
    /* Login box mobile */
    .login-box {
        width: 90%;
        padding: 24px;
    }
    
    /* Badge de notificações mobile */
    .badge-noti {
        top: -2px;
        right: -2px;
        font-size: 0.65rem;
        min-width: 18px;
        height: 18px;
    }
}

/* Extra small devices (phones, 480px and down) */
@media (max-width: 480px) {
    .dash {
        grid-template-columns: 1fr;
    }
    
    .brand {
        font-size: 0.85rem;
    }
    
    .brand i {
        font-size: 0.9rem;
    }
    
    .tab-btn {
        min-width: auto;
        padding: 10px;
        font-size: 0.75rem;
        gap: 4px;
    }
    
    .tab-btn i {
        font-size: 0.9rem;
    }
    
    /* Compacta ainda mais o header */
    .nav-top {
        padding: 8px 10px;
    }
    
    .pedido-card h4 {
        font-size: 0.85rem;
    }
    
    .pedido-card p {
        font-size: 0.75rem;
    }
    
    /* Botões flutuantes mobile */
    #floating-delivery-btn {
        padding: 12px 16px;
        font-size: 0.8rem;
        bottom: 70px; /* Ajusta para não cobrir navegação */
    }
    
    /* Adjust modal para telas pequenas */
    .modal-content-custom h3 {
        font-size: 1.1rem;
    }
}

/* Landscape mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .nav-top {
        flex-direction: row;
    }
    
    .brand-empresa {
        display: inline;
        margin-left: 8px;
    }
    
    .dash {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Touch improvements */
@media (hover: none) and (pointer: coarse) {
    /* Aumenta área de toque para dispositivos touch */
    .btn,
    .tab-btn,
    button {
        min-height: 44px; /* Tamanho mínimo recomendado Apple HIG */
    }
    
    /* Remove hover effects em touch devices */
    .btn:hover,
    .tab-btn:hover,
    .pedido-card:hover {
        transform: none;
    }
    
    /* Adiciona feedback visual de toque */
    .btn:active,
    .tab-btn:active {
        transform: scale(0.95);
        opacity: 0.8;
    }
}
