/* ============================================================
   Tournament Form — Styles
   Spielegesellschaft Design System
   ============================================================ */

/* ── Alerts (form page) ── */

.tournament-form-container .alert {
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.5;
  animation: formAlertIn 0.35s ease-out;
}

.tournament-form-container .alert-success {
  background: rgba(56, 142, 60, 0.15);
  color: #4caf50;
  border: 1px solid rgba(56, 142, 60, 0.3);
}

.tournament-form-container .alert-danger {
  background: rgba(211, 47, 47, 0.15);
  color: #ef5350;
  border: 1px solid rgba(211, 47, 47, 0.3);
}

@keyframes formAlertIn {
  from { opacity: 0; transform: translateY(-0.5rem); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Container ── */

.tournament-form-container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 2rem 1rem;
  font-family: var(--font-primary);
}

/* ── Form Header ── */

.form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
}

.form-header .form-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-secondary);
  margin: 0;
}

/* ── Buttons (form-scoped) ── */

.tournament-form-container .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 0.25rem;
  font-family: var(--font-primary);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  line-height: 1.4;
}

.tournament-form-container .btn-primary {
  background: #5c6bc0;
  color: #fff;
  border-color: #5c6bc0;
}

.tournament-form-container .btn-primary:hover {
  background: #3f51b5;
  border-color: #3f51b5;
  transform: translateY(-1px);
  box-shadow: 0 0.25rem 0.75rem rgba(92, 107, 192, 0.3);
}

.tournament-form-container .btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.tournament-form-container .btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.25);
}

.tournament-form-container .btn-secondary {
  background: var(--background-lighter);
  color: var(--text-primary);
  border-color: var(--background-lighter);
}

.tournament-form-container .btn-secondary:hover {
  opacity: 0.85;
}

/* ── Form ── */

.tournament-form {
  background: var(--background-darker);
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/* ── Form Section ── */

.form-section {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.form-section:last-of-type {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-secondary);
  margin: 0 0 1.25rem;
  padding-bottom: 0.5rem;
  position: relative;
}

.section-title::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 3rem;
  height: 2px;
  background: #5c6bc0;
  border-radius: 1px;
}

/* ── Form Row ── */

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1rem;
}

/* ── Form Group ── */

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.9rem;
}

.form-group small,
.form-text {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* ── Form Controls ── */

.tournament-form-container .form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--background);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.25rem;
  color: var(--text-primary);
  font-family: var(--font-primary);
  font-size: 0.95rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  -webkit-appearance: none;
  appearance: none;
}

.tournament-form-container .form-control:focus {
  border-color: #5c6bc0;
  outline: none;
  box-shadow: 0 0 0 2px rgba(92, 107, 192, 0.25);
}

.tournament-form-container .form-control::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

/* Select specific styling */
.tournament-form-container select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238792b0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

/* Textarea */
.tournament-form-container textarea.form-control {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

/* Date inputs */
.tournament-form-container input[type="date"].form-control {
  cursor: pointer;
}

.tournament-form-container input[type="date"].form-control::-webkit-calendar-picker-indicator {
  filter: invert(0.6);
  cursor: pointer;
}

/* Number inputs */
.tournament-form-container input[type="number"].form-control {
  -moz-appearance: textfield;
}

.tournament-form-container input[type="number"].form-control::-webkit-inner-spin-button,
.tournament-form-container input[type="number"].form-control::-webkit-outer-spin-button {
  opacity: 1;
}

/* ── Form Validation ── */

.form-group.has-error .form-control {
  border-color: #ef5350;
  box-shadow: 0 0 0 1px rgba(239, 83, 80, 0.3);
}

.form-group .error-message {
  color: #ef5350;
  font-size: 0.8rem;
  margin-top: 0.35rem;
  animation: errorFadeIn 0.25s ease-out;
}

@keyframes errorFadeIn {
  from { opacity: 0; transform: translateY(-0.25rem); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Form Actions ── */

.form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.75rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* ============================================================
   Light Mode Overrides
   ============================================================ */

[data-theme="light"] .tournament-form {
  box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .tournament-form-container .btn-outline {
  border-color: rgba(0, 0, 0, 0.15);
  color: var(--text-primary);
}

[data-theme="light"] .tournament-form-container .btn-outline:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .tournament-form-container .form-control {
  border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .tournament-form-container .form-control:focus {
  border-color: #5c6bc0;
}

[data-theme="light"] .tournament-form-container select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234d4d4d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

[data-theme="light"] .tournament-form-container input[type="date"].form-control::-webkit-calendar-picker-indicator {
  filter: none;
}

[data-theme="light"] .form-section {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .form-actions {
  border-top-color: rgba(0, 0, 0, 0.08);
}

[data-theme="light"] .alert-success {
  color: #2e7d32;
}

[data-theme="light"] .alert-danger {
  color: #c62828;
}

/* Fallback for prefers-color-scheme */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .tournament-form {
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.08);
  }

  :root:not([data-theme="dark"]) .tournament-form-container .btn-outline {
    border-color: rgba(0, 0, 0, 0.15);
  }

  :root:not([data-theme="dark"]) .tournament-form-container .btn-outline:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.25);
  }

  :root:not([data-theme="dark"]) .tournament-form-container .form-control {
    border-color: rgba(0, 0, 0, 0.12);
  }

  :root:not([data-theme="dark"]) .tournament-form-container select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%234d4d4d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  }

  :root:not([data-theme="dark"]) .tournament-form-container input[type="date"].form-control::-webkit-calendar-picker-indicator {
    filter: none;
  }

  :root:not([data-theme="dark"]) .form-section {
    border-bottom-color: rgba(0, 0, 0, 0.08);
  }

  :root:not([data-theme="dark"]) .form-actions {
    border-top-color: rgba(0, 0, 0, 0.08);
  }
}

/* ── Responsive ── */

@media (max-width: 768px) {
  .tournament-form-container {
    padding: 1.5rem 0.75rem;
  }

  .form-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-header .form-title {
    font-size: 1.4rem;
  }

  .tournament-form {
    padding: 1.25rem;
  }

  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .form-actions {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .form-actions .btn {
    justify-content: center;
  }
}
