/* ==========================================================
   DESAFIO DOS R$ 125.000 - ESTILOS PRINCIPAIS
   Tema: Emerald & Deep Slate (Moderno, Responsivo e Touch-Friendly)
   ========================================================== */

:root {
  --bg-main: #0b0f19;
  --bg-card: #131b2e;
  --bg-card-hover: #1c2740;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(16, 185, 129, 0.5);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Cores de Destaque Financeiro */
  --emerald-500: #10b981;
  --emerald-600: #059669;
  --emerald-700: #047857;
  --emerald-glow: rgba(16, 185, 129, 0.25);

  /* Diferenciação dos Parceiros */
  --partner-a-color: #10b981;
  --partner-a-bg: rgba(16, 185, 129, 0.15);
  --partner-a-border: rgba(16, 185, 129, 0.4);

  --partner-b-color: #6366f1;
  --partner-b-bg: rgba(99, 102, 241, 0.15);
  --partner-b-border: rgba(99, 102, 241, 0.4);

  --gold-500: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.2);

  --danger-500: #ef4444;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);

  --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-main);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Scrollbar fina e moderna */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* Container Principal */
.app-container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 16px 48px;
  flex: 1;
}

/* ==========================================================
   BANNER DE INSTALAÇÃO PWA
   ========================================================== */
.pwa-install-banner {
  display: none;
  background: linear-gradient(90deg, #064e3b, #047857);
  color: #ffffff;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  animation: slideDown 0.3s ease;
}
.pwa-install-banner.active {
  display: flex;
}
.pwa-banner-content {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
  font-weight: 500;
}
.pwa-banner-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
}
.pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ==========================================================
   CABEÇALHO E BARRA SUPERIOR
   ========================================================== */
.app-header {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 20px;
}
@media (min-width: 640px) {
  .app-header {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}
.brand-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 40%, #10b981 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Badges e Pílulas */
.room-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}
.room-code-tag {
  color: var(--gold-500);
  letter-spacing: 1px;
  font-family: ui-monospace, monospace;
}

.partner-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--partner-a-bg);
  border: 1px solid var(--partner-a-border);
  color: var(--partner-a-color);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.partner-badge:hover {
  filter: brightness(1.15);
}

.sync-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--emerald-500);
  box-shadow: 0 0 8px var(--emerald-500);
  transition: background-color 0.3s;
}
.sync-status-dot.syncing {
  background-color: var(--gold-500);
  box-shadow: 0 0 8px var(--gold-500);
  animation: pulse 1s infinite;
}
.sync-status-dot.offline {
  background-color: var(--danger-500);
  box-shadow: 0 0 8px var(--danger-500);
}

/* Botões Modernos */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  outline: none;
  user-select: none;
  white-space: nowrap;
}
.btn:active {
  transform: scale(0.97);
}
.btn-primary {
  background: linear-gradient(135deg, var(--emerald-500), var(--emerald-700));
  color: #ffffff;
  box-shadow: 0 4px 14px var(--emerald-glow);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #10b981, #059669);
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.4);
}
.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}
.btn-whatsapp {
  background: #25d366;
  color: #0b2512;
  font-weight: 700;
}
.btn-whatsapp:hover {
  background: #22bf5b;
}
.btn-sm {
  padding: 5px 10px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}
.btn-icon {
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}
.btn-icon:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

/* ==========================================================
   PAINEL DE MÉTRICAS (DASHBOARD)
   ========================================================== */
.dashboard-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-md);
  position: relative;
  overflow: hidden;
}
.dashboard-card::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(16, 185, 129, 0.08) 0%, transparent 70%);
  pointer-events: none;
}

.hero-metric {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
}
@media (min-width: 640px) {
  .hero-metric {
    flex-direction: row;
    align-items: flex-end;
    justify-content: space-between;
  }
}
.metric-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  font-weight: 600;
}
.metric-values {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.metric-current {
  font-size: 2.3rem;
  font-weight: 900;
  color: var(--emerald-500);
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.metric-target {
  font-size: 1.25rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Barra de Progresso */
.progress-container {
  position: relative;
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-full);
  height: 22px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 20px;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #059669, #10b981, #34d399);
  border-radius: var(--radius-full);
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 16px rgba(16, 185, 129, 0.5);
  position: relative;
}
.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.78rem;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  pointer-events: none;
}

/* Grade de Métricas Secundárias */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
.stat-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.stat-box-title {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.stat-box-number {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Estatísticas por Parceiro */
.partners-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  flex-wrap: wrap;
}
.partner-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
}

/* ==========================================================
   BARRA DE FERRAMENTAS E FILTROS DA GRADE
   ========================================================== */
.grid-toolbar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}
@media (min-width: 768px) {
  .grid-toolbar {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.filter-btn {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}
.filter-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}
.filter-btn.active {
  background: var(--emerald-600);
  color: #ffffff;
  border-color: var(--emerald-500);
  box-shadow: 0 2px 8px var(--emerald-glow);
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px 12px;
  width: 100%;
  max-width: 220px;
}
.search-box input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 0.85rem;
  outline: none;
  width: 100%;
}
.search-box input::placeholder {
  color: var(--text-muted);
}

/* ==========================================================
   GRADE NUMÉRICA DOS 500 BLOCOS
   ========================================================== */
.slots-grid-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  min-height: 400px;
}

.slots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(62px, 1fr));
  gap: 8px;
}
@media (min-width: 640px) {
  .slots-grid {
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 10px;
  }
}

/* Bloco Numérico */
.slot-item {
  aspect-ratio: 1 / 1;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
  touch-action: manipulation;
}
.slot-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-2px);
}
.slot-item:active {
  transform: scale(0.92);
}

.slot-number {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
}
.slot-value {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 3px;
}

/* Bloco Marcado */
.slot-item.marked {
  background: linear-gradient(135deg, #065f46, #047857);
  border-color: #10b981;
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
  animation: popIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.slot-item.marked .slot-number {
  color: #ffffff;
}
.slot-item.marked .slot-value {
  color: rgba(255, 255, 255, 0.85);
}
.slot-item.marked .slot-author-badge {
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 0.55rem;
  font-weight: 800;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.45);
  border-radius: 4px;
  padding: 1px 3px;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Diferenciação de cores para múltiplos parceiros */
.slot-item.marked.partner-alt {
  background: linear-gradient(135deg, #4338ca, #4f46e5);
  border-color: #818cf8;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

/* Bloco Oculto por filtro */
.slot-item.hidden {
  display: none !important;
}

/* Efeito de destaque ao pesquisar */
.slot-item.highlight {
  border-color: var(--gold-500) !important;
  box-shadow: 0 0 16px var(--gold-glow) !important;
  transform: scale(1.08);
  z-index: 2;
}

/* ==========================================================
   MODAIS E TELAS DE BOAS-VINDAS
   ========================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  animation: fadeIn 0.25s ease;
}
.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 440px;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  animation: scaleUp 0.25s ease;
  position: relative;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
}
.modal-close-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-input:focus {
  border-color: var(--emerald-500);
  box-shadow: 0 0 0 3px var(--emerald-glow);
}
.form-input.uppercase-code {
  font-family: ui-monospace, monospace;
  letter-spacing: 3px;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
}
.modal-divider::before, .modal-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

/* ==========================================================
   TOASTS E NOTIFICAÇÕES
   ========================================================== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 2000;
  pointer-events: none;
}
.toast {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  font-size: 0.88rem;
  font-weight: 600;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.7s forwards;
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.success {
  border-color: var(--emerald-500);
}

/* ==========================================================
   ANIMAÇÕES
   ========================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes scaleUp {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes popIn {
  0% { transform: scale(0.85); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(12px); }
}
