/* --- Variáveis de Tema (Amarelo Banana e Dark Deep) --- */
:root {
    --bg-color: #0d1117;       
    --card-bg: rgba(22, 27, 34, 0.8); /* Glassmorphism base */
    --primary-color: #e3b341;  
    --primary-hover: #c49933;  
    --text-color: #f0f6fc;     
    --text-muted: #8b949e;     
    --border-color: rgba(48, 54, 61, 0.7);   
    --danger-color: #f85149;   
    --glass-blur: blur(12px);
}

/* --- Reset Básico --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 20% 20%, rgba(227, 179, 65, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(227, 179, 65, 0.05) 0%, transparent 40%);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- Utilitários --- */
.hidden {
    display: none !important;
}

/* --- Splash Screen --- */
.splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.8s;
}

.splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.splash-logo {
    width: 140px;
    height: 140px;
    margin-bottom: 24px;
    filter: drop-shadow(0 0 20px rgba(227, 179, 65, 0.3));
    animation: floating 3s ease-in-out infinite;
}

@keyframes floating {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(5deg); }
}

.splash-title {
    color: var(--primary-color);
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -1px;
}

/* --- Cabeçalho --- */
header {
    width: 100%;
    background-color: rgba(22, 27, 34, 0.7);
    backdrop-filter: var(--glass-blur);
    padding: 16px 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.btn-back {
    position: absolute;
    left: 20px;
    background: rgba(227, 179, 65, 0.1);
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    font-size: 1rem;
    padding: 8px 14px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
}

.btn {
    padding: 14px;
    border: none;
    border-radius: 12px;
    background-color: var(--primary-color);
    color: #0d1117;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
}

.btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(227, 179, 65, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.header-logo {
    width: 36px;
    height: 36px;
}

header h1 {
    color: var(--primary-color);
    font-size: 1.3rem;
    font-weight: 700;
}

/* --- Container Principal --- */
main {
    width: 100%;
    max-width: 480px;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    flex-grow: 1; /* Faz o main crescer para preencher a tela */
}

.view {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex-grow: 1;
}

/* Centraliza o empty state no espaço restante */
.empty-state:not(.hidden) {
    flex-grow: 1;
    justify-content: center;
}

.view.hidden {
    display: none;
}

/* --- Barra de Filtros --- */
.filter-bar {
    display: flex;
    gap: 8px;
    padding: 4px;
    background: rgba(22, 27, 34, 0.95);
    backdrop-filter: var(--glass-blur);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    overflow-x: auto;
    position: sticky;
    top: 73px; /* Logo abaixo do header */
    z-index: 50;
}

.filter-btn {
    flex: 1;
    padding: 10px 14px;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
}

.filter-btn.active {
    background: var(--primary-color);
    color: #0d1117;
    box-shadow: 0 2px 8px rgba(227, 179, 65, 0.3);
}

.filter-btn:not(.active):hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
}

/* --- Cartões e Itens --- */
.market-item, .product-item, .add-section, .summary-section, .modal-content {
    background-color: var(--card-bg);
    backdrop-filter: var(--glass-blur);
    border-radius: 18px;
    border: 1px solid var(--border-color);
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.market-item {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    border-left: 5px solid var(--primary-color);
    margin-bottom: 4px;
}

.market-item.completed {
    border-left-color: var(--text-muted);
    opacity: 0.5;
}

.market-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.market-name {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--primary-color);
}

.completed .market-name {
    text-decoration: line-through;
    color: var(--text-muted);
}

.market-date {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.market-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* --- Botões e Ações --- */
.product-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-toggle {
    width: 48px;
    height: 26px;
    background-color: #2d333b;
    border-radius: 20px;
    position: relative;
    cursor: pointer;
    border: 1.5px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
    display: flex;
    align-items: center;
}

.btn-toggle::after {
    content: '';
    position: absolute;
    left: 4px;
    width: 18px;
    height: 18px;
    background-color: var(--text-muted);
    border-radius: 50%;
    transition: all 0.3s ease;
}

.btn-toggle.completed {
    background-color: rgba(227, 179, 65, 0.2);
    border-color: var(--primary-color);
}

.btn-toggle.completed::after {
    background-color: var(--primary-color);
    transform: translateX(20px);
}

.btn-edit {
    background: rgba(227, 179, 65, 0.1);
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.btn-delete {
    background: transparent;
    color: var(--danger-color);
    border: 1px solid rgba(248, 81, 73, 0.3);
    width: 38px;
    height: 38px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
}

.btn-delete:hover {
    background: rgba(248, 81, 73, 0.1);
    border-color: var(--danger-color);
}

/* --- FAB (Botão Flutuante) --- */
.fab-btn {
    position: fixed;
    bottom: 32px;
    right: 32px;
    width: 64px;
    height: 64px;
    border-radius: 22px;
    background: var(--primary-color);
    color: #0d1117;
    border: none;
    font-size: 2.2rem;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(227, 179, 65, 0.4);
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.fab-btn:active {
    transform: scale(0.9) rotate(90deg);
}

/* --- Modal --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #1c2128;
    width: 92%;
    max-width: 420px;
    padding: 28px 24px 24px;
    border-radius: 28px;
    border: 1px solid var(--border-color);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.9) translateY(20px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Cabeçalho do Modal - Título e X na mesma linha */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-header h2 {
    color: var(--primary-color);
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.btn-close-modal {
    background: rgba(255, 255, 255, 0.06);
    border: none;
    font-size: 1.4rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-close-modal:hover {
    background: rgba(248, 81, 73, 0.15);
    color: var(--danger-color);
}

/* Formulário dentro do modal */
#market-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#product-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* --- Estilo de Input --- */
.input-group label {
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

input {
    background: rgba(13, 17, 23, 0.8);
    border: 1px solid var(--border-color);
    padding: 14px 16px;
    border-radius: 14px;
    font-weight: 500;
    width: 100%; /* Garante largura total */
    color: var(--text-color);
    font-size: 1rem;
    transition: all 0.2s ease;
}

input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(13, 17, 23, 1);
    box-shadow: 0 0 0 3px rgba(227, 179, 65, 0.1);
}

/* Ajuste específico para o input de data */
input[type="date"] {
    position: relative;
    color-scheme: dark; /* Força o ícone do calendário a ficar visível no dark mode */
}

/* --- Estilo de Produto --- */
.product-item {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    padding: 16px;
}

.product-name {
    font-size: 1.1rem;
    font-weight: 600;
}

.product-price {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* --- Empty state --- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--text-muted);
    padding: 20px;
}

.empty-icon {
    font-size: 5rem;
    margin-bottom: 16px;
    filter: drop-shadow(0 0 10px rgba(227, 179, 65, 0.2));
}

.empty-state p {
    font-size: 1.1rem;
    font-weight: 600;
}

.empty-sub {
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    opacity: 0.6;
    margin-top: 6px;
}

/* --- Summary --- */
.summary-section h2 {
    font-size: 1rem;
    color: var(--text-muted);
}

#total-price {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary-color);
}
