/* =========================================================================
   BLINDAGEM NATIVA E RESETS (Apple & Google Play)
   ========================================================================= */
* {
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; 
    -webkit-tap-highlight-color: transparent; 
    outline: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

input, select, textarea {
    -webkit-user-select: auto;
    user-select: auto;
}

html { 
    max-width: 100vw; 
    overflow-x: hidden; 
}

/* Oculta as setas nativas em campos numéricos globalmente */
input[type="number"]::-webkit-inner-spin-button, 
input[type="number"]::-webkit-outer-spin-button { 
    -webkit-appearance: none; 
    margin: 0; 
}
input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* =========================================================================
   CLEANPRO - VARIÁVEIS GLOBAIS E ESTRUTURA BASE (Mobile Otimizado)
   ========================================================================= */
:root {
    --primary: #7dd3fc;
    --primary-dark: #0369a1;
    --bg-color: #f5f3ee;
    --card-bg: #ffffff;
    --text-main: #334155;
    --text-light: #64748b;
    --success: #86efac;
    --success-dark: #15803d;
    --warning: #fde047;
    --warning-dark: #a16207;
    --danger: #fca5a5;
    --danger-dark: #b91c1c;
    --border: #e2e8f0;
    --freelancer: #e9d5ff;
    --freelancer-dark: #6b21a8;
    --shadow: 0 2px 10px rgba(0,0,0,0.04);
}

body { 
    background-color: var(--bg-color); 
    color: var(--text-main); 
    padding-bottom: calc(90px + env(safe-area-inset-bottom)); 
    overflow-x: clip; 
    font-size: 0.95rem; /* Base mais compacta para mobile */
}

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-light { color: var(--text-light); }

/* Logo & Header */
.pin-logo { width: 180px; margin-bottom: 10px; border-radius: 16px; background-color: transparent; }
.header-logo-small { height: 44px; width: auto; object-fit: contain; border-radius: 8px; background-color: transparent; }
.luxury-header { background-color: rgba(255, 255, 255, 0.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); padding: 10px 16px; position: sticky; top: 0; z-index: 1000; box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.header-brand-box { display: flex; align-items: center; justify-content: center; width: 100%; }

/* PIN Screen */
.pin-container { height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; background: #f5f3ee; padding: 16px; }
.pin-box { background: white; padding: 30px 16px; border-radius: 20px; box-shadow: 0 8px 30px rgba(0,0,0,0.05); width: 100%; max-width: 340px; text-align: center; border: 1px solid #e5e1d8; }
.pin-instruction { font-size: 0.9rem; color: var(--text-main); margin-bottom: 16px; font-weight: 600; line-height: 1.4; }
.cloud-status-indicator { font-size: 0.8rem; font-weight: 700; color: var(--text-light); margin-top: 15px; min-height: 20px; }
.pin-input-group { display: flex; justify-content: center; gap: 8px; }
.pin-field { width: 50px; height: 64px; text-align: center; font-size: 1.8rem; border: 2px solid #e2e8f0; border-radius: 12px; background: #f8fafc; font-weight: 800; color: #8c7343; transition: 0.2s; }
.pin-field:focus { border-color: #8c7343; background: white; box-shadow: 0 0 0 3px rgba(140, 115, 67, 0.1); }

/* Dashboard Toggle Mobile Friendly */
.view-toggle { display: flex; background: var(--border); border-radius: 14px; padding: 4px; margin-bottom: 16px; }
.toggle-option { flex: 1; text-align: center; padding: 10px; border-radius: 10px; font-weight: 700; color: var(--text-light); cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 0.9rem; }
.toggle-option.active { background: white; color: var(--primary-dark); box-shadow: var(--shadow); }

/* =========================================================================
   FORMULÁRIOS, INPUTS E CARTÕES (Otimizados para Espaço)
   ========================================================================= */
.section { display: none; padding: 14px; animation: fadeIn 0.2s ease-out; max-width: 1200px; margin: 0 auto; }
.section.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; } }

.form-card { background: white; padding: 16px; border-radius: 16px; box-shadow: var(--shadow); border: 1px solid var(--border); margin-bottom: 16px; height: 100%; }
.form-title { display: flex; align-items: center; gap: 8px; color: var(--primary-dark); font-size: 1.05rem; border-bottom: 1px solid var(--border); padding-bottom: 8px; font-weight: bold;}

label { display: block; font-size: 0.75rem; font-weight: 800; color: var(--text-light); margin: 12px 0 4px 0; text-transform: uppercase; letter-spacing: 0.5px; }
input, select, textarea { width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--border); font-size: 0.95rem; background: #f8fafc; color: var(--text-main); transition: 0.2s; }
input:focus, select:focus, textarea:focus { border-color: var(--primary-dark); background: white; box-shadow: 0 0 0 3px rgba(3, 105, 161, 0.1); }
select { padding-right: 32px; background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%2364748b%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E"); background-repeat: no-repeat; background-position: right 12px top 50%; background-size: 10px auto; }

/* Custom Inputs (Telefones e Moeda) */
.phone-input-group { display: flex; gap: 8px; margin: 4px 0 12px 0; }
.phone-prefix { width: 100px !important; flex-shrink: 0; font-weight: 800; font-size: 0.85rem !important;}
.phone-number { flex: 1; }

.money-input-wrapper { position: relative; display: flex; align-items: center; }
.money-symbol { position: absolute; left: 14px; font-weight: bold; font-size: 1rem; color: var(--primary-dark); }
.money-field { padding-left: 32px !important; font-weight: bold !important; font-size: 1rem !important; }
.highlight-field { border-color: var(--primary) !important; background: #f0f9ff !important; }
.danger-symbol { color: var(--danger-dark); }
.danger-field { border-color: var(--danger) !important; background: #fef2f2 !important; color: var(--danger-dark) !important; }

/* Gestão de Equipa */
.equipe-label { background: var(--bg-color); border: 2px dashed var(--border); padding: 14px; border-radius: 12px; cursor: pointer; display: flex; align-items: center; gap: 10px; margin-top: 16px; transition: 0.2s; }
.equipe-label:active { background: #e2e8f0; }
.equipe-label input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--primary-dark); }

.freelancer-box { background-color: #faf5ff; padding: 14px; border-radius: 12px; margin-top: 12px; border: 1px dashed var(--freelancer-dark); }
.equipe-group { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.membro-pill { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-radius: 10px; border: 1.5px solid var(--border); background: white; font-weight: 700; color: var(--text-main); cursor: pointer; transition: 0.2s; font-size: 0.9rem; }
.membro-pill input[type="checkbox"] { display: none; }
.membro-pill.active-membro { background: var(--freelancer-dark); color: white; border-color: var(--freelancer-dark); transform: scale(1.02); box-shadow: 0 4px 10px rgba(107, 33, 168, 0.15); }
.membro-pill::after { content: 'add_circle_outline'; font-family: 'Material Icons Round'; font-size: 20px; color: var(--text-light); transition: 0.2s; }
.membro-pill.active-membro::after { content: 'check_circle'; color: white; }

.dias-semana-group { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.dia-pill { flex: 1; min-width: 32px; text-align: center; background: white; border: 1.5px solid var(--border); padding: 8px 0; border-radius: 8px; font-weight: 800; color: var(--text-light); cursor: pointer; transition: 0.2s; font-size: 0.85rem; }
.dia-pill.active-dia { background: var(--primary-dark); color: white; border-color: var(--primary-dark); transform: scale(1.05); }

/* Layout Inputs Lado a Lado */
.row-inputs-mobile { display: flex; flex-direction: column; gap: 10px; }
.time-inputs-mobile { display: flex; gap: 10px; }
.col-input { flex: 1; width: 100%; }
@media (min-width: 480px) {
    .row-inputs-mobile { flex-direction: row; align-items: flex-end; }
    .data-input-mobile { flex: 1.5; }
    .time-inputs-mobile { flex: 2; }
}

/* =========================================================================
   LISTAGENS, CARTÕES E BOTÕES (Dashboard, Clientes e Equipa)
   ========================================================================= */
.dashboard-header-date { background: white; padding: 12px 16px; border-radius: 14px; margin-bottom: 14px; border: 1px solid var(--border); box-shadow: var(--shadow); display: flex; justify-content: space-between; align-items: center; }
.dashboard-header-date input { width: auto; border: none; padding: 0; font-weight: 800; color: var(--primary-dark); font-size: 1.15rem; background: transparent; margin-top: 0;}
.btn-calendar { background: var(--primary); color: var(--primary-dark); width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; border-radius: 10px; }

.filtros { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.filtros::-webkit-scrollbar { display: none; }
.chip { background: white; border: 1px solid var(--border); padding: 10px 16px; border-radius: 18px; font-size: 0.85rem; font-weight: 700; color: var(--text-light); cursor: pointer; white-space: nowrap; transition: 0.2s; }
.chip.active { background: var(--primary); color: var(--primary-dark); border-color: var(--primary); }

.card-servico, .card-list-item { background: white; border-radius: 16px; padding: 16px; margin-bottom: 14px; border: 1px solid var(--border); box-shadow: var(--shadow); }
.info-linha { display: flex; align-items: flex-start; gap: 8px; color: var(--text-light); font-size: 0.9rem; margin-bottom: 6px; line-height: 1.3; }

/* Botões Padronizados (Toque ideal = 48px min) */
.card-actions { display: flex; gap: 8px; margin-top: 14px; }
.btn-large { min-height: 48px !important; font-size: 0.9rem !important; border-radius: 12px !important; }
.btn-status { flex: 2; border: none; border-radius: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 12px; cursor: pointer; transition: 0.15s; font-size: 0.9rem; }
.btn-status:active { transform: scale(0.96); opacity: 0.9; }
.btn-status.pendente { background: var(--primary); color: var(--primary-dark); }
.btn-status.concluido { background: var(--success); color: var(--success-dark); }

.btn-icon { flex: 0.6; height: 48px; border: none; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; cursor: pointer; transition: 0.15s; }
.btn-icon:active { transform: scale(0.92); }
.btn-whatsapp { background-color: #dcfce7; color: #166534; }
.btn-maps { background-color: #e0f2fe; color: #0369a1; }

.search-bar { display: flex; align-items: center; background-color: #f8fafc; border: 1.5px solid var(--border); border-radius: 12px; padding: 4px 12px; margin-bottom: 14px; transition: 0.2s; }
.search-bar:focus-within { border-color: var(--primary-dark); background: white; }
.search-bar input { border: none; padding: 10px 8px; background: transparent; font-weight: 600; font-size: 0.95rem; width: 100%; outline: none; }

/* =========================================================================
   FINANCEIRO & COMPONENTES EXTRAS
   ========================================================================= */
.financeiro-resumo-mobile { display: flex; justify-content: space-between; align-items: center; background: #f8fafc; padding: 14px; border-radius: 14px; border: 1px solid var(--border); }
.fin-col { flex: 1; border-right: 1px solid #cbd5e1; padding: 0 4px; }
.fin-col.no-border { border-right: none; }
.fin-col span { font-size: 0.65rem; color: var(--text-light); font-weight: 800; display: block; margin-bottom: 4px; text-transform: uppercase;}
.fin-col strong { font-size: 1rem; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-main); }

.finance-progress-bar { width: 100%; height: 6px; background: #fee2e2; border-radius: 8px; overflow: hidden; margin-top: 14px; display: flex; }
.finance-progress-fill { height: 100%; background: var(--success); transition: width 0.5s ease; }

.btn-export { background: #f8fafc; border: 1px solid var(--border); color: var(--primary-dark); font-weight: bold; border-radius: 12px; padding: 12px; display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 14px; width: 100%; transition: 0.2s; font-size: 0.9rem; }
.btn-export:active { background: #e2e8f0; transform: scale(0.98); }

.autocomplete-box { display: none; position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1.5px solid var(--primary-dark); border-radius: 12px; margin-top: 4px; z-index: 100; max-height: 200px; overflow-y: auto; box-shadow: 0 10px 25px rgba(0,0,0,0.1); }
.autocomplete-item { padding: 14px; cursor: pointer; border-bottom: 1px solid #f1f5f9; color: var(--text-main); font-weight: 700; font-size: 0.95rem; display: flex; align-items: center; }
.autocomplete-item:hover, .autocomplete-item:active { background: #f8fafc; color: var(--primary-dark); }

/* =========================================================================
   BOTTOM NAVIGATION BAR (Estilo App Nativa)
   ========================================================================= */
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: flex; justify-content: space-around; align-items: flex-end; padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid rgba(0,0,0,0.08); z-index: 2000; }
.nav-item { border: none; background: none; color: var(--text-light); font-size: 0.65rem; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; flex: 1; font-weight: 800; cursor: pointer; min-height: 48px; transition: 0.2s; }
.nav-item i { font-size: 24px; margin-bottom: 4px; transition: 0.2s; }
.nav-item.active-nav { color: var(--primary-dark); }
.nav-item.active-nav i { transform: scale(1.15); }

/* Botão Central de Adicionar Agendamento */
.nav-main-btn { background: var(--primary-dark); color: white; width: 42px; height: 42px; border-radius: 14px; display: flex; align-items: center; justify-content: center; margin-bottom: -2px; box-shadow: 0 4px 10px rgba(3, 105, 161, 0.3); }
.nav-main-btn i { font-size: 24px; margin: 0; color: white; }

/* =========================================================================
   FULLCALENDAR (Ajustes de Grid para Mobile)
   ========================================================================= */
#dashboard-view-calendario { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 20px; }
#dashboard-view-calendario .form-card { min-width: 800px; width: 100%; display: block; }
#calendar { width: 100%; min-width: auto; }
.fc .fc-toolbar-chunk:last-child { display: flex; justify-content: flex-end; padding-right: 12px; }
.fc .fc-toolbar { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; margin-bottom: 14px !important; min-width: 800px; }
.fc .fc-scrollgrid-section-header > * { position: sticky !important; top: 0 !important; z-index: 100 !important; background: var(--card-bg) !important; }
.fc-col-header-cell-cushion { font-weight: 900 !important; color: var(--primary-dark) !important; text-transform: uppercase; padding: 8px 0 !important; font-size: 0.8rem; }
.fc-theme-standard td, .fc-theme-standard th { border-color: #cbd5e1 !important; }
.fc-daygrid-event { border-radius: 6px; padding: 4px; border: none !important; margin-bottom: 4px !important; box-shadow: 0 2px 4px rgba(0,0,0,0.05); cursor: pointer; white-space: normal !important; word-wrap: break-word; font-size: 0.8rem; }
.fc-event-main { overflow: hidden; }
.fc .fc-toolbar-title { font-size: 1.2rem !important; color: var(--primary-dark); font-weight: 900; text-transform: capitalize; padding-left: 4px; }
.fc .fc-button-primary { background-color: var(--primary) !important; border-color: var(--primary) !important; color: var(--primary-dark) !important; font-weight: bold; border-radius: 8px; padding: 6px 12px; font-size: 0.85rem; box-shadow: none !important; }

/* =========================================================================
   MODAIS SWEETALERT E LAYOUTS (Correção Definitiva Mobile)
   ========================================================================= */
.lang-option { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 14px; background: #f8fafc; cursor: pointer; transition: 0.2s; }
.lang-option.active-lang { border-color: var(--primary-dark); background: #f0f9ff; }
.lang-option:active { transform: scale(0.98); }

/* Força os popups acima de tudo, inclusive navbar, sempre ao centro */
.swal2-container {
    z-index: 99999 !important;
    position: fixed !important;
    inset: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow-y: auto !important;
    padding: 16px !important;
}
.swal2-popup.swal-app-popup,
.swal2-popup {
    margin: auto !important;
}
body.swal2-height-auto { height: auto !important; }

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.modal-box {
    background: white;
    width: 100%;
    max-width: 420px;
    max-height: 90dvh;
    overflow-y: auto;
    border-radius: 20px;
    padding: 20px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.18);
}

.extrato-toolbar {
    justify-content: space-between;
    margin-top: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    gap: 10px;
}
.btn-nova-despesa {
    background: #fef2f2;
    color: var(--danger-dark);
    border: 1.5px solid #fecaca;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 0.8rem;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.btn-nova-despesa i { font-size: 18px; }

@media (max-width: 768px) {
    .swal2-popup {
        width: 96% !important;
        max-height: 88dvh !important;
        padding: 16px !important;
        margin: auto !important;
        box-sizing: border-box !important;
        border-radius: 20px !important;
        overflow-y: auto !important;
    }
    
    .swal2-html-container {
        max-height: none !important;
        overflow: visible !important;
        margin: 1em 0 0 !important;
        padding: 0 4px !important;
    }
    
    .swal2-actions {
        flex-direction: column !important;
        width: 100% !important;
        gap: 10px !important;
        margin-top: 15px !important;
    }
    
    .swal2-confirm, .swal2-cancel, .swal2-deny {
        width: 100% !important;
        margin: 0 !important;
        min-height: 48px !important;
        border-radius: 12px !important;
        font-size: 0.95rem !important;
    }
    
    .swal-z-index-fix {
        padding: 12px !important;
        align-items: center !important;
        justify-content: center !important;
    }
}

/* Layouts PC */
@media (min-width: 1024px) {
    .pc-layout { display: flex; gap: 24px; align-items: flex-start; }
    .pc-col { flex: 1; }
    .bottom-nav { max-width: 1200px; margin: 0 auto; border-radius: 16px 16px 0 0; left: 0; right: 0; }
}

/* Compactação da Navbar Inferior (75% do tamanho) */
.bottom-nav { padding: 4px 0 calc(4px + env(safe-area-inset-bottom)); }
.nav-item { min-height: 42px; font-size: 0.6rem; }
.nav-item i { font-size: 20px; margin-bottom: 2px; }
.nav-main-btn { width: 38px; height: 38px; border-radius: 12px; }
.nav-main-btn i { font-size: 22px; }

/* Compactação dos Cartões e Botões no Dashboard */
.card-servico, .card-list-item { padding: 12px 14px; margin-bottom: 10px; border-radius: 12px; }
.info-linha { margin-bottom: 4px; font-size: 0.85rem; }
.card-actions { margin-top: 10px; gap: 6px; }
.btn-large { min-height: 38px !important; font-size: 0.85rem !important; border-radius: 8px !important; }
.btn-status { padding: 8px; font-size: 0.8rem; border-radius: 8px; }
.btn-icon { height: 38px; font-size: 1.1rem; border-radius: 8px; }

/* Correção de Inputs Cortados (Prefixo e Data/Hora) */
.phone-input-group { flex-wrap: nowrap; }
.phone-prefix { width: 115px !important; padding: 0 4px !important; text-align: center; font-size: 0.85rem !important; }
.time-inputs-mobile { display: flex; flex-wrap: wrap; gap: 8px; }
.time-inputs-mobile .col-input { flex: 1; min-width: 45%; }

/* Alinhamento de Texto no Calendário */
.fc-daygrid-event { padding: 4px; }
.fc-event-main { display: flex; align-items: center; justify-content: flex-start; text-align: left; }

/* Menu ativo durante o tour, por cima do sombreado */
body.tour-ativo .bottom-nav { z-index: 1000000001 !important; }
.tour-menu-foco {
    position: relative;
    z-index: 1000000001 !important;
    box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--primary-dark);
    border-radius: 14px;
}
.tour-exemplo-tag {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--primary-dark);
    background: #e0f2fe;
    border-radius: 8px;
    padding: 2px 8px;
    margin-bottom: 8px;
}