/* ═══════════════════════════════════════
   HISTORY — modal e cards do histórico
═══════════════════════════════════════ */

/* ── Overlay ── */
#history-overlay {
    position: fixed;
    inset: 0;
    background: rgba(28, 25, 23, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: overlayIn 0.25s ease both;
}
#history-overlay.closing {
    animation: overlayOut 0.22s ease forwards;
}
#history-overlay.closing #history-modal {
    animation: modalOut 0.22s ease forwards;
}

/* ── Modal ── */
#history-modal {
    background: var(--card);
    width: 100%;
    max-width: 480px;
    border-radius: var(--radius);
    box-shadow: 0 30px 80px -10px rgba(0,0,0,0.3);
    padding: 24px 24px 20px;
    max-height: 82vh;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ── Cabeçalho do modal ── */
.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-shrink: 0;
}
.history-title-group {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary);
}
.history-title-group svg { width: 20px; height: 20px; }
.history-title-group h2 {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--text);
}

#closeHistoryBtn {
    background: var(--bg);
    border: 1.5px solid var(--border);
    width: 34px;
    height: 34px;
    border-radius: 9px;
    cursor: pointer;
    display: grid;
    place-items: center;
    color: var(--muted);
    transition: all 0.18s;
    flex-shrink: 0;
}
#closeHistoryBtn:hover {
    background: var(--danger-light);
    color: var(--danger);
    border-color: var(--danger);
}
#closeHistoryBtn svg { width: 16px; height: 16px; }

/* ── Lista scrollável ── */
#history-list {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

/* ── Card de entrada ── */
.history-card {
    border: 1.5px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    background: #fff;
    flex-shrink: 0;
    transition: border-color 0.22s, box-shadow 0.22s, transform 0.22s;
    animation: itemIn 0.32s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.history-card:hover {
    border-color: #a7f3d0;
    box-shadow: 0 6px 24px rgba(26,92,58,0.11);
    transform: translateY(-1px);
}

/* Topo verde */
.history-card-top {
    background: linear-gradient(135deg, var(--primary) 0%, #22865a 100%);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.history-entry-label {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.history-index {
    width: 26px;
    height: 26px;
    background: rgba(255,255,255,0.18);
    border-radius: 7px;
    display: grid;
    place-items: center;
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 0.85rem;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
}
.history-date {
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(255,255,255,0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.history-item-count {
    background: rgba(255,255,255,0.18);
    border-radius: 100px;
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 800;
    color: #fff;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Corpo — todos os chips */
.history-card-body {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.history-items-preview {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.preview-chip {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 100px;
    padding: 4px 11px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
    line-height: 1.3;
}

/* Rodapé com ações */
.history-card-footer {
    padding: 10px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: #fafaf8;
}
.btn-use-history {
    flex: 1;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    font-size: 0.82rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-use-history:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 14px rgba(26,92,58,0.3);
}
.btn-use-history svg { width: 14px; height: 14px; }

.btn-del-history {
    background: none;
    border: 1.5px solid var(--border);
    width: 34px;
    height: 34px;
    border-radius: 8px;
    cursor: pointer;
    display: grid;
    place-items: center;
    color: var(--muted);
    transition: all 0.18s;
    flex-shrink: 0;
}
.btn-del-history:hover {
    background: var(--danger-light);
    color: var(--danger);
    border-color: #fca5a5;
}
.btn-del-history svg { width: 15px; height: 15px; }

/* ── Empty state do histórico ── */
#history-empty {
    text-align: center;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}
#history-empty svg {
    width: 40px;
    height: 40px;
    color: #d4d0cc;
    margin-bottom: 6px;
}
#history-empty p {
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 1rem;
    font-weight: 800;
    color: #c4bfbb;
}
#history-empty span { font-size: 0.82rem; color: #c4bfbb; }
