/* ========================================
   FLORA VENDEDORAS - PWA
   Paleta: Rosa do Deserto Fortaleza
   ======================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&display=swap');

:root {
  /* Paleta RDF */
  --purple: #88529d;
  --purple-light: #b061d0;
  --purple-dark: #623474;
  --purple-deep: #3d1f4e;
  --bg: #f5f0eb;
  --bg-warm: #e6ddd4;
  --bg-card: #ffffff;
  --bg-card-alt: #faf7f4;
  --green: #81d742;
  --green-dark: #6bc232;
  --yellow: #f39c12;
  --red: #e74c3c;
  --text: #323232;
  --text-light: #666;
  --text-muted: #999;
  --white: #ffffff;
  --border: #e8e0d8;
  --shadow: 0 2px 12px rgba(136, 82, 157, 0.08);
  --shadow-lg: 0 8px 32px rgba(136, 82, 157, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --nav-height: 68px;
  --header-height: 60px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ====== TELAS ====== */
.screen { display: none; }
.screen.active { display: flex; }

/* ====== LOGIN ====== */
#login-screen {
  min-height: 100dvh;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(145deg, var(--purple-deep) 0%, var(--purple) 50%, var(--purple-light) 100%);
  position: relative;
  overflow: hidden;
}

#login-screen::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -30%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(176, 97, 208, 0.3) 0%, transparent 70%);
  border-radius: 50%;
}

#login-screen::after {
  content: '';
  position: absolute;
  bottom: -40%;
  left: -20%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(98, 52, 116, 0.4) 0%, transparent 70%);
  border-radius: 50%;
}

.login-container {
  width: 100%;
  max-width: 380px;
  text-align: center;
  position: relative;
  z-index: 1;
}

.login-logo {
  width: 100px;
  height: auto;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3));
}

.login-container h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--white);
  margin-bottom: 4px;
  letter-spacing: -0.5px;
}

.login-subtitle {
  color: rgba(255,255,255,0.7);
  margin-bottom: 36px;
  font-size: 14px;
  font-weight: 400;
}

.login-card {
  background: rgba(255,255,255,0.12);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 28px 24px;
}

.login-label {
  color: rgba(255,255,255,0.85);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  display: block;
  margin-bottom: 10px;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Inputs no login (glass style) */
.login-card select {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--white);
  padding: 16px;
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  width: 100%;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.login-card select:focus {
  border-color: rgba(255,255,255,0.5);
  background: rgba(255,255,255,0.15);
}

.login-card select option {
  background: var(--purple-dark);
  color: var(--white);
}

/* Inputs no app (light theme) */
input, select, textarea {
  background: var(--white);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 14px 16px;
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(136, 82, 157, 0.12);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%23999' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

select option {
  background: var(--white);
  color: var(--text);
}

/* ====== BOTÕES ====== */
.btn-primary {
  background: linear-gradient(135deg, var(--purple-light) 0%, var(--purple) 100%);
  color: var(--white);
  border: none;
  padding: 16px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 16px rgba(136, 82, 157, 0.3);
  margin-top: 8px;
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-secondary {
  background: var(--white);
  color: var(--purple);
  border: 1.5px solid var(--purple);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s;
}

.btn-secondary:active {
  background: var(--bg);
}

.btn-whatsapp {
  background: #25D366;
  color: var(--white);
  border: none;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.25);
}

.btn-whatsapp:active {
  background: #1da851;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--white);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  opacity: 0.8;
}

.btn-icon:active { opacity: 1; }

/* ====== HEADER ====== */
#app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: linear-gradient(135deg, var(--purple) 0%, var(--purple-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 100;
  box-shadow: 0 2px 16px rgba(136, 82, 157, 0.2);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  width: 32px;
  height: auto;
  filter: brightness(10);
}

#header-nome {
  font-weight: 600;
  font-size: 16px;
  color: var(--white);
}

.badge {
  background: rgba(255,255,255,0.2);
  color: var(--white);
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ====== NAVEGAÇÃO INFERIOR ====== */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -2px 16px rgba(0,0,0,0.04);
}

.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  padding: 8px 16px;
  position: relative;
  transition: color 0.2s;
  font-family: inherit;
}

.nav-btn.active {
  color: var(--purple);
}

.nav-btn.active .nav-icon-svg {
  fill: var(--purple);
}

.nav-icon { font-size: 24px; }
.nav-label { font-size: 11px; font-weight: 500; }

.count-badge {
  position: absolute;
  top: 2px;
  right: 6px;
  background: var(--red);
  color: var(--white);
  font-size: 10px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

/* ====== CONTEÚDO DAS ABAS ====== */
.tab-content {
  display: none;
  padding: calc(var(--header-height) + 16px) 16px calc(var(--nav-height) + 16px);
  min-height: 100dvh;
}

.tab-content.active { display: block; }

.tab-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--purple-dark);
}

.tab-desc {
  color: var(--text-light);
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin: 24px 0 12px;
  color: var(--text-light);
}

/* ====== BUSCA ====== */
.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.search-bar input {
  flex: 1;
  background: var(--white);
  box-shadow: var(--shadow);
  border-color: transparent;
}

.search-bar input:focus {
  border-color: var(--purple);
}

.search-bar select {
  width: 150px;
  flex-shrink: 0;
  box-shadow: var(--shadow);
  border-color: transparent;
}

/* ====== GRID DE PRODUTOS ====== */
.produtos-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.produto-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.15s, box-shadow 0.2s;
  border: 1px solid rgba(0,0,0,0.04);
}

.produto-card:active {
  transform: scale(0.98);
  box-shadow: var(--shadow-lg);
}

.produto-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--bg-warm);
}

.produto-info {
  padding: 12px;
}

.produto-nome {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 6px;
  color: var(--text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.produto-preco {
  color: var(--purple);
  font-weight: 700;
  font-size: 16px;
  margin-bottom: 4px;
}

.produto-estoque {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.produto-estoque.baixo {
  color: var(--yellow);
}

.produto-estoque.sem {
  color: var(--red);
}

.produto-id {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  background: var(--bg);
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 600;
}

.btn-add {
  background: var(--purple);
  color: var(--white);
  border: none;
  width: 100%;
  padding: 11px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-add:active { background: var(--purple-dark); }

.btn-add.added {
  background: var(--green);
}

.btn-add:disabled {
  background: var(--bg-warm);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ====== CARRINHO ====== */
.carrinho-lista {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.carrinho-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  padding: 12px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.04);
}

.carrinho-item-img {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-warm);
}

.carrinho-item-info {
  flex: 1;
  min-width: 0;
}

.carrinho-item-nome {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.carrinho-item-preco {
  color: var(--purple);
  font-size: 15px;
  font-weight: 700;
  margin-top: 2px;
}

.btn-remover {
  background: none;
  border: none;
  color: var(--red);
  font-size: 22px;
  cursor: pointer;
  padding: 8px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.btn-remover:active { opacity: 1; }

.resumo-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.04);
}

.resumo-linha {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  font-size: 15px;
  border-bottom: 1px solid var(--border);
}

.resumo-linha.destaque {
  color: var(--purple);
  font-weight: 700;
  font-size: 16px;
  border-bottom: none;
  padding-top: 14px;
}

.link-gerado-box {
  margin-top: 20px;
}

.link-gerado-box label {
  font-size: 13px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
}

#link-gerado {
  font-size: 12px;
  resize: none;
  margin-bottom: 12px;
  background: var(--bg);
  border-color: var(--border);
}

.link-actions {
  display: flex;
  gap: 10px;
}

.link-actions .btn-secondary,
.link-actions .btn-whatsapp {
  flex: 1;
}

/* ====== COMISSÕES ====== */
.comissao-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 24px;
}

.comissao-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.04);
}

.comissao-label {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.comissao-valor {
  font-size: 20px;
  font-weight: 700;
  color: var(--purple);
}

.comissoes-historico {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.comissao-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  padding: 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,0,0,0.04);
}

.comissao-item-info {
  font-size: 14px;
  font-weight: 500;
}

.comissao-item-data {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.comissao-item-valor {
  font-weight: 700;
  color: var(--green-dark);
  font-size: 15px;
}

.comissao-nota {
  margin-top: 24px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.5;
}

/* ====== INFO DA VENDEDORA ====== */
.vendedora-info {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--purple);
  display: flex;
  align-items: center;
  gap: 12px;
}

.vendedora-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--purple-light), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.vendedora-dados {
  flex: 1;
}

.vendedora-nome-info {
  font-weight: 600;
  font-size: 15px;
}

.vendedora-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ====== ESTADOS ====== */
.loading {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 0;
  color: var(--text-muted);
}

.empty-msg {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
  font-size: 14px;
  line-height: 1.6;
}

/* ====== TOAST ====== */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + 20px);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--purple-dark);
  color: var(--white);
  padding: 12px 24px;
  border-radius: 50px;
  font-size: 14px;
  font-weight: 500;
  z-index: 200;
  opacity: 0;
  transition: transform 0.3s, opacity 0.3s;
  white-space: nowrap;
  box-shadow: var(--shadow-lg);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ====== SPINNER ====== */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}

/* ====== RESPONSIVO ====== */
@media (min-width: 480px) {
  .produtos-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 768px) {
  .produtos-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .comissao-cards {
    max-width: 500px;
  }
}
