:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f3f4f6;
  color: #111827;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 100%);
}

button,
input {
  font: inherit;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem;
}

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

.app-header h1 {
  margin: 0;
  font-size: clamp(1.8rem, 2.2vw, 2.6rem);
}

.subtitle {
  margin: 0.3rem 0 0;
  color: #4b5563;
}

.main-nav {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.nav-button {
  border: 1px solid #808080;
  background: #013369;
  color: white;
  padding: 0.75rem 1rem;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.nav-button:hover {
  transform: translateY(-1px);
  background: #D50A0A;
}

.hidden {
  display: none !important;
}

.app-main {
  display: grid;
  gap: 1.25rem;
}

.page {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  padding: 1.25rem;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.05);
}

.page h2 {
  margin-top: 0;
}

.auth-form {
  display: grid;
  gap: 1rem;
}

.auth-form label {
  display: grid;
  gap: 0.5rem;
  color: #374151;
}

.auth-form input {
  width: 100%;
  padding: 0.9rem 1rem;
  border: 1px solid #d1d5db;
  border-radius: 0.75rem;
  background: #f8fafc;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.form-actions button {
  border: #808080;
  background: #013369;
  color: white;
  padding: 0.9rem 1.25rem;
  border-radius: 0.75rem;
  cursor: pointer;
  border-color: #808080;
}

.form-actions button:hover {
  background: #D50A0A;  
}

.form-actions button[type='button'] {
  background: #013369;
}

.form-actions button[type='button']:hover {
  background: #D50A0A;
}

.list-container {
  min-height: 160px;
}

#picker-section {
  padding: 1rem;
}

#picker-section .picker-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 0.8rem;
}

#picker-section .picker-toolbar label {
  display: grid;
  gap: 0.3rem;
  margin: 0;
  min-width: 160px;
  flex: 1 1 auto;
}

#picker-section .picker-toolbar .action-button {
  flex: 0 0 auto;
}

#picker-section .list-container {
  min-height: 420px;
}

#picker-section .table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.65rem 0;
  font-size: 0.95rem;
}

#picker-section .table th,
#picker-section .table td {
  padding: 0.4rem 0.5rem !important;
}

#picker-section .page-note {
  margin-bottom: 0.65rem;
  padding: 0.7rem 0.85rem;
}

.dashboard-widgets {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.9rem;
  margin-top: 0.9rem;
}

.dashboard-widgets .widget {
  min-height: 260px;
}

.dashboard-widgets .widget-content {
  max-height: 320px;
  padding: 0.75rem;
}

.widget-header {
  padding: 0.85rem;
}

#picker-section .widget-header h3 {
  font-size: 1rem;
}

.table th,
.table td {
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
  padding: 0.85rem 0.75rem;
  vertical-align: middle;
}

.table th {
  font-weight: 700;
  color: #111827;
}

.table tbody tr:hover {
  background: #f8fafc;
}

/* Game row highlighting for correct/incorrect picks */
.game-row.pick-correct,
.game-row.pick-correct > td {
  background-color: #d1fae5 !important;
  border-left: 4px solid #22c55e;
}

.game-row.pick-correct:hover,
.game-row.pick-correct:hover > td {
  background-color: #86efac !important;
}

.game-row.pick-incorrect,
.game-row.pick-incorrect > td {
  background-color: #fee2e2 !important;
  border-left: 4px solid #ef4444;
}

.game-row.pick-incorrect:hover,
.game-row.pick-incorrect:hover > td {
  background-color: #fecaca !important;
}

.action-button {
  border: 1px solid #808080;
  background: #013369;
  color: white;
  padding: 0.00rem 0.50rem;
  border-radius: 0.75rem;
  cursor: pointer;
}

.action-button:hover {
  transform: translateY(-2px);
  background: #D50A0A;
}

.action-button:disabled,
.action-button.disabled {
  background: #d1d5db;
  border-color: #9ca3af;
  color: #6b7280;
  cursor: not-allowed;
  opacity: 0.6;
}

.action-button.secondary {
  background: #ffffff;
  color: #808080;
  border-color: #d1d5db;
}

.action-button.secondary:hover {
  background: #013369;
  color: white;
  border-color: black;
}
.action-button.secondary:disabled,
.action-button.secondary.disabled {
  background: #f3f4f6;
  border-color: #d1d5db;
  color: #9ca3af;
  cursor: not-allowed;
  opacity: 0.6;
}

.status-message {
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 0.75rem;
  background: #f8fafc;
  border: 1px solid #c7d2fe;
  color: #1e293b;
}

.status-message.error {
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
}

.page-note {
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border-radius: 0.75rem;
  background: #eef2ff;
  color: #1d4ed8;
}

.app-footer {
  text-align: center;
  color: #475569;
  font-size: 0.95rem;
  margin-top: 1rem;
}

/* Admin styles */
.admin-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 0.5rem;
}

.admin-nav-button {
  border: 1px solid #808080;
  background: #013369;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
}

.admin-nav-button.active {
  background: #013369;
  color: white;
  border-color: #808080;
}

.admin-nav-button:hover {
  transform: translateY(-1px);
  background: #D50A0A;
}

.admin-page {
  display: none;
}

.admin-page.active {
  display: block;
}

.crud-form {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  background: #f9fafb;
}

.crud-form h4 {
  margin-top: 0;
}

.crud-form label {
  display: block;
  margin-bottom: 0.5rem;
}

.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  z-index: 1000;
}

.dialog {
  width: min(660px, 100%);
  background: white;
  border-radius: 1rem;
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.2);
  overflow: hidden;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
}

.dialog-header h4 {
  margin: 0;
  font-size: 1.1rem;
}

.close-button {
  border: none;
  background: transparent;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  color: #374151;
}

.dialog-form {
  padding: 1.25rem;
}

.dialog-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  flex-wrap: wrap;
}

.dialog-form label {
  margin-bottom: 1rem;
}

.games-toolbar {
  margin-bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
}

.games-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  flex: 1;
  min-width: 320px;
}

.games-filters label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.9rem;
  color: #374151;
}

.small-select,
.small-input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  background: white;
}

.dialog-overlay.hidden {
  display: none;
}

#playoffs-container {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

#playoffs-container .widget {
  min-width: 0;
}

#playoffs-container .widget-content {
  overflow: visible;
  max-height: none;
  padding: 0.75rem;
}

#playoffs-container .table {
  width: 100%;
}

#playoffs-container .game-team-cell {
  flex-wrap: wrap;
  white-space: normal;
}

#game-schedule-fields {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#game-schedule-fields.hidden {
  display: none;
}

.select-with-icon {
  padding-left: 2.5rem;
}

.select-with-icon option {
  padding-left: 2.5rem;
  background-repeat: no-repeat;
  background-position: left center;
  background-size: 24px 24px;
}

.crud-form input,
.crud-form select {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.25rem;
}

.team-select-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 180px;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.team-picker {
  position: relative;
}

.team-picker-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  background: #f8fafc !important;
  color: #111827 !important;
  cursor: pointer;
  text-align: left;
}

.team-picker-button:hover,
.team-picker-button:focus {
  background: #eef2ff !important;
}

.team-picker-button-icon {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  border-radius: 50%;
  overflow: hidden;
  background: #f8fafc;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.team-picker-button-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.team-picker-button-label {
  flex: 1;
  color: #111827;
}

.team-picker-button-chevron {
  color: #6b7280;
}

.team-picker-list {
  position: absolute;
  z-index: 1100;
  left: 0;
  right: 0;
  max-height: 280px;
  overflow: auto;
  margin-top: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.75rem;
  background: white;
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
}

.team-picker .team-picker-item,
.team-picker .team-picker-button {
  appearance: none;
  border: none;
  background: white;
  color: #111827;
}

.team-picker .team-picker-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
}

.team-picker .team-picker-item:last-child {
  border-bottom: none;
}

.team-picker .team-picker-item:hover,
.team-picker .team-picker-item:focus {
  background: #e9effb;
  outline: none;
}

.team-picker .team-picker-item.selected {
  background: #dde7fd;
}

.team-picker-item-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  background: #f8fafc;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.team-picker-item-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.team-picker-button-icon {
  width: 28px;
  height: 28px;
  min-width: 28px;
  min-height: 28px;
  border-radius: 50%;
  overflow: hidden;
  background: #f8fafc;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.team-picker-button-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.team-picker-preview {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.75rem;
  border-radius: 0.75rem;
  min-height: 56px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
}

.team-picker-preview img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.team-picker-preview span {
  display: block;
}

.team-picker-input {
  display: none;
}

.game-team-cell {
  display: flex;
  /* justify-content: center;  Horizontal centering */
  align-items: center; /* Vertical centering */
  gap: 0.6rem;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.game-team-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  vertical-align: middle;
  white-space: nowrap;
}

.game-vs {
  color: #6b7280;
  font-weight: 700;
}


.winner-display {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  vertical-align: middle;
  line-height: 1;
}

.game-team-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  background: #f8fafc;
}

.game-team-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.winner-team-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  background: #f8fafc;
  margin-right: 0.3rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.winner-team-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.picked-team-display,
.pick-button-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.picked-team-icon,
.pick-button-icon {
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  border-radius: 50%;
  overflow: hidden;
  background: #f8fafc;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.picked-team-icon img,
.pick-button-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.action-button,
.action-button.secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dialog-overlay.hidden {
  display: none;
}

.team-preview img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 0.35rem;
  border: 1px solid #e5e7eb;
}

.team-preview .team-preview-label {
  display: grid;
  gap: 0.2rem;
  font-size: 0.95rem;
}

.date-time-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.date-time-row label {
  margin-bottom: 0;
}

.crud-form button {
  margin-top: 0.5rem;
}

/* Dashboard Widgets Layout */
.dashboard-widgets {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
  margin-top: 1.25rem;
}

.widget {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.widget-header {
  background: #f3f4f6;
  border-bottom: 1px solid #e5e7eb;
  padding: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.widget-header h3 {
  margin: 0;
  font-size: 1.1rem;
  color: #1f2937;
}

.widget-content {
  flex: 1;
  overflow-y: auto;
  max-height: 400px;
  padding: 0;
}

.standings-table,
.performers-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.standings-table thead,
.performers-table thead {
  background: #f3f4f6;
  position: sticky;
  top: 0;
  z-index: 1;
}

.standings-table th,
.performers-table th {
  padding: 0.75rem;
  text-align: left;
  font-weight: 600;
  color: #374151;
  border-bottom: 2px solid #e5e7eb;
}

.standings-table td,
.performers-table td {
  padding: 0.75rem;
  border-bottom: 1px solid #e5e7eb;
  color: #1f2937;
}

.standings-table tbody tr:hover,
.performers-table tbody tr:hover {
  background-color: #f9fafb;
}

.standings-table tbody tr:last-child td,
.performers-table tbody tr:last-child td {
  border-bottom: none;
}

.rank-cell {
  font-weight: 600;
  color: #4338ca;
  min-width: 2rem;
}

.player-name-cell {
  font-weight: 500;
}

.points-cell {
  text-align: right;
  font-weight: 600;
  color: #059669;
}

.widget-empty-message {
  padding: 2rem 1rem;
  text-align: center;
  color: #6b7280;
  font-size: 0.95rem;
}

/* Responsive: Stack widgets on smaller screens */
@media (max-width: 768px) {
  .dashboard-widgets {
    grid-template-columns: 1fr;
  }
}

.crud-form button[type='submit'] {
  background: #10b981;
  color: white;
}

.crud-form button[type='button'] {
  background: #6b7280;
  color: white;
}

/* Keep custom team-picker options readable inside CRUD forms. */
.crud-form .team-picker .team-picker-item {
  background: #ffffff;
  color: #0f172a;
  border-bottom: 1px solid #e2e8f0;
}

.crud-form .team-picker .team-picker-item:hover,
.crud-form .team-picker .team-picker-item:focus,
.crud-form .team-picker .team-picker-item:focus-visible {
  background: #e0e7ff;
  color: #0f172a;
  outline: none;
}

.crud-form .team-picker .team-picker-item.selected {
  background: #bfdbfe;
  color: #0f172a;
  font-weight: 600;
}

.crud-form .team-picker .team-picker-item.selected:hover,
.crud-form .team-picker .team-picker-item.selected:focus,
.crud-form .team-picker .team-picker-item.selected:focus-visible {
  background: #93c5fd;
  color: #0f172a;
}

.sub-nav {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.sub-nav-button {
  border: 1px solid #808080;
  background: #013369;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
}

.sub-nav-button.active {
  background: #013369;
  color: white;
  border-color: #808080;
}

.sub-nav-button:hover {
  transform: translateY(-1px);
  background: #D50A0A;
}

.games-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: #f8fafc;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
}

.games-controls.hidden {
  display: none;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.control-group label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-weight: 500;
}

.control-group select,
.control-group input {
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.25rem;
  font-size: 1rem;
}

.control-group input[type='number'] {
  width: 120px;
}

#games-import-btn {
  padding: 0.5rem 1.5rem;
  background: #3b82f6;
  color: white;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-weight: 500;
}

#games-import-btn:hover {
  background: #2563eb;
}

@media (max-width: 700px) {
  .app-header {
    flex-direction: column;
    align-items: stretch;
  }

  .nav-button {
    width: 100%;
  }
}

/* Ensure winner select is visible and styled in schedule rows */
.winner-select {
  display: inline-block;
  min-width: 120px;
  padding: 0.45rem 0.6rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  background: white;
  color: #111827;
  appearance: auto;
}

.winner-select:focus {
  outline: 2px solid rgba(59,130,246,0.3);
}
