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

:root {
  --bg: #0f0e17;
  --surface: #1a1a2e;
  --surface-2: #16213e;
  --text: #e8e8e8;
  --text-muted: #a0a0b0;
  --primary: #e94560;
  --primary-hover: #ff6b81;
  --green: #2ecc71;
  --green-bg: rgba(46, 204, 113, 0.15);
  --red: #e74c3c;
  --red-bg: rgba(231, 76, 60, 0.15);
  --yellow: #f39c12;
  --yellow-bg: rgba(243, 156, 18, 0.15);
  --border: #2a2a4a;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Noto Sans TC', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

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

/* ─── Navbar ─── */
.navbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text) !important;
  letter-spacing: 1px;
}
.nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
}
.nav-link {
  color: var(--text-muted) !important;
  font-size: 0.9rem;
  transition: color 0.2s;
}
.nav-link:hover { color: var(--text) !important; }
.nav-login {
  background: var(--primary);
  color: #fff !important;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.nav-login:hover { background: var(--primary-hover) !important; color: #fff !important; }
.nav-logout { color: var(--text-muted) !important; }
.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-size: 0.9rem;
}
.avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--primary);
}

/* ─── Container ─── */
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 24px 20px 80px;
}

/* ─── Page Header ─── */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-header h1 { font-size: 1.6rem; }
.page-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.breadcrumb { width: 100%; margin-bottom: 8px; }
.breadcrumb a { color: var(--text-muted); font-size: 0.9rem; }

/* ─── Buttons ─── */
.btn {
  display: inline-block;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-warning { background: var(--yellow); color: #000; }
.btn-warning:hover { opacity: 0.85; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { opacity: 0.85; }

/* ─── Raid Grid ─── */
.raid-grid {
  display: grid;
  gap: 20px;
}
.raid-card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: all 0.2s;
  text-decoration: none;
  color: var(--text);
}
.raid-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  color: var(--text);
}
.raid-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.raid-card-header h3 { font-size: 1.1rem; }
.raid-card-body .raid-info {
  display: flex;
  gap: 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 12px;
}
.raid-progress {
  display: flex;
  align-items: center;
  gap: 12px;
}
.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s;
}
.fill-green { background: var(--green); }
.fill-red { background: var(--red); }
.raid-count {
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
}
.text-full { color: var(--primary); }
.waitlist-count {
  font-size: 0.8rem;
  color: var(--yellow);
  margin-left: 4px;
}
/* ─── Raid Role Stats (Card) ─── */
.raid-role-stats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.rrs-item {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
}
.rrs-tank { color: #3498db; background: rgba(52,152,219,0.15); }
.rrs-dd { color: #e74c3c; background: rgba(231,76,60,0.15); }
.rrs-healer { color: #2ecc71; background: rgba(46,204,113,0.15); }
.rrs-flex { color: #9b59b6; background: rgba(155,89,182,0.15); }

.raid-card-status {
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-dot.green { background: var(--green); }
.status-dot.red { background: var(--red); }
.status-dot.gray { background: #555; }

/* ─── Raid Detail ─── */
.raid-detail { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
.detail-header {
  padding: 24px;
  border-bottom: 1px solid var(--border);
}
.detail-header.header-green { background: var(--green-bg); }
.detail-header.header-gray { background: rgba(85, 85, 85, 0.15); }
.detail-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.detail-title-row h1 { font-size: 1.5rem; }
.detail-status {
  font-size: 0.95rem;
  font-weight: 600;
}
.detail-status.green { color: var(--green); }
.detail-status.gray { color: #888; }
.detail-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.meta-item { display: flex; flex-direction: column; gap: 4px; }
.meta-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; }
.meta-value { font-size: 0.95rem; font-weight: 600; }

/* ─── Alert ─── */
.alert {
  padding: 14px 20px;
  margin: 16px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
}
.alert-warning { background: var(--yellow-bg); color: var(--yellow); border: 1px solid rgba(243,156,18,0.3); }
.alert-info { background: rgba(52,152,219,0.15); color: #3498db; border: 1px solid rgba(52,152,219,0.3); }
.alert-error { background: var(--red-bg); color: var(--red); border: 1px solid rgba(231,76,60,0.3); }

/* ─── Sections ─── */
.detail-section { padding: 20px 24px; border-bottom: 1px solid var(--border); }
.detail-section:last-child { border-bottom: none; }
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.section-header h2, .detail-section h2 { font-size: 1.1rem; }
.section-actions { display: flex; gap: 8px; }

/* ─── Member Grid ─── */
.signup-list { display: flex; flex-direction: column; gap: 20px; }
.signup-group h3 { font-size: 0.95rem; margin-bottom: 12px; color: var(--text-muted); }
.member-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.member-card {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
}
.member-card.member-self {
  border-color: var(--primary);
  background: rgba(233, 69, 96, 0.1);
}
.member-card.member-waitlist { opacity: 0.7; }
.member-card.role-tank { border-color: #3498db; }
.member-card.role-dd { border-color: #e74c3c; }
.member-card.role-healer { border-color: #2ecc71; }
.member-card.role-flex { border-color: #9b59b6; }
.member-avatar img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}
.member-name { font-weight: 500; }
.member-role { font-size: 0.75rem; margin-left: 2px; }

/* ─── Role Stats ─── */
.role-stats {
  display: flex;
  gap: 16px;
  padding: 10px 24px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.role-stat {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
}
.role-stat.role-tank { color: #3498db; background: rgba(52,152,219,0.15); }
.role-stat.role-dd { color: #e74c3c; background: rgba(231,76,60,0.15); }
.role-stat.role-healer { color: #2ecc71; background: rgba(46,204,113,0.15); }
.role-stat.role-flex { color: #9b59b6; background: rgba(155,89,182,0.15); }

/* ─── Signup Form ─── */
.signup-form {
  display: flex;
  gap: 8px;
  align-items: center;
}
.signup-role-select {
  padding: 8px 34px 8px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a0a0b0' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.signup-role-select:hover { border-color: var(--primary); }
.signup-role-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(233,69,96,0.2); }

/* ─── Group List ─── */
.group-list { display: flex; flex-direction: column; gap: 8px; }
.group-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  transition: background 0.2s;
}
.group-item:hover { background: var(--border); }

/* ─── Admin ─── */
.admin-section { background: rgba(233, 69, 96, 0.05); }
.admin-actions { display: flex; gap: 10px; }

/* ─── Profile Page ─── */
.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  max-width: 480px;
}
.profile-info {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.profile-avatar img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid var(--primary);
}
.profile-discord { font-size: 1.1rem; font-weight: 700; }
.profile-label { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }
.form-nickname .form-actions { padding-top: 8px; }

/* ─── Form ─── */
.form-raid {
  background: var(--surface);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.form-group { margin-bottom: 20px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a0a0b0' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}
.form-group select:hover { border-color: var(--primary); }
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(233,69,96,0.2);
}

.form-group select option,
.signup-role-select option {
  background: var(--surface);
  color: var(--text);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
}
.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  color: var(--text) !important;
  font-size: 0.95rem !important;
}
.checkbox-label input[type="checkbox"] {
  width: auto;
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}
.recurring-options {
  padding: 16px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
}
.form-actions {
  display: flex;
  gap: 12px;
  padding-top: 12px;
}

/* ─── Empty State ─── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ─── Badge ─── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-recurring { background: rgba(52, 152, 219, 0.2); color: #3498db; }
.badge-expired { background: rgba(85, 85, 85, 0.3); color: #999; }

/* ─── Form Hint ─── */
.form-hint { display: block; font-size: 0.78rem; margin-top: 4px; color: var(--text-muted); }
.text-muted { color: var(--text-muted); }
.text-danger { color: var(--red); }

/* ─── Header Clock ─── */
.header-clock {
  text-align: center;
  padding: 8px 20px;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}

/* ─── My Signups ─── */
.my-signups {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}
.my-signups-header {
  padding: 12px 20px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.5px;
}
.my-signups-list {
  display: flex;
  flex-direction: column;
}
.my-signup-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  text-decoration: none;
  color: var(--text);
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  transition: background 0.15s, border-left-color 0.2s;
}
.my-signup-item:last-child { border-bottom: none; }
.my-signup-item:hover { background: var(--surface-2); color: var(--text); }
.my-signup-item.my-open { border-left-color: var(--green); }
.my-signup-item.my-full { border-left-color: var(--yellow); }
.my-signup-item.my-expired { border-left-color: #555; opacity: 0.6; }
.my-signup-item.my-expired:hover { opacity: 0.8; }

.my-signup-left { flex-shrink: 0; }
.my-signup-dot {
  display: block;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--green);
}
.my-open .my-signup-dot { background: var(--green); }
.my-full .my-signup-dot { background: var(--yellow); }
.my-expired .my-signup-dot { background: #666; }

.my-signup-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.my-signup-name {
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.my-signup-meta {
  color: var(--text-muted);
  font-size: 0.78rem;
  display: flex;
  gap: 12px;
  align-items: center;
}
.my-signup-time { white-space: nowrap; }

.my-signup-right {
  flex-shrink: 0;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  min-width: 80px;
}
.my-signup-count {
  font-size: 1.05rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.my-count-full { color: var(--yellow); }
.my-count-expired { color: var(--text-muted); }
.my-count-total {
  font-size: 0.78rem;
  font-weight: 400;
  color: var(--text-muted);
}
.my-signup-bar {
  width: 60px;
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
}
.my-signup-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--green);
  transition: width 0.3s;
}
.my-full .my-signup-fill { background: var(--yellow); }
.my-expired .my-signup-fill { background: #555; }

/* ─── My Signups Tab Bar ─── */
.my-tab-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.my-tab-item {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
  user-select: none;
}
.my-tab-item:hover { color: var(--text); }
.my-tab-item.active { color: var(--text); }
.my-tab-item small {
  font-weight: 400;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-left: 4px;
}
.my-tab-content { display: none; }
.my-tab-content.active { display: block; }
.tab-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.tab-item {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
  user-select: none;
  letter-spacing: 0.5px;
}
.tab-item:hover { color: var(--text); }
.tab-item.active { color: var(--text); }
.tab-item small {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 4px;
}
.tab-sep {
  color: var(--border);
  font-size: 0.9rem;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Footer ─── */
.footer {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

/* ─── Responsive ─── */
@media (max-width: 640px) {
  .nav-container { height: auto; padding: 12px 16px; flex-direction: column; gap: 10px; }
  .nav-links { flex-wrap: wrap; justify-content: center; }
  .detail-meta { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
}
