/* styles.css */

:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --border: #e3e6ec;
  --text: #1f2430;
  --text-muted: #6b7280;

  --primary: #4f46e5;
  --primary-hover: #4338ca;

  --success: #16a34a;
  --success-hover: #15803d;

  --danger: #dc2626;
  --danger-hover: #b91c1c;

  --header-bg: #1f2430;
  --header-text: #f4f5f8;

  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 2px 8px rgba(16, 24, 40, 0.08);
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  background-color: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
}

main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 28px 20px 60px;
}

h1, h2, h3 {
  color: var(--text);
  margin: 0 0 8px;
}

/* ---------- Header ---------- */

.app-header {
  background-color: var(--header-bg);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.app-header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-brand {
  color: var(--header-text);
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
}

.logout-button {
  background-color: transparent;
  color: var(--header-text);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
}

.logout-button:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

/* ---------- Flash / alert messages ---------- */

.flash {
  padding: 12px 16px;
  border-radius: 8px;
  margin: 0 auto 20px;
  font-size: 0.95rem;
  max-width: 380px;
}

.flash-error {
  background-color: #fef2f2;
  color: var(--danger-hover);
  border: 1px solid #fecaca;
}

.alert {
  background-color: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 20px;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  text-align: center;
}

/* ---------- Auth pages ---------- */

.auth-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 380px;
  margin: 40px auto 0;
  padding: 32px;
  text-align: center;
}

.auth-card h1 {
  font-size: 1.5rem;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 24px;
}

.auth-card form {
  text-align: left;
}

.auth-switch {
  margin-top: 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-switch a {
  color: var(--primary);
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* ---------- Form fields ---------- */

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
.select-input {
  width: 100%;
  font-size: 1rem;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--surface);
  color: var(--text);
}

input[type="text"]:focus,
input[type="password"]:focus,
.select-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

/* ---------- Buttons ---------- */

.btn-primary,
.auth-card button[type="submit"] {
  width: 100%;
  font-size: 1rem;
  font-weight: 600;
  padding: 11px;
  margin-top: 4px;
  cursor: pointer;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
}

.btn-primary:hover,
.auth-card button[type="submit"]:hover {
  background-color: var(--primary-hover);
}

/* ---------- Main app layout ---------- */

.app-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-start;
  justify-content: center;
}

.app-grid .panel#controls-container {
  width: 280px;
  flex-shrink: 0;
}

.app-grid .board-wrapper {
  width: 520px;
  max-width: 100%;
  flex-shrink: 0;
}

.app-grid .move-list {
  width: 200px;
  flex-shrink: 0;
}

.panel {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

/* ---------- Opening details ---------- */

.opening-details {
  background-color: #f8f8fc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  margin-bottom: 20px;
}

.opening-details h2 {
  font-size: 1.05rem;
}

.opening-details p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

/* ---------- Mode toggle ---------- */

.mode-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #d1d5db;
  transition: 0.2s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.2s;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:focus + .slider {
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

/* ---------- Variation options ---------- */

.variation-options {
  margin-bottom: 20px;
}

.variation-options h3 {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.variation-options button {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  background-color: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  font-size: 0.9rem;
}

.variation-options button:hover {
  border-color: var(--success);
  color: var(--success-hover);
}

/* ---------- Chessboard ---------- */

.board-wrapper {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  line-height: 0;
}

#board {
  width: 100%;
}

/* ---------- Move list ---------- */

.move-list h2 {
  font-size: 1rem;
  margin-bottom: 12px;
}

.move-list ol {
  list-style: none;
  margin: 0;
  padding: 0;
  counter-reset: move;
}

.move-list li {
  display: flex;
  gap: 8px;
  padding: 6px 4px;
  font-family: "SF Mono", "Menlo", "Consolas", monospace;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

.move-list li:nth-child(odd) {
  background-color: #fafafc;
}

.move-list li::before {
  counter-increment: move;
  content: counter(move) ".";
  color: var(--text-muted);
  min-width: 1.5em;
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .app-grid {
    flex-direction: column;
    align-items: center;
  }

  .app-grid .panel#controls-container,
  .app-grid .board-wrapper,
  .app-grid .move-list {
    width: 100%;
    max-width: 500px;
  }
}
