/* ============================================================
   Gameti.me — Design System & App Styles
   ============================================================ */

/* 1. Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* 2. Root Variables */
:root {
  --color-primary: #4F6EF7;
  --color-primary-dark: #3b5bdb;
  --color-primary-light: #e8edff;
  --color-yes: #22c55e;
  --color-yes-light: #dcfce7;
  --color-maybe: #f59e0b;
  --color-maybe-light: #fef9c3;
  --color-no: #ef4444;
  --color-no-light: #fee2e2;
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
}

/* 3. Body */
body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.5;
}

/* 4. Container */
.container {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
}

/* 5. Card */
.card {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.card + .card {
  margin-top: 1rem;
}

/* 7. Form Elements */
.form-group {
  margin-bottom: 1.25rem;
}

label {
  display: block;
  font-weight: 500;
  margin-bottom: .375rem;
  font-size: .9rem;
}

.input {
  width: 100%;
  padding: .625rem .875rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  outline: none;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  transition: border-color .15s, box-shadow .15s;
}

.input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

select.input {
  width: 100%;
  padding: .625rem .875rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 1rem;
  outline: none;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
}

select.input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

textarea.input {
  resize: vertical;
  min-height: 80px;
}

/* 8. Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .625rem 1.25rem;
  border-radius: var(--radius);
  font-size: .925rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all .15s;
  font-family: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

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

.btn-secondary:hover:not(:disabled) {
  background: #d1dbe8;
}

.btn-danger {
  background: var(--color-no);
  color: white;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

.btn-sm {
  padding: .375rem .75rem;
  font-size: .85rem;
}

.btn:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.btn-full {
  width: 100%;
  justify-content: center;
}

/* 9. Tabs */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--color-border);
  margin-bottom: 1.5rem;
  gap: .25rem;
}

.tab-btn {
  padding: .625rem 1.25rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: .925rem;
  color: var(--color-text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .15s;
  font-family: inherit;
  font-weight: 400;
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 500;
}

/* 10. Calendar */
.calendar-wrap {
  overflow-x: auto;
}

.months-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
}

.month-block {
  min-width: 280px;
}

.month-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: .75rem;
  font-weight: 600;
}

.month-nav-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: .25rem .5rem;
  border-radius: 4px;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--color-text);
}

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

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-day-header {
  text-align: center;
  font-size: .75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  padding: .25rem 0;
}

.cal-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .875rem;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  transition: all .1s;
}

.cal-cell.in-window:hover {
  background: var(--color-primary-light);
}

.cal-cell.selected {
  background: var(--color-primary);
  color: white;
  font-weight: 600;
}

.cal-cell.range-start,
.cal-cell.range-end {
  background: var(--color-primary);
  color: white;
}

.cal-cell.in-range {
  background: var(--color-primary-light);
}

.cal-cell.out-window {
  color: var(--color-border);
  cursor: default;
}

.cal-cell.blank {
  cursor: default;
}

.cal-cell.today {
  font-weight: 700;
}

/* Heat map */
.cal-cell.heat-high {
  background: #bbf7d0;
}

.cal-cell.heat-med {
  background: #fef9c3;
}

.cal-cell.heat-low {
  background: #fee2e2;
}

/* heat-none uses default background */

/* 11. Hour Grid */
.day-hours-section {
  margin-top: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.day-hours-header {
  padding: .5rem 1rem;
  background: var(--color-bg);
  font-weight: 600;
  font-size: .9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hour-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: .75rem;
}

.hour-cell {
  padding: .375rem .625rem;
  border-radius: 6px;
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid var(--color-border);
  user-select: none;
  transition: all .1s;
  min-width: 52px;
  text-align: center;
}

.hour-cell.status-unset {
  background: white;
  color: var(--color-text-muted);
}

.hour-cell.status-yes {
  background: var(--color-yes-light);
  border-color: var(--color-yes);
  color: #166534;
}

.hour-cell.status-maybe {
  background: var(--color-maybe-light);
  border-color: var(--color-maybe);
  color: #92400e;
}

.hour-cell.status-no {
  background: var(--color-no-light);
  border-color: var(--color-no);
  color: #991b1b;
}

.mark-all-row {
  display: flex;
  gap: .5rem;
  align-items: center;
  padding: 0 .75rem .5rem;
  flex-wrap: wrap;
}

/* 12. Token Display */
.token-box {
  font-family: monospace;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  word-break: break-all;
  font-size: .875rem;
}

.token-row {
  display: flex;
  gap: .5rem;
  align-items: flex-start;
}

.copy-btn {
  flex-shrink: 0;
}

/* 13. Alerts */
.alert {
  padding: .875rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: .9rem;
}

.alert-success {
  background: var(--color-yes-light);
  color: #166534;
  border: 1px solid var(--color-yes);
}

.alert-error {
  background: var(--color-no-light);
  color: #991b1b;
  border: 1px solid var(--color-no);
}

.alert-info {
  background: var(--color-primary-light);
  color: #1e3a8a;
  border: 1px solid var(--color-primary);
}

.alert-warning {
  background: var(--color-maybe-light);
  color: #92400e;
  border: 1px solid var(--color-maybe);
}

/* 14. Spinner */
.spinner {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

.spinner-dark {
  display: inline-block;
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

/* 15. Keyframes */
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* 16. Header */
.app-header {
  padding: 1rem;
  background: white;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

/* 17. Results */
.results-summary {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.count-badge {
  padding: .5rem 1rem;
  border-radius: var(--radius);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  font-size: .9rem;
}

.slot-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.slot-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem;
  background: var(--color-bg);
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
}

.slot-rank {
  font-weight: 700;
  color: var(--color-text-muted);
  min-width: 1.5rem;
}

.yes-badge,
.maybe-badge,
.no-badge {
  padding: .2rem .5rem;
  border-radius: 4px;
  font-size: .8rem;
  font-weight: 600;
}

.yes-badge {
  background: var(--color-yes-light);
  color: #166534;
}

.maybe-badge {
  background: var(--color-maybe-light);
  color: #92400e;
}

.no-badge {
  background: var(--color-no-light);
  color: #991b1b;
}

/* 18. Utility Classes */
.text-muted {
  color: var(--color-text-muted);
}

.text-sm {
  font-size: .875rem;
}

.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.flex { display: flex; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none; }

/* 19. Responsive */
@media (max-width: 600px) {
  .months-row {
    flex-direction: column;
  }

  .hour-grid {
    font-size: .75rem;
  }

  .btn {
    padding: .5rem 1rem;
  }

  .card {
    padding: 1rem;
  }

  .container {
    padding: .75rem;
  }
}
