/* === Reset & Base === */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-dark: #1a1625;
  --bg-card: #241e30;
  --bg-input: #2d2438;
  --bg-nav: #1e1829;
  --text: #dcd7e8;
  --text-muted: #8b8394;
  --accent: #c4a0f0;
  --accent-hover: #d4b8f8;
  --success: #5ddb8a;
  --warning: #f0a841;
  --danger: #e05a4f;
  --border: #352d42;
  --radius: 6px;

  /* WoW class colors */
  --class-warrior: #c79c6e;
  --class-paladin: #f58cba;
  --class-hunter: #abd473;
  --class-rogue: #fff569;
  --class-priest: #ffffff;
  --class-shaman: #0070de;
  --class-mage: #69ccf0;
  --class-warlock: #9482c9;
  --class-druid: #ff7d0a;
  --class-unknown: #808080;
}

body {
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  color: var(--accent-hover);
}

/* === Layout === */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* === Cards === */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}

.card h2 {
  margin-bottom: 14px;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

/* === Stat Cards Row === */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.stat-card .stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.stat-card .offspec-count,
td .offspec-count {
  color: var(--warning);
  font-size: 0.75em;
  font-weight: 600;
}

/* === Tables === */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 600;
}

tr:hover {
  background: rgba(196, 160, 240, 0.04);
}

/* === Search === */
.search-row {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input {
  width: 100%;
  padding: 8px 36px 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}

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

.search-input::placeholder {
  color: var(--text-muted);
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.search-clear:hover {
  color: var(--accent);
}

.search-count {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* === Forms === */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

input[type='text'],
input[type='password'],
input[type='date'],
select,
textarea {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

textarea {
  min-height: 120px;
  resize: vertical;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.8rem;
}

/* === Buttons === */
.btn {
  display: inline-block;
  padding: 8px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 500;
  transition: background 150ms ease;
}

.btn-primary {
  background: var(--accent);
  color: #1a1625;
}
.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover {
  background: #c94a40;
}

.btn-sm {
  padding: 4px 12px;
  font-size: 0.8rem;
}

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

.btn-discord {
  background: #5865f2;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  padding: 12px 24px;
}
.btn-discord:hover {
  background: #4752c4;
}

/* === Navbar === */
.navbar {
  background: var(--bg-nav);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 20px;
  height: 54px;
}

.navbar .brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.navbar .brand {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  white-space: nowrap;
}

.navbar .nav-links {
  display: flex;
  gap: 4px;
  flex: 1;
}

.navbar .nav-link {
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
  border: none;
  background: none;
  font-family: inherit;
  font-weight: 500;
  transition: color 150ms ease, background 150ms ease;
}

.navbar .nav-link:hover {
  color: var(--text);
  background: rgba(196, 160, 240, 0.08);
}
.navbar .nav-link.active {
  color: var(--text);
  background: rgba(196, 160, 240, 0.12);
}

.navbar .nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.navbar .phase-select {
  padding: 4px 8px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.85rem;
  font-family: inherit;
}

.navbar .user-info {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.navbar .logout-btn {
  padding: 4px 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
  transition: color 150ms ease, border-color 150ms ease;
}
.navbar .logout-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* === Landing Page === */
.landing {
  max-width: 860px;
  margin: 0 auto;
  padding: 60px 20px 40px;
}

.landing-hero {
  text-align: center;
  margin-bottom: 60px;
}

.landing-title {
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}

.landing-tagline {
  font-size: 1.05rem;
  color: var(--text-muted);
  max-width: 520px;
  margin: 0 auto 28px;
  line-height: 1.6;
}

.btn-discord-lg {
  font-size: 1.05rem;
  padding: 14px 32px;
}

.landing-section-title {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 28px;
}

.landing-feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 60px;
}

.landing-feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  transition: border-color 200ms ease;
}

.landing-feature-card:hover {
  border-color: var(--accent);
}

.landing-feature-icon {
  font-size: 1.6rem;
  margin-bottom: 10px;
}

.landing-feature-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}

.landing-feature-card p {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.landing-cta {
  text-align: center;
  padding: 32px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.landing-cta p {
  color: var(--text-muted);
  margin-bottom: 18px;
  font-size: 0.95rem;
}

@media (max-width: 768px) {
  .landing {
    padding: 32px 16px 24px;
  }
  .landing-title {
    font-size: 1.8rem;
  }
  .landing-feature-grid {
    grid-template-columns: 1fr;
  }
}

/* === Login Page === */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 380px;
}

.login-box h1 {
  text-align: center;
  color: var(--text);
  margin-bottom: 8px;
  font-size: 1.4rem;
}

.login-box .btn {
  width: 100%;
}

/* === Badges === */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-won {
  background: var(--success);
  color: #1a1625;
}
.badge-missed {
  background: var(--danger);
  color: #fff;
}
.badge-lost {
  background: var(--danger);
  color: #fff;
}
.badge-no-drop {
  background: #706880;
  color: #dcd7e8;
}
.badge-reserved {
  background: #5865f2;
  color: #fff;
}
.badge-offspec {
  background: var(--warning);
  color: #1a1625;
}
.badge-roll {
  background: #524866;
  color: #dcd7e8;
}

/* === Messages === */
.msg {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
  font-size: 0.85rem;
}

.msg-success {
  background: rgba(93, 219, 138, 0.12);
  border: 1px solid var(--success);
  color: var(--success);
}
.msg-error {
  background: rgba(224, 90, 79, 0.12);
  border: 1px solid var(--danger);
  color: var(--danger);
}
.msg-info {
  background: rgba(196, 160, 240, 0.12);
  border: 1px solid var(--accent);
  color: var(--accent);
}

/* === Item Icon === */
.item-icon {
  width: 24px;
  height: 24px;
  border-radius: 3px;
  vertical-align: middle;
  margin-right: 6px;
  border: 1px solid var(--border);
}

.item-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* === Class colors === */
.class-WARRIOR {
  color: var(--class-warrior);
}
.class-PALADIN {
  color: var(--class-paladin);
}
.class-HUNTER {
  color: var(--class-hunter);
}
.class-ROGUE {
  color: var(--class-rogue);
}
.class-PRIEST {
  color: var(--class-priest);
}
.class-SHAMAN {
  color: var(--class-shaman);
}
.class-MAGE {
  color: var(--class-mage);
}
.class-WARLOCK {
  color: var(--class-warlock);
}
.class-DRUID {
  color: var(--class-druid);
}
.class-UNKNOWN {
  color: var(--class-unknown);
}

/* === Two column layout === */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

/* === Chart containers === */
.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}

.chart-container-sm {
  height: 260px;
  max-width: 360px;
  margin: 0 auto;
}

@media (max-width: 768px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .navbar {
    flex-wrap: wrap;
    height: auto;
    padding: 10px;
  }
  .chart-container,
  .chart-container-sm {
    height: 220px;
  }
}

/* === Loading === */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

/* === Upload section === */
.upload-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 16px;
}

.upload-section h3 {
  margin-bottom: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

/* === Scrollable table container === */
.table-wrap {
  overflow-x: auto;
}

/* === Corrected row indicator === */
tr.corrected-row {
  border-left: 3px solid var(--warning);
}

.corrected-icon {
  color: var(--warning);
  font-size: 0.75rem;
  margin-left: 4px;
  cursor: help;
}

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

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 {
  color: var(--text);
  margin-bottom: 16px;
  font-size: 1rem;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}

.modal .form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.modal .form-row .form-group {
  flex: 1;
  margin-bottom: 0;
}

.modal .checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.modal .checkbox-group input[type='checkbox'] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.modal .checkbox-group label {
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 0;
}

.modal .btn-row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.btn-secondary {
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 8px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 150ms ease;
}

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

.btn-edit {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 0.85rem;
  border-radius: var(--radius);
  transition: color 150ms ease, background 150ms ease;
}

.btn-edit:hover {
  color: var(--accent);
  background: rgba(196, 160, 240, 0.1);
}

/* === Correction history in modal === */
.correction-info {
  background: rgba(240, 168, 65, 0.1);
  border: 1px solid var(--warning);
  border-radius: var(--radius);
  padding: 10px;
  margin-bottom: 14px;
  font-size: 0.8rem;
  color: var(--warning);
}

.correction-info strong {
  display: block;
  margin-bottom: 4px;
}

/* === Attendance Page === */
.attendance-table-wrap {
  overflow-x: auto;
  max-height: 70vh;
  overflow-y: auto;
}

.attendance-table {
  border-collapse: collapse;
  font-size: 0.82rem;
  white-space: nowrap;
}

.attendance-table th,
.attendance-table td {
  padding: 4px 8px;
  text-align: center;
  border: 1px solid var(--border);
}

.attendance-table .sticky-col {
  position: sticky;
  left: 0;
  background: var(--bg-card);
  z-index: 2;
  text-align: left;
  min-width: 120px;
}

.attendance-table thead th {
  position: sticky;
  top: 0;
  background: var(--bg-nav);
  z-index: 3;
}

.attendance-table thead th.sticky-col {
  z-index: 4;
}

.attendance-table .date-col {
  font-size: 0.72rem;
  min-width: 56px;
}

.attendance-table .player-name {
  font-weight: 500;
}

.att-cell {
  font-weight: 700;
  width: 56px;
}

.att-present {
  color: var(--success);
  background: rgba(93, 219, 138, 0.08);
}

.att-absent {
  color: var(--danger);
  background: rgba(224, 90, 79, 0.06);
}

.att-high {
  color: var(--success);
  font-weight: 700;
}

.att-mid {
  color: var(--warning);
  font-weight: 700;
}

.att-low {
  color: var(--danger);
  font-weight: 700;
}

/* === Guild Settings === */
.role-select {
  width: auto;
  padding: 4px 8px;
  font-size: 0.82rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
}

.invite-link-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.invite-link-input {
  flex: 1;
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 0.82rem;
}

.discord-status {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.discord-linked {
  color: var(--success);
  font-size: 0.9rem;
  font-weight: 500;
}

.danger-zone-card {
  border-color: var(--danger);
}

.danger-zone-card h2 {
  color: var(--danger);
  border-bottom-color: var(--danger);
}

/* === Guild Setup === */
.guild-setup-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
}

.guild-setup-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 440px;
  text-align: center;
}

.guild-setup-box h1 {
  color: var(--text);
  margin-bottom: 8px;
  font-size: 1.4rem;
}

.guild-setup-box .subtitle {
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 0.85rem;
}

.guild-setup-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guild-setup-btn {
  width: 100%;
  padding: 14px 20px;
  font-size: 1rem;
}

.guild-setup-box form {
  text-align: left;
}

.guild-setup-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* === Developer Panel === */
.stat-box {
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}
.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.row-selected {
  background: rgba(196, 160, 240, 0.1);
}

/* === Raids Page === */

/* --- Raid Timeline --- */
.raid-timeline {
  margin-bottom: 18px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.raid-timeline-track {
  display: flex;
  min-width: max-content;
  position: relative;
}

/* Line that spans the full track behind markers */
.raid-timeline-track::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22px;
  height: 2px;
  background: var(--border);
}

.raid-timeline-day {
  flex: 1 0 0;
  min-width: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.raid-timeline-marker {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  z-index: 1;
  flex-shrink: 0;
}

.raid-timeline-marker-muted {
  background: var(--text-muted);
  opacity: 0.4;
}

.raid-timeline-today .raid-timeline-marker {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(196, 160, 240, 0.5);
}

.raid-timeline-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: nowrap;
}

.raid-timeline-today .raid-timeline-label {
  color: var(--accent);
  font-weight: 600;
}

.raid-timeline-dots {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 6px;
  min-height: 24px;
  align-items: center;
  justify-content: flex-end;
}

.raid-timeline-dot {
  background: var(--accent);
  color: var(--bg-dark);
  font-size: 0.68rem;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: 10px;
  padding: 2px 8px;
  cursor: pointer;
  white-space: nowrap;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 150ms ease, transform 150ms ease;
}

.raid-timeline-dot:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.raid-timeline-future-pill {
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 500;
  border-radius: 10px;
  padding: 2px 8px;
  white-space: nowrap;
}

.raid-timeline-future-col {
  flex: 0 0 auto;
  min-width: 72px;
}

/* --- Raid Filter Tabs --- */
.raid-filter-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 14px;
}

.raid-filter-tab {
  padding: 5px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  background: none;
  font-family: inherit;
  font-weight: 500;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}

.raid-filter-tab:hover {
  color: var(--text);
  background: rgba(196, 160, 240, 0.08);
}

.raid-filter-tab.active {
  color: var(--text);
  background: rgba(196, 160, 240, 0.12);
  border-color: var(--accent);
}

.badge-raid-open {
  background: var(--success);
  color: #1a1625;
}

.badge-raid-closed {
  background: #706880;
  color: #dcd7e8;
}

.badge-raid-cancelled {
  background: var(--danger);
  color: #fff;
}

.badge-raid-tentative {
  background: var(--warning);
  color: #1a1625;
}

.raid-signups-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.raid-role-group {
  background: var(--bg-input);
  border-radius: var(--radius);
  padding: 12px;
}

.raid-signup-row {
  display: flex;
  align-items: center;
  padding: 4px 0;
  font-size: 0.85rem;
}

.raid-signup-row + .raid-signup-row {
  border-top: 1px solid var(--border);
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-switch .toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.toggle-switch .toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  bottom: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: #fff;
}
