/* ============================================================
   MERCEARIA ELIAN — Estilos Mobile-First
   ============================================================ */

:root {
    --green-dark:   #1a472a;
    --green-mid:    #2d6a4f;
    --green-light:  #52b788;
    --green-pale:   #d8f3dc;
    --accent:       #f4a261;
    --accent-dark:  #e76f51;
    --white:        #ffffff;
    --gray-50:      #f9fafb;
    --gray-100:     #f3f4f6;
    --gray-200:     #e5e7eb;
    --gray-400:     #9ca3af;
    --gray-600:     #4b5563;
    --gray-800:     #1f2937;
    --red:          #ef4444;
    --yellow:       #f59e0b;
    --blue:         #3b82f6;

    --radius:       12px;
    --radius-sm:    8px;
    --shadow:       0 2px 12px rgba(0,0,0,.10);
    --shadow-lg:    0 8px 32px rgba(0,0,0,.15);
    --font-head:    'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --font-body:    'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
    --transition:   .18s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: var(--font-body);
    background: var(--gray-50);
    color: var(--gray-800);
    min-height: 100vh;
    overscroll-behavior: none;
}

#app { min-height: 100vh; }

/* ---- Tipografia ---- */
h1, h2, h3 { font-family: var(--font-head); }

/* ---- Layout base ---- */
.page { min-height: 100vh; display: flex; flex-direction: column; }

.container { width: 100%; max-width: 480px; margin: 0 auto; padding: 0 16px; }

/* ---- Header ---- */
.header {
    background: var(--green-dark);
    color: var(--white);
    padding: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}
.header-inner {
    max-width: 480px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.header-title {
    font-family: var(--font-head);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -.02em;
}
.header-subtitle { font-size: .8rem; opacity: .75; margin-top: 1px; }

/* ---- Login ---- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, var(--green-dark) 0%, var(--green-mid) 100%);
    padding: 24px;
}
.login-card {
    background: var(--white);
    border-radius: 20px;
    padding: 40px 32px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
}
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo .logo-icon {
    width: 64px;
    height: 64px;
    background: var(--green-pale);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 12px;
}
.login-logo h1 {
    font-size: 1.5rem;
    color: var(--green-dark);
    font-weight: 800;
}
.login-logo-text {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--green-dark);
    text-align: center;
}
.login-logo p { color: var(--gray-400); font-size: .9rem; margin-top: 4px; }

/* ---- Formulários ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: .85rem; font-weight: 500; color: var(--gray-600); margin-bottom: 6px; }
.form-input {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--gray-800);
    background: var(--white);
    transition: border-color var(--transition);
    -webkit-appearance: none;
}
.form-input:focus { outline: none; border-color: var(--green-light); }
.form-input::placeholder { color: var(--gray-400); }

select.form-input { cursor: pointer; }
textarea.form-input { resize: vertical; min-height: 80px; }

/* ---- Botões ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    min-height: 48px;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--green-dark); color: var(--white); width: 100%; }
.btn-primary:hover { background: var(--green-mid); }
.btn-success { background: var(--green-light); color: var(--white); }
.btn-success:hover { background: var(--green-mid); }
.btn-accent { background: var(--accent); color: var(--white); }
.btn-accent:hover { background: var(--accent-dark); }
.btn-outline { background: transparent; border: 2px solid var(--green-dark); color: var(--green-dark); }
.btn-danger { background: var(--red); color: var(--white); }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-sm { padding: 8px 16px; font-size: .875rem; min-height: 36px; }
.btn-lg { padding: 18px 32px; font-size: 1.1rem; min-height: 56px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-block { width: 100%; }

/* ---- Cards de Tarefa ---- */
.task-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--gray-200);
    cursor: pointer;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.task-card:active { transform: scale(.99); box-shadow: none; }
.task-card.priority-high { border-left-color: var(--red); }
.task-card.priority-medium { border-left-color: var(--yellow); }
.task-card.priority-low { border-left-color: var(--green-light); }
.task-card.status-done { opacity: .7; }
.task-card.status-late { border-left-color: var(--accent-dark); }

.task-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.task-card-title { font-weight: 600; font-size: .95rem; line-height: 1.3; flex: 1; }
.task-card-meta { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.task-card-time { font-size: .8rem; color: var(--gray-400); }
.task-card-actions { display: flex; gap: 8px; margin-top: 12px; }

/* ---- Badges ---- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge-done    { background: var(--green-pale); color: var(--green-mid); }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-late    { background: #fee2e2; color: #991b1b; }
.badge-cancelled { background: #f3f4f6; color: #6b7280; }
.stat-card { cursor: default; transition: transform .1s, box-shadow .1s; }
.stat-card[data-status]:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.stat-card.stat-active { outline: 3px solid currentColor; outline-offset: 2px; }
.status-cancelled { opacity: .6; }

/* Visibilidade por breakpoint */
.desktop-only { display: none; }
.mobile-only  { display: flex; }

@media (min-width: 900px) {
    .desktop-only { display: block; }
    .mobile-only  { display: none !important; }
}
.badge-high    { background: #fee2e2; color: #991b1b; }
.badge-medium  { background: #fef3c7; color: #92400e; }
.badge-low     { background: var(--green-pale); color: var(--green-mid); }

/* ---- Bottom Nav ---- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--white);
    border-top: 1px solid var(--gray-200);
    display: flex;
    z-index: 100;
    padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 4px;
    cursor: pointer;
    border: none;
    background: none;
    color: var(--gray-400);
    font-size: .7rem;
    font-family: var(--font-body);
    gap: 4px;
    transition: color var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item.active { color: var(--green-dark); }
.bottom-nav-item .nav-icon { font-size: 1.4rem; }
.page-content { padding-bottom: 80px; }

/* ---- Stat Cards ---- */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-card .stat-number { font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif; font-size: 2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
.stat-card .stat-label  { font-size: .78rem; color: var(--gray-400); margin-top: 4px; }
.stat-done   .stat-number { color: var(--green-mid); }
.stat-pending .stat-number { color: var(--yellow); }
.stat-late   .stat-number { color: var(--red); }
.stat-total  .stat-number { color: var(--green-dark); }

/* ---- Progress bar ---- */
.progress-bar { background: var(--gray-200); border-radius: 999px; height: 8px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--green-light); border-radius: 999px; transition: width .4s ease; }

/* ---- Modal / Bottom Sheet ---- */
.overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 200;
    display: flex;
    align-items: flex-end;
    padding: 0;
    animation: fadeIn .15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.bottom-sheet {
    background: var(--white);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    padding: 24px 20px 40px;
    animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

.sheet-handle {
    width: 40px; height: 4px;
    background: var(--gray-200);
    border-radius: 2px;
    margin: 0 auto 20px;
}

.modal-center {
    background: var(--white);
    border-radius: var(--radius);
    width: calc(100% - 32px);
    max-width: 420px;
    margin: auto;
    padding: 24px 20px;
    animation: slideUp .2s ease;
}

/* ---- Foto ---- */
.photo-preview {
    width: 100%;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--gray-100);
    margin: 12px 0;
}
.photo-preview img { width: 100%; display: block; max-height: 260px; object-fit: cover; }
.photo-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px;
    border: 2px dashed var(--gray-200);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--gray-600);
    background: var(--gray-50);
    font-size: .9rem;
    transition: all var(--transition);
}
.photo-upload-btn:hover { border-color: var(--green-light); color: var(--green-mid); }

/* ---- Seção / Título de página ---- */
.page-section { padding: 20px 0 8px; }
.page-section h2 { font-size: 1.15rem; font-weight: 700; color: var(--gray-800); }
.page-section p  { font-size: .85rem; color: var(--gray-400); margin-top: 2px; }

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--gray-400);
}
.empty-state .empty-icon { font-size: 3.5rem; margin-bottom: 12px; }
.empty-state p { font-size: .95rem; }

/* ---- Dias da semana (criação de tarefa) ---- */
.weekdays { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.weekday-btn {
    width: 42px; height: 42px;
    border-radius: 50%;
    border: 2px solid var(--gray-200);
    background: var(--white);
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    -webkit-tap-highlight-color: transparent;
}
.weekday-btn.selected { background: var(--green-dark); border-color: var(--green-dark); color: var(--white); }

/* ---- Toast ---- */
.toast-container { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; width: calc(100% - 32px); max-width: 420px; }
.toast {
    background: var(--gray-800);
    color: var(--white);
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    box-shadow: var(--shadow-lg);
    animation: toastIn .2s ease;
    pointer-events: all;
}
.toast.success { background: var(--green-mid); }
.toast.error   { background: var(--red); }
@keyframes toastIn { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }

/* ---- Loading ---- */
.spinner {
    width: 24px; height: 24px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--green-dark);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; flex-direction: column; gap: 12px; color: var(--gray-400); }

/* ---- Insights ---- */
.insight-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--green-light);
}
.insight-card.warning { border-left-color: var(--yellow); }
.insight-card.error   { border-left-color: var(--red); }
.insight-message { font-size: .9rem; line-height: 1.5; }
.insight-suggestion { font-size: .82rem; color: var(--gray-400); margin-top: 6px; font-style: italic; }

/* ---- Responsivo desktop ---- */
@media (min-width: 640px) {
    .login-card { padding: 48px 40px; }
}
@media (min-width: 640px) and (max-width: 899px) {
    .bottom-nav { max-width: 480px; left: 50%; transform: translateX(-50%); border-radius: 20px 20px 0 0; border: 1px solid var(--gray-200); }
}
/* ============================================================
   MERCEARIA ELIAN — Layout Desktop (≥ 900px)
   ============================================================ */

@media (min-width: 900px) {

    /* ── Estrutura principal ── */
    .page {
        flex-direction: row;
        min-height: 100vh;
    }

    /* ── Sidebar: header + bottom-nav formam a barra lateral ── */
    .header {
        position: fixed;
        top: 0; left: 0;
        width: 240px;
        height: 100vh;
        min-height: 100vh;
        padding: 0;
        box-shadow: none;
        z-index: 100;
        overflow: hidden;
    }
    .header-inner {
        flex-direction: column;
        align-items: flex-start;
        padding: 28px 24px 20px;
        max-width: none;
        border-bottom: 1px solid rgba(255,255,255,.1);
    }
    .header-title { font-size: 1.2rem; }
    .header-subtitle { margin-top: 4px; font-size: .8rem; }
    #mgr-logout, #emp-logout {
        background: rgba(255,255,255,.1) !important;
        border: 1px solid rgba(255,255,255,.2) !important;
        color: var(--white) !important;
        border-radius: var(--radius-sm);
        margin-top: 8px;
        width: 100%;
        justify-content: center;
        font-size: .85rem;
        min-height: 36px;
        padding: 8px;
    }
    #mgr-logout:hover, #emp-logout:hover { background: rgba(255,255,255,.2) !important; }

    /* ── Nav vira continuação da sidebar ── */
    .bottom-nav {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        width: 240px;
        flex-direction: column;
        background: var(--green-dark);
        border: none;
        padding-top: 140px; /* espaço para o header acima */
        padding-bottom: 16px;
        overflow-y: auto;
        box-shadow: 2px 0 16px rgba(0,0,0,.12);
        z-index: 99;
    }
    .bottom-nav-item {
        flex-direction: row;
        justify-content: flex-start;
        padding: 13px 24px;
        font-size: .9rem;
        gap: 12px;
        border-radius: 0;
        color: rgba(255,255,255,.65);
        text-align: left;
        border-left: 3px solid transparent;
        transition: all var(--transition);
        width: 100%;
    }
    .bottom-nav-item:hover {
        background: rgba(255,255,255,.08);
        color: var(--white);
    }
    .bottom-nav-item.active {
        background: rgba(255,255,255,.12);
        color: var(--white);
        border-left-color: var(--accent);
        font-weight: 600;
    }
    .bottom-nav-item .nav-icon { font-size: 1.15rem; }

    /* ── Área de conteúdo ── */
    .page-content {
        margin-left: 240px;
        flex: 1;
        padding-bottom: 0;
        min-height: 100vh;
        background: var(--gray-50);
    }
    .container {
        max-width: 960px;
        padding: 32px 40px;
    }

    /* ── Stats 4 colunas ── */
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
    .stat-card {
        padding: 20px;
    }
    .stat-card .stat-number { font-size: 2.4rem; }

    /* ── Overlays como modais centrados ── */
    .overlay {
        align-items: center;
        justify-content: center;
        padding: 24px;
    }
    .bottom-sheet {
        border-radius: var(--radius);
        max-width: 560px;
        max-height: 88vh;
        animation: modalPop .2s ease;
    }
    @keyframes modalPop {
        from { opacity: 0; transform: scale(.97) translateY(8px); }
        to   { opacity: 1; transform: scale(1)  translateY(0); }
    }
    .sheet-handle { display: none; }

    /* ── Task cards em grid 2 colunas ── */
    .desktop-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
    .desktop-grid .task-card { margin-bottom: 0; }

    /* ── Dashboard: coluna principal + lateral ── */
    .desktop-dashboard {
        display: grid;
        grid-template-columns: 1fr 340px;
        gap: 28px;
        align-items: start;
    }
    .desktop-dashboard-main { min-width: 0; }
    .desktop-dashboard-side {
        position: sticky;
        top: 32px;
    }

    /* ── Formulários mais largos ── */
    .modal-center {
        max-width: 560px;
    }

    /* ── Page section no desktop ── */
    .page-section { padding: 8px 0 12px; }
    .page-section h2 { font-size: 1.25rem; }

    /* ── Task cards no dashboard em grid ── */
    #mgr-content .mgr-task-card-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

    /* ── Grid de tarefas do colaborador ── */
    .emp-task-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 14px;
    }
    .emp-task-grid .task-card { margin-bottom: 0; }

    /* ── Layout do colaborador no desktop: navegação de data mais larga ── */
    .emp-date-nav {
        background: var(--white);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        padding: 16px 20px;
        margin-bottom: 20px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    /* ── Stats do colaborador em 4 colunas ── */
    .emp-stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    /* ── Progress bar mais estilosa ── */
    .progress-bar { height: 10px; }
}

/* ── Breakpoint médio: tablet ── */
@media (min-width: 640px) and (max-width: 899px) {
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
}


/* ---- Utilitários ---- */
.text-center { text-align: center; }
.text-sm { font-size: .85rem; }
.text-xs { font-size: .75rem; }
.text-muted { color: var(--gray-400); }
.text-success { color: var(--green-mid); }
.text-danger  { color: var(--red); }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
