/* ============================================================
   CF MODAL — Modal reutilizável ("Ver todos") + lista compacta
   de pedidos (padrão do modal de Solicitações Pendentes).
   Cores claras de propósito: o tema escuro inverte tudo
   automaticamente (css/theme.css).
   ============================================================ */

/* Trava a rolagem da página enquanto um modal está aberto */
body.cfm-scroll-lock {
    overflow: hidden !important;
}

/* ── Overlay + caixa ── */
.cfm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 1300; /* acima da navegação inferior mobile (1200) */
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(16px, env(safe-area-inset-top, 0px))
             max(16px, env(safe-area-inset-right, 0px))
             max(16px, env(safe-area-inset-bottom, 0px))
             max(16px, env(safe-area-inset-left, 0px));
    animation: cfmFade .18s ease;
}

.cfm-box {
    background: white;
    border-radius: 16px;
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    max-height: calc(100dvh - 32px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
    animation: cfmUp .22s ease;
}

.cfm-head {
    padding: 16px 20px 14px;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex-shrink: 0;
}

.cfm-head-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #f3f4f6;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 15px;
}

.cfm-head-info {
    flex: 1;
    min-width: 0;
}

.cfm-title {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.cfm-badge {
    font-size: 12px;
    font-weight: 600;
    background: #f3f4f6;
    color: #374151;
    padding: 2px 10px;
    border-radius: 8px;
    white-space: nowrap;
}

.cfm-subtitle {
    font-size: 12px;
    color: #9ca3af;
    margin: 4px 0 0;
}

.cfm-close {
    width: 36px;
    height: 36px;
    border: none;
    background: #f3f4f6;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    color: #6b7280;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s, color .15s;
}

.cfm-close:hover {
    background: #fee2e2;
    color: #ef4444;
}

.cfm-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    padding: 16px 20px;
}

/* Botão "Ver todas / Mostrar mais" no rodapé de cards e listas */
.cfm-vermais {
    width: 100%;
    margin-top: 4px;
    padding: 10px;
    background: #f9fafb;
    border: 1.5px dashed #d1d5db;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    color: #374151;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all .15s ease;
}

.cfm-vermais:hover {
    border-color: var(--primary);
    background: var(--primary-tint);
    color: var(--primary-darker);
}

/* Cabeçalho de card clicável (dashboard) */
.cf-clicavel {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.cf-clicavel:hover .section-action {
    color: var(--primary-dark);
    text-decoration: underline;
}

@keyframes cfmFade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes cfmUp {
    from { opacity: 0; transform: translateY(14px) scale(.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   CFP — Item de pedido em lista compacta expansível
   (usado na tela de Pedidos e no modal "Todos os Pedidos")
   ============================================================ */
.cfp-lista {
    display: flex;
    flex-direction: column;
}

.cfp-item {
    border: 1.5px solid #e5e7eb;
    border-radius: 14px;
    margin-bottom: 10px;
    overflow: hidden;
    background: white;
    transition: border-color .15s, box-shadow .15s;
}

.cfp-item.aberto {
    border-color: var(--primary-soft);
    box-shadow: 0 4px 16px rgba(0, 0, 0, .07);
}

.cfp-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    width: 100%;
    min-height: 60px;
    border: none;
    background: transparent;
    text-align: left;
    font-family: inherit;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: background .15s;
}

.cfp-head:hover {
    background: #f9fafb;
}

.cfp-head-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--primary-tint);
    color: var(--primary-darker);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 14px;
}

.cfp-head-info {
    flex: 1;
    min-width: 0;
}

.cfp-head-num {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.cfp-head-sub {
    font-size: 11px;
    color: #9ca3af;
    margin-top: 3px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}

.cfp-head-sub i {
    font-size: 10px;
    margin-right: 3px;
}

.cfp-sub-cliente {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.cfp-head-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.cfp-head-valor {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
    white-space: nowrap;
}

.cfp-chevron {
    color: #9ca3af;
    font-size: 12px;
    transition: transform .2s;
    flex-shrink: 0;
    margin-left: 2px;
}

.cfp-item.aberto .cfp-chevron {
    transform: rotate(180deg);
}

.cfp-alerta-dot {
    color: #f59e0b;
    font-size: 12px;
}

.cfp-chip-catalogo {
    font-size: 10px;
    background: #fce8ef;
    color: #c41854;
    padding: 1px 7px;
    border-radius: 8px;
    font-weight: 700;
}

/* Corpo expandido */
.cfp-body {
    border-top: 1px solid #f3f4f6;
    animation: cfmFade .15s ease;
}

.cfp-rows {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cfp-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    color: #374151;
    min-width: 0;
}

.cfp-row > i {
    color: #9ca3af;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
    margin-top: 2px;
    font-size: 12px;
}

.cfp-row > span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.cfp-row-label {
    color: #9ca3af;
}

.cfp-pag-forma {
    font-size: 11px;
    color: #6b7280;
    background: #f3f4f6;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.cfp-pag-status {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.cfp-pag-status.pago      { background: #dcfce7; color: #166534; }
.cfp-pag-status.pendente  { background: #fef3c7; color: #92400e; }
.cfp-pag-status.parcial   { background: var(--primary-tint-2); color: var(--primary-darker); }
.cfp-pag-status.cancelado { background: #fee2e2; color: #991b1b; }

/* Alerta de comprovante pendente dentro do corpo expandido */
.cfp-alerta {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 600;
    color: #c2410c;
}

.cfp-alerta i {
    color: #f97316;
    font-size: 12px;
    flex-shrink: 0;
}

/* Rodapé de ações do item */
.cfp-footer {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: #f9fafb;
    border-top: 1px solid #f3f4f6;
    flex-wrap: wrap;
}

.cfp-btn-det,
.cfp-btn-avancar,
.cfp-btn-up {
    flex: 1;
    min-width: 130px;
    min-height: 40px;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all .15s;
}

.cfp-btn-det {
    background: #f9fafb;
    border: 1.5px solid #e5e7eb;
    color: #374151;
}

.cfp-btn-det:hover {
    background: var(--primary-tint);
    border-color: var(--primary-soft);
    color: var(--primary-darker);
}

.cfp-btn-avancar {
    background: #f0fdf4;
    border: 1.5px solid #86efac;
    color: #166534;
}

.cfp-btn-avancar:hover {
    background: #dcfce7;
}

/* Botão "Comprovante" (upload) usado na lista do vendedor */
.cfp-btn-up {
    background: #fffbeb;
    border: 1.5px solid #fcd34d;
    color: #92400e;
}

.cfp-btn-up:hover {
    background: #fef3c7;
}

/* Badges de status do pedido (mesmas cores do sistema) */
.cfp-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.cfp-badge.pendente  { background: #fef3c7; color: #92400e; }
.cfp-badge.pago      { background: #dcfce7; color: #166534; }
.cfp-badge.separacao,
.cfp-badge.separado  { background: #e0e7ff; color: #3730a3; }
.cfp-badge.enviado   { background: #d1fae5; color: #065f46; }
.cfp-badge.entregue  { background: #dcfce7; color: #14532d; }
.cfp-badge.cancelado { background: #fee2e2; color: #991b1b; }
.cfp-badge.default   { background: #f3f4f6; color: #6b7280; }

/* ── Mobile: respeita área segura e navegação inferior ── */
@media (max-width: 768px) {
    .cfm-overlay {
        padding: calc(env(safe-area-inset-top, 0px) + 12px)
                 12px
                 calc(var(--bottom-nav-height, 62px) + env(safe-area-inset-bottom, 0px) + 12px);
    }

    .cfm-box {
        max-height: 100%;
    }

    .cfm-close {
        width: 40px;
        height: 40px;
    }

    .cfp-head {
        padding: 12px;
        gap: 10px;
    }

    .cfp-head-icon {
        width: 34px;
        height: 34px;
        font-size: 13px;
    }

    .cfp-head-sub .cfp-sub-extra {
        display: none; /* no fechado, mobile mostra só data + cliente */
    }

    .cfp-footer .cfp-btn-det,
    .cfp-footer .cfp-btn-avancar,
    .cfp-footer .cfp-btn-up {
        min-height: 44px;
    }
}
