/* ═══════════════════════ APP COMPRAS - ESTILOS ═══════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --texto: #1e293b;
  --texto2: #64748b;
  --texto3: #94a3b8;
  --borda: #e2e8f0;
  --sombra: 0 2px 12px rgba(0,0,0,0.06);
  --raio: 16px;
  --marsala: #4a0e2e;
  --cosmico: #0dff92;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  background: radial-gradient(ellipse at 50% 0%, rgba(13, 255, 146, 0.02), transparent 70%),
              radial-gradient(ellipse at 80% 100%, rgba(74, 14, 46, 0.03), transparent 70%),
              #f8fafc;
  color: var(--texto);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* ═══════════ ANIMAÇÕES ═══════════ */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes checkBounce { 0% { transform: scale(0); } 50% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes cosmicPulse { 0%,100%{ box-shadow:0 0 8px rgba(13,255,146,.3),0 0 20px rgba(13,255,146,.1) } 50%{ box-shadow:0 0 12px rgba(13,255,146,.5),0 0 30px rgba(13,255,146,.2) } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ═══════════ SPLASH SCREEN ═══════════ */
#splash-screen {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 50%, #a5d6a7 100%);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    z-index: 9999; transition: opacity 0.5s ease;
}
#splash-logo { font-size: 5rem; animation: pulse 1.5s ease-in-out infinite; }
#splash-nome { font-size: 1.8rem; font-weight: 800; color: #2e7d32; margin-top: 20px; font-family: 'Poppins', sans-serif; animation: fadeInUp 0.8s ease-out; }
#splash-slogan { font-size: 0.9rem; color: #555; margin-top: 8px; font-family: 'Poppins', sans-serif; animation: fadeInUp 0.8s ease-out 0.3s both; }
#splash-loader { margin-top: 30px; width: 40px; height: 40px; border: 3px solid rgba(46,125,50,0.2); border-top: 3px solid #2e7d32; border-radius: 50%; animation: spin 1s linear infinite; }

/* ═══════════ DASHBOARD ═══════════ */
#dashboard { animation: fadeIn 0.4s ease-out; }
#dashboard-grid > div { animation: fadeInUp 0.5s ease-out both; }
#dashboard-grid > div:nth-child(1) { animation-delay: 0.05s; }
#dashboard-grid > div:nth-child(2) { animation-delay: 0.1s; }
#dashboard-grid > div:nth-child(3) { animation-delay: 0.15s; }
#dashboard-grid > div:nth-child(4) { animation-delay: 0.2s; }
#dashboard-grid > div:nth-child(5) { animation-delay: 0.25s; }
#dashboard-grid > div:nth-child(6) { animation-delay: 0.3s; }
#dashboard-grid > div:nth-child(7) { animation-delay: 0.35s; }
#dashboard-grid > div:nth-child(8) { animation-delay: 0.4s; }
#dashboard-grid > div:nth-child(9) { animation-delay: 0.45s; }

/* ═══════════ BOTÃO VOLTAR ═══════════ */
#btn-voltar { animation: fadeIn 0.3s ease-out; transition: transform 0.2s, box-shadow 0.2s; }
#btn-voltar:active { transform: scale(0.9); box-shadow: 0 1px 4px rgba(0,0,0,0.1); }

/* ═══════════ HEADER ═══════════ */
.app-header { position:sticky; top:0; z-index:50; background:rgba(255,255,255,.95); backdrop-filter:blur(20px); -webkit-backdrop-filter:blur(20px); border-bottom:1px solid var(--borda); padding:12px 50px; display:flex; align-items:center; justify-content:space-between; }
.app-header h1 { font-size:1.1rem; font-weight:800; display:flex; align-items:center; gap:8px; }
.app-header .total-header { font-weight:700; font-size:.85rem; color:var(--texto2); }

/* ═══════════ CONTAINER ═══════════ */
.container { max-width:700px; margin:0 auto; padding:16px; padding-bottom:120px; }

/* ═══════════ BOTÃO INSTALAR ═══════════ */
.btn-instalar { background:#1e293b; color:white; border:none; padding:14px; border-radius:14px; font-weight:700; cursor:pointer; font-family:inherit; font-size:.9rem; width:100%; margin-bottom:14px; display:none; transition:all .3s; }
.btn-instalar:hover { background:#334155; transform:translateY(-1px); }

/* ═══════════ CATEGORIAS ═══════════ */
.categoria-card { background:var(--card); border-radius:var(--raio); margin-bottom:8px; box-shadow:var(--sombra); overflow:hidden; animation:fadeIn .3s ease-out; }
.categoria-header { display:flex; align-items:center; justify-content:space-between; padding:14px 16px; cursor:pointer; font-weight:700; font-size:.9rem; border:none; background:none; width:100%; font-family:inherit; color:var(--texto); text-align:left; }
.categoria-header:hover { background:rgba(0,0,0,.01); }
.categoria-header .seta { transition:transform .3s; font-size:.7rem; color:var(--texto3); }
.categoria-header.aberta .seta { transform:rotate(180deg); }
.categoria-itens { max-height:0; overflow:hidden; transition:max-height .4s ease; }
.categoria-itens.aberta { max-height:2000px; }

/* ═══════════ ITEM (LINHA) ═══════════ */
.item-row { display:flex; align-items:center; gap:6px; padding:8px 12px; border-top:1px solid var(--borda); cursor:pointer; transition:all .4s ease; border-left:3px solid transparent; }
.item-row:hover { background:rgba(0,0,0,.01); }
.item-row:not(.comprado) .item-nome { color:var(--texto); }
.item-row.comprado { background:linear-gradient(135deg,rgba(74,14,46,.12),rgba(74,14,46,.04)); border-left:3px solid var(--marsala); opacity:1 !important; }
.item-row.comprado .item-nome { color:var(--marsala); font-weight:700; font-size:.92rem; text-shadow:0 0 6px rgba(74,14,46,.2); letter-spacing:.02em; }
.item-row.comprado .item-check { background:var(--marsala); border-color:var(--cosmico); color:var(--cosmico); box-shadow:0 0 10px rgba(13,255,146,.4); animation:checkBounce .4s ease-out; }
.item-row.comprado .item-qtd,
.item-row.comprado .item-preco,
.item-row.comprado .item-unidade { border-color:var(--cosmico); box-shadow:0 0 8px rgba(13,255,146,.3),0 0 20px rgba(13,255,146,.1); animation:cosmicPulse 3s ease-in-out infinite; color:var(--texto); font-weight:600; }
.item-row.comprado .item-preco-total { color:var(--marsala); font-weight:700; text-shadow:0 0 6px rgba(74,14,46,.2); }

/* Campos do item */
.item-check { width:22px; height:22px; border-radius:50%; border:2px solid #cbd5e1; display:flex; align-items:center; justify-content:center; flex-shrink:0; font-size:.6rem; color:transparent; transition:all .3s; }
.item-nome { flex:1; font-size:.85rem; transition:all .4s ease; }
.item-qtd { width:38px; padding:4px; text-align:center; border:1px solid var(--borda); border-radius:6px; font-family:inherit; font-size:.75rem; background:var(--bg); }
.item-preco { width:60px; padding:4px; text-align:right; border:1px solid var(--borda); border-radius:6px; font-family:inherit; font-size:.75rem; background:var(--bg); }
.item-preco-total { font-weight:700; font-size:.75rem; min-width:55px; text-align:right; }
.item-unidade { width:50px; padding:3px; font-size:.6rem; border:1px solid #ddd; border-radius:4px; background:#fff; font-family:inherit; transition:all .3s ease; }

/* ═══════════ RESUMO ═══════════ */
.resumo { background:var(--card); border-radius:var(--raio); padding:16px; margin-top:12px; box-shadow:var(--sombra); }
.resumo-row { display:flex; justify-content:space-between; margin-bottom:6px; font-size:.85rem; }
.resumo-total { font-size:1.3rem; font-weight:900; border-top:1px solid var(--borda); padding-top:8px; margin-top:8px; }

/* ═══════════ BOTÕES AÇÕES ═══════════ */
.acoes { display:flex; gap:8px; margin-top:12px; }
.btn-acao { flex:1; padding:14px; border:none; border-radius:14px; font-weight:700; cursor:pointer; font-family:inherit; font-size:.85rem; display:flex; align-items:center; justify-content:center; gap:6px; transition:all .2s; }
.btn-acao:active { transform:scale(.97); }
.btn-wpp { background:#25d366; color:white; }
.btn-limpar { background:#fee2e2; color:#dc2626; }
.btn-salvar { background:#1e293b; color:white; }

/* ═══════════ LISTAS ═══════════ */
.lista-salva { background:var(--card); border-radius:var(--raio); padding:14px; margin-bottom:8px; box-shadow:var(--sombra); display:flex; justify-content:space-between; align-items:center; cursor:pointer; }
.lista-salva:hover { background:#f1f5f9; }

/* ═══════════ TOAST ═══════════ */
.toast { position:fixed; bottom:100px; left:50%; transform:translateX(-50%); padding:10px 20px; background:#1e293b; color:white; border-radius:20px; font-weight:600; font-size:.85rem; z-index:400; opacity:0; transition:all .3s; pointer-events:none; }
.toast.show { opacity:1; }

/* ═══════════ AVISO MÉDICO ═══════════ */
#aviso-medico { animation:fadeIn .4s ease-out; }

/* ═══════════ BOTÃO OBSERVAÇÃO ═══════════ */
.btn-obs { background: rgba(13,255,146,.08); border: 1px solid rgba(13,255,146,.3); border-radius: 6px; padding: 4px 8px; font-size: .65rem; font-weight: 600; color: var(--cosmico); cursor: pointer; font-family: inherit; white-space: nowrap; transition: all .3s ease; }
.btn-obs:hover { background: rgba(13,255,146,.15); box-shadow: 0 0 10px rgba(13,255,146,.3); }

/* ═══════════ MODAL ═══════════ */
.modal-overlay { position: fixed; inset: 0; z-index: 500; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; pointer-events: none; transition: opacity .3s; }
.modal-overlay.ativo { opacity: 1; pointer-events: all; }
.modal-content { background: white; border-radius: 20px; padding: 24px; max-width: 500px; width: 100%; max-height: 85vh; overflow-y: auto; }

/* ═══════════ SIDEBAR DE CATEGORIAS ═══════════ */
#sidebar-categorias { scrollbar-width: none; -ms-overflow-style: none; }
#sidebar-categorias::-webkit-scrollbar { display: none; }

/* ═══════════ RESPONSIVIDADE ═══════════ */
@media (min-width: 768px) {
    .container { padding: 24px; padding-bottom: 120px; }
    #sidebar-categorias { width: 55px; }
    #main-content { margin-left: 55px !important; }
}

@media (max-width: 767px) {
    #dashboard-grid { gap: 6px; }
    #dashboard-grid > div { padding: 12px 6px; }
    #dashboard-grid > div > div:first-child { font-size: 1.6rem !important; }
    #dashboard-grid > div > div:last-child { font-size: 0.65rem !important; }
    
    .app-header { padding: 10px 12px 10px 44px; }
    .app-header h1 { font-size: 0.9rem; }
    
    .acoes { gap: 6px; }
    .btn-acao { padding: 10px 8px; font-size: 0.78rem; }
    
    #sidebar-categorias { width: 42px; }
    #sidebar-categorias button { width: 34px !important; height: 34px !important; font-size: 1rem !important; }
    #main-content { margin-left: 42px !important; }
    
    .item-row { gap: 3px; padding: 6px 8px; }
    .item-nome { font-size: 0.75rem; }
    .item-qtd { width: 32px; font-size: 0.7rem; }
    .item-preco { width: 48px; font-size: 0.7rem; }
    .item-unidade { width: 42px; font-size: 0.55rem; }
}