/* === Theme Variables === */
:root {
  color-scheme: dark;
  --bg:          #0d1f3c;
  --surface:     #162840;
  --surface-alt: #1c3252;
  --border:      rgba(255, 255, 255, 0.08);
  --text:        #e8eef7;
  --muted:       #7a95b8;
  --accent:      #2f7fff;
  --accent-hover:#1a6ae8;
  --danger:      #e05252;
  --warning:     #f0a732;
  --shadow:      0 4px 24px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  color-scheme: light;
  --bg:          #eef6ff;
  --surface:     #ffffff;
  --surface-alt: #f4f8ff;
  --border:      rgba(13, 55, 90, 0.10);
  --text:        #102a43;
  --muted:       #5f758f;
  --accent:      #0b69ff;
  --accent-hover:#0055dd;
  --danger:      #d93025;
  --warning:     #ffb830;
  --shadow:      0 4px 24px rgba(15, 62, 115, 0.08);
}

/* === Reset & Base === */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  transition: background 0.2s, color 0.2s;
}

h1 {
  margin: 0 0 4px;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}

p {
  margin: 0;
  color: var(--muted);
}

/* === App pages: sidebar + main side by side === */
body[data-page="overview"],
body[data-page="users"] {
  display: flex;
  min-height: 100vh;
}

/* === Sidebar === */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 24px 16px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 20px;
  border-bottom: 2px solid #3ab34a;
  margin-bottom: 20px;
}

.sidebar-logo .club-icon {
  width: 44px;
  height: 44px;
  object-fit: contain;
  flex-shrink: 0;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.4));
  border-radius: 4px;
}

.sidebar-logo-text strong {
  display: block;
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.2;
}

.sidebar-logo-text span {
  font-size: 0.76rem;
  color: var(--muted);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.sidebar-nav .nav-link {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.15s, color 0.15s;
}

.sidebar-nav .nav-link:hover {
  background: var(--surface-alt);
  color: var(--text);
}

body[data-page="overview"] .sidebar-nav a[href="index.html"],
body[data-page="users"]    .sidebar-nav a[href="users.html"] {
  background: var(--accent);
  color: #fff;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.user-info-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.user-label {
  font-size: 0.76rem;
  color: var(--muted);
}

.user-info-panel strong {
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 700;
  line-height: 1.2;
}

.user-role-badge {
  font-size: 0.74rem;
  color: var(--accent);
  font-weight: 600;
  text-transform: capitalize;
  margin-bottom: 4px;
}

/* === Main content area === */
.main-content {
  flex: 1;
  min-width: 0;
  padding: 32px 32px 48px;
  overflow-y: auto;
}

/* === Auth pages: centered layout (login, change-password) === */
.app-shell {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 24px 40px;
}

.app-shell header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 3px solid #3ab34a;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.app-shell header .header-text {
  flex: 1;
}

.app-shell header p {
  font-size: 0.95rem;
  margin-top: 2px;
}

.club-icon {
  vertical-align: middle;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.4));
}

.club-icon-inline {
  height: 1.4em;
  width: auto;
  object-fit: contain;
  border-radius: 3px;
}

/* === Panels === */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

/* === Buttons === */
.btn-primary {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 8px 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 14px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-secondary:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.btn-icon {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
  transition: background 0.15s;
  align-self: flex-start;
}

.btn-icon:hover {
  background: var(--surface-alt);
}

/* Circular action buttons on member cards */
.card-actions .btn-primary,
.action-buttons button {
  border: 0;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* === Tabs === */
.tab-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.tab-btn {
  padding: 9px 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab-btn:hover {
  background: var(--surface-alt);
  color: var(--text);
}

.tab-btn.tab-btn-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* === Penalty Preview (always-visible rows) === */
.penalty-preview {
  display: grid;
  gap: 6px;
  padding-top: 10px;
}

/* === Forms === */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  align-items: center;
}

.form-row input,
.form-row select {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  background: var(--surface-alt);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.form-row input:focus,
.form-row select:focus {
  border-color: var(--accent);
}

.form-row select,
.auth-form input {
  min-width: 180px;
}

.auth-form input {
  flex: 1 1 180px;
}

.form-row button {
  padding: 11px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s;
}

.form-row button:hover {
  background: var(--accent-hover);
}

/* === Total Fines === */
.total-fines {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.total-fines h2 {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}

.total-fines-summary {
  text-align: right;
}

.total-fines-amount {
  font-size: 0.95rem;
  color: var(--muted);
}

.total-fines-amount strong {
  font-size: 1.4rem;
  color: var(--accent);
  font-weight: 800;
}

.total-fines-extras {
  margin: 2px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.member-search-bar {
  margin-bottom: 14px;
}

.member-search-input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  background: var(--surface-alt);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.member-search-input:focus {
  border-color: var(--accent);
}

/* === Member Cards === */
.members-list {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr;
  align-items: stretch;
}

.member-card {
  display: flex;
  flex-direction: column;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 12px;
  background: var(--surface-alt);
}

.member-card.inactive {
  opacity: 0.65;
  border-left-color: var(--muted);
}

.member-card.inactive .member-name {
  color: var(--muted);
}

.member-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.member-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  overflow: hidden;
}

.member-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.member-summary-subtitle {
  font-size: 0.88rem;
  color: var(--muted);
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}

.toggle-btn {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.83rem;
  transition: background 0.15s, color 0.15s;
}

.toggle-btn:hover {
  background: var(--surface);
  color: var(--text);
}

/* === Penalty List === */
.penalty-list {
  display: none;
  gap: 7px;
  padding-top: 12px;
}

.member-card.expanded .penalty-list {
  display: grid;
}

.penalty-row {
  padding: 9px 14px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 0.91rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.penalty-row.removable {
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.penalty-row.removable:hover {
  background: rgba(224, 82, 82, 0.18);
  border-color: var(--danger);
  transform: translateY(-1px);
}

.penalty-row.removable:hover::after {
  content: '🗑️';
  margin-left: 8px;
}

.no-penalties {
  color: var(--muted);
  font-style: italic;
  font-size: 0.9rem;
}

.penalty-chip.removable {
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.penalty-chip.removable:hover {
  background: rgba(224, 82, 82, 0.18);
  transform: translateY(-1px);
}

.penalty-chip-label {
  font-weight: 600;
  color: var(--text);
}

.penalty-summary {
  text-align: left;
  font-size: 0.91rem;
  color: var(--text);
  line-height: 1.4;
  min-width: 120px;
}

/* === User Management === */
.user-list-panel {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-alt);
}

.user-row span {
  flex: 1 1 160px;
  font-weight: 600;
  color: var(--text);
}

.user-row.inactive {
  opacity: 0.65;
}

.user-row.inactive span {
  color: var(--muted);
}

.user-role-select {
  min-width: 110px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
}

.user-delete {
  padding: 8px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.15s;
}

.user-delete:hover {
  opacity: 0.85;
}

.role-panel label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.role-panel select {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  min-width: 180px;
  outline: none;
}

.role-message {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* === Modal === */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
  max-width: 960px;
  width: min(960px, calc(100% - 32px));
  max-height: 90vh;
  overflow-y: auto;
}

.modal-content h3 {
  margin: 0 0 16px;
  font-size: 1.2rem;
  color: var(--text);
  font-weight: 700;
}

.modal-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.modal-content input[type="date"] {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 18px;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}

.modal-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.modal-group {
  display: grid;
  gap: 8px;
  width: 100%;
}

.modal-group h4 {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.modal-btn {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface-alt);
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.modal-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* === Auth === */
.auth-panel {
  max-width: 480px;
}

/* === Misc === */
.hidden {
  display: none !important;
}

.settled-separator {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.settled-separator::before,
.settled-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.empty-state {
  color: var(--muted);
  padding: 24px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  text-align: center;
}

/* === Responsive === */
@media (max-width: 900px) {
  .modal-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Sidebar collapses to horizontal top bar on mobile */
@media (max-width: 768px) {
  body[data-page="overview"],
  body[data-page="users"] {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar-logo {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
  }

  .sidebar-nav {
    flex-direction: row;
    flex: none;
    gap: 6px;
  }

  .sidebar-footer {
    flex-direction: row;
    align-items: center;
    border-top: none;
    padding-top: 0;
    margin-left: auto;
    gap: 8px;
  }

  .user-label,
  .user-role-badge {
    display: none;
  }

  .user-info-panel strong {
    display: none;
  }

  .user-info-panel {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .main-content {
    padding: 20px 16px 32px;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: 20px 16px 32px;
  }

  .app-shell header {
    flex-direction: column;
    gap: 10px;
  }

  .modal-content {
    padding: 16px;
  }

  .modal-options {
    grid-template-columns: 1fr;
  }

  .member-card-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .card-actions {
    justify-content: flex-start;
  }
}
