/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-hover: #334155;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --accent: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --transition: 0.2s ease;
}

html {
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ===== APP LAYOUT ===== */
.app {
  max-width: 800px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 80px;
}

/* ===== HEADER ===== */
.header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0;
  margin-bottom: 8px;
}

.header h1 {
  font-size: 1.5rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}

.header h1 i {
  color: var(--primary);
}

/* ===== SPOTIFY STATUS ===== */
.spotify-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--surface);
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
}

.spotify-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.spotify-indicator.connected {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

#spotifyLabel {
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 1;
  min-width: 0;
}

.btn-spotify {
  background: #1db954;
  color: white;
  flex-shrink: 0;
}
.btn-spotify:hover:not(:disabled) {
  background: #169c46;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }

.btn-secondary {
  background: var(--border);
  color: var(--text);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); }

.btn-success {
  background: var(--accent);
  color: white;
}
.btn-success:hover:not(:disabled) { background: #16a34a; }

.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: background var(--transition), color var(--transition);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}
.btn-icon:hover { background: var(--surface-hover); color: var(--text); }

.btn-small {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
}

.card-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-header h2 i { color: var(--primary); }

.toggle-icon {
  transition: transform var(--transition);
  color: var(--text-muted);
}

.toggle-icon.open { transform: rotate(180deg); }

.card-body {
  padding: 0 18px 18px;
}

/* ===== SCHEDULE ===== */
.schedule-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.time-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.time-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg);
  cursor: pointer;
  transition: background var(--transition);
}

.time-group-header:hover { background: var(--surface-hover); }

.time-group-past {
  opacity: 0.45;
  transition: opacity 0.3s ease;
}

.time-group-past:hover {
  opacity: 0.8;
}

.time-group-header .time {
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.time-group-header .match-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.match-item {
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
}

.match-item .field {
  font-weight: 600;
  color: var(--primary);
  min-width: 60px;
}

.match-item .teams {
  flex: 1;
}

.match-item .referee {
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* ===== ANNOUNCEMENTS ===== */
.announcement-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  overflow: hidden;
}

.announcement-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  cursor: pointer;
  transition: background var(--transition);
  gap: 8px;
}

.announcement-header:hover { background: var(--surface-hover); }

.announcement-header .time-badge {
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.announcement-header .status-badge {
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
  flex-shrink: 0;
}

.status-badge.draft {
  background: var(--warning);
  color: #1e293b;
}

.status-badge.has-audio {
  background: var(--accent);
  color: #1e293b;
}

.announcement-header .btn-group {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.announcement-body {
  padding: 0 14px 14px;
  display: none;
}

.announcement-body.open {
  display: block;
}

.announcement-body .text-content {
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
}

.announcement-body .meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.announcement-body .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ===== AUDIO PLAYER STYLING ===== */
audio {
  width: 100%;
  max-width: 300px;
  height: 40px;
  border-radius: var(--radius-sm);
}

/* ===== MODAL ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 1.1rem; }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.modal-body textarea {
  width: 100%;
  min-height: 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px;
  font-size: 0.95rem;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
}

.modal-body textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  justify-content: flex-end;
}

/* ===== LOADING ===== */
.loading {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
}

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 3s forwards;
  pointer-events: auto;
}

.toast.success { border-color: var(--accent); }
.toast.error { border-color: var(--danger); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(16px); }
}

/* ===== SOUNDBOARD ===== */
.soundboard-section {
  margin-bottom: 20px;
}

.soundboard-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.soundboard-section h3 i {
  color: var(--primary);
}

.input-text {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}

.input-text:focus {
  outline: none;
  border-color: var(--primary);
}

.input-text::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.btn-warning {
  background: #f59e0b;
  color: #1e293b;
}
.btn-warning:hover:not(:disabled) {
  background: #d97706;
}

.btn-sound {
  font-size: 1.1rem;
  padding: 14px 28px;
  border-radius: var(--radius);
  font-weight: 700;
}

.soundboard-tts-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.soundboard-row {
  width: 100%;
}

.input-select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
}

.input-select:focus {
  outline: none;
  border-color: var(--primary);
}

.soundboard-tts-form textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 12px;
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
}

.soundboard-tts-form textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.soundboard-options {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
  color: var(--text);
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
  cursor: pointer;
}

.soundboard-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Presets */
.presets-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.preset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.preset-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.preset-info strong {
  font-size: 0.9rem;
  color: var(--text);
}

.preset-text {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.preset-flags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.flag {
  font-size: 0.75rem;
  padding: 2px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-muted);
}

.preset-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
  .app { padding: 12px; padding-bottom: 80px; }
  .header { flex-direction: column; align-items: stretch; }
  .header h1 { justify-content: center; }
  .header .btn { justify-content: center; width: 100%; }
  .announcement-header { flex-wrap: wrap; }
  .announcement-header .btn-group { margin-left: auto; }
  .modal-body textarea { min-height: 150px; }
  audio { max-width: 100%; }
}