/* ==========================================================================
   SORTEIO FUTEBOL - DESIGN SYSTEM MOBILE (ESTILO BLOCO DE NOTAS)
   Paleta: Verde Futebol (#16a34a), Neutros Suaves, Zero Roxo/Violeta.
   ========================================================================== */

:root {
  --bg-app: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-subtle: #f8fafc;
  --border-color: #e2e8f0;
  --border-focus: #16a34a;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --primary: #16a34a;
  --primary-hover: #15803d;
  --primary-active: #166534;
  --primary-light: #dcfce7;
  --primary-text: #14532d;
  
  --whatsapp: #25d366;
  --whatsapp-hover: #1ea952;
  --whatsapp-active: #178740;
  
  --danger: #ef4444;
  --danger-light: #fee2e2;
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 9999px;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-floating: 0 14px 28px rgba(0, 0, 0, 0.12), 0 10px 10px rgba(0, 0, 0, 0.06);

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

@media (prefers-color-scheme: dark) {
  :root {
    --bg-app: #0b0f19;
    --bg-card: #151d2e;
    --bg-card-subtle: #1c263c;
    --border-color: #27344f;
    --border-focus: #22c55e;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-light: #64748b;
    
    --primary: #22c55e;
    --primary-hover: #16a34a;
    --primary-active: #15803d;
    --primary-light: #064e3b;
    --primary-text: #86efac;
    
    --danger-light: #450a0a;
  }
}

/* Reset Básico & Acessibilidade */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  min-height: -webkit-fill-available;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-x: hidden;
}

/* Container do App com proporção mobile */
.app-container {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-card);
  position: relative;
  box-shadow: var(--shadow-lg);
}

@media (min-width: 640px) {
  body {
    padding: 24px 16px;
    background-color: #0d131f;
  }
  
  .app-container {
    min-height: calc(100vh - 48px);
    max-height: 900px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    border: 1px solid var(--border-color);
  }
}

/* Cabeçalho */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 10;
}

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

.header-icon {
  font-size: 26px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background-color: var(--primary-light);
  border-radius: var(--radius-md);
}

.header-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

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

.btn-icon {
  background: transparent;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  background-color: var(--bg-card-subtle);
  color: var(--danger);
}

.btn-icon:active {
  transform: scale(0.92);
}

/* Área Principal / Bloco de Notas */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px 20px 24px;
  gap: 16px;
  overflow-y: auto;
}

.notepad-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-card-subtle);
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  overflow: hidden;
}

.notepad-card:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.notepad-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px dashed var(--border-color);
  background-color: rgba(0, 0, 0, 0.015);
}

.notepad-tag {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.notepad-counter {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary-text);
  background-color: var(--primary-light);
  padding: 3px 10px;
  border-radius: var(--radius-pill);
}

.notepad-body {
  flex: 1;
  display: flex;
  min-height: 280px;
}

.notepad-body textarea {
  width: 100%;
  height: 100%;
  min-height: 280px;
  padding: 16px;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.65;
  resize: none;
  outline: none;
}

.notepad-body textarea::placeholder {
  color: var(--text-light);
  opacity: 0.8;
  font-weight: 400;
}

.notepad-footer {
  padding: 10px 16px;
  border-top: 1px dashed var(--border-color);
  background-color: rgba(0, 0, 0, 0.015);
}

.notepad-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

/* Barra de Ação Flutuante / Botão Principal */
.action-dock {
  margin-top: auto;
  position: sticky;
  bottom: 0;
  background-color: var(--bg-card);
  padding-top: 12px;
}

.btn-primary {
  width: 100%;
  height: 54px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-hover) 100%);
  color: #ffffff;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(22, 163, 74, 0.35);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: scale(0.98);
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.25);
}

.btn-primary:disabled {
  background: var(--border-color);
  color: var(--text-light);
  cursor: not-allowed;
  box-shadow: none;
}

/* Painel de Resultados (Bottom Sheet / Modal Mobile) */
.results-sheet {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--bg-card);
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding: 16px 20px 24px;
  overflow-y: auto;
  animation: slideInUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
}

.sheet-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sheet-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.sheet-badge {
  font-size: 0.75rem;
  font-weight: 600;
  background-color: var(--primary-light);
  color: var(--primary-text);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.btn-close {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: pointer;
}

.btn-close:active {
  transform: scale(0.92);
}

/* Grid de Times Sorteados */
.teams-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 18px 0;
  flex: 1;
}

.team-card {
  background-color: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease;
}

.team-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.team-name {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.team-count {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--bg-card);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-color);
}

.team-players-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.team-player-item {
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  background-color: rgba(255, 255, 255, 0.6);
}

@media (prefers-color-scheme: dark) {
  .team-player-item {
    background-color: rgba(0, 0, 0, 0.2);
  }
}

.player-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-light);
  width: 18px;
}

/* Card de Reservas / Próximos (se houver) */
.team-card.reservas {
  border-style: dashed;
  border-color: #cbd5e1;
  background-color: rgba(241, 245, 249, 0.5);
}

/* Botões do Sheet */
.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 10px;
}

.btn-whatsapp {
  width: 100%;
  height: 52px;
  border: none;
  border-radius: var(--radius-md);
  background-color: var(--whatsapp);
  color: #ffffff;
  font-size: 1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
  transition: all 0.2s ease;
}

.btn-whatsapp:hover {
  background-color: var(--whatsapp-hover);
}

.btn-whatsapp:active {
  transform: scale(0.98);
}

.sub-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-secondary {
  height: 44px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-card-subtle);
  color: var(--text-main);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background-color: var(--border-color);
}

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

/* Toast de Feedback */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background-color: #0f172a;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 600;
  box-shadow: var(--shadow-floating);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
}

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