/* =========================================================
   ROLE ICONS (EMOJI — WORKING, NO DEPENDENCIES)
   ========================================================= */

.role-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  min-width: 18px;
  font-size: 16px;
  line-height: 1;
}

/* Emoji role icons */
.role-icon.leader::before { content: "👑"; }
.role-icon.vice::before   { content: "🛡️"; }
.role-icon.member::before { content: "⚔️"; }

/* ================= ROOT ================= */

:root {
  --bg-main: linear-gradient(180deg, #020617, #0b1120, #1a2d4a);
  --bg-header: rgba(15, 23, 42, 0.95);
  --bg-acrylic: rgba(20, 26, 38, 0.92);

  --border-soft: rgba(212,168,87,.25);
  --border-subtle: rgba(255,255,255,.08);

  --text-main: #f0f2f6;
  --text-muted: rgba(240, 242, 246, 0.7);

  --accent-gold: #d4a857;
  --danger-red: #d46a6a;

  --radius: 14px;
  --radius-sm: 10px;
}

/* ================= THEMES ================= */

html.theme-blue {
  --bg-main: linear-gradient(180deg, #020617, #0b1120, #1a2d4a);
  --bg-header: rgba(15, 23, 42, 0.95);
  --bg-acrylic: rgba(20, 26, 38, 0.92);
}

html.theme-black {
  --bg-main: linear-gradient(180deg, #0e1116, #12161d, #161c26);
  --bg-header: rgba(18, 22, 30, 0.96);
  --bg-acrylic: rgba(26, 30, 38, 0.96);
}

/* ================= BASE ================= */

[hidden] { display: none !important; }

html {
  font-size: 16px;
}

/* ================= CHROME ANDROID FIXED BACKGROUND ================= */

html::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--bg-main);
  z-index: -1;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: transparent;
  color: var(--text-main);
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  line-height: 1.55;
  letter-spacing: 0.01em;
  overflow-x: hidden;
}

/* ================= iOS SCROLL BACKGROUND FIX ================= */

html {
  height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
}

/* ================= HEADER ================= */

.app-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--bg-header);
  backdrop-filter: blur(18px);
}

.app-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent,
    var(--border-soft),
    transparent
  );
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 24px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.brand-group {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 14px;
}

.header-sword {
  width: 48px;
  filter: drop-shadow(0 0 10px rgba(212,168,87,.45));
}

.app-name {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.6px;
}

.app-subtitle {
  font-size: 11px;
  letter-spacing: 2.8px;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ================= NAV ================= */

.app-nav {
  grid-column: 1 / -1;
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.app-nav button {
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.08);
  border: 1px solid var(--border-soft);
  color: var(--text-main);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.app-nav button.active {
  background: rgba(212,168,87,.25);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

/* ================= LAYOUT ================= */

.main-wrapper {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 64px;
  min-height: calc(100vh - 120px);
}

/* =========================================================
   SECTION HEADER — CENTER SEARCH + BUTTON UNDER TITLE
   ========================================================= */

.section-header {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.section-header input[type="text"] {
  width: 118px;
  height: 32px;
  padding: 6px 14px;
  text-align: center;
  box-sizing: border-box;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.10);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
}

.section-header .btn {
  height: 32px;
}

/* ================= PANELS ================= */

.acrylic-panel {
  background: var(--bg-acrylic);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow:
    0 10px 30px rgba(0,0,0,.45),
    inset 0 0 0 1px var(--border-subtle);
}

/* ================= DASHBOARD ================= */

#dashboard .acrylic-panel {
  min-height: 200px;
}

/* ================= MEMBERS ================= */

#members {
  --member-rhythm: 12px;
}

#members .member-row {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(var(--member-rhythm) * 1.5) 0;
  gap: 18px;
  transition: background 0.15s ease;
}

#members .member-row:hover {
  background: rgba(255,255,255,0.03);
}

#members .member-row + .member-row {
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--member-rhythm);
}

#members .member-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  flex: 1 1 auto;
  min-width: 0;
}

#members .member-name {
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.015em;
  line-height: 1.35;
}

#members .member-role {
  margin-top: var(--member-rhythm);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  align-items: center;
  column-gap: 10px;
  max-width: max-content;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ================= ROLE BADGES ================= */

.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  font-weight: 600;
  letter-spacing: 0.04em;
  box-shadow:
    inset 0 0 0 1px rgba(255,255,255,0.08),
    0 1px 4px rgba(0,0,0,0.35);
}

/* Leader */
.role-badge:has(.role-icon.leader) {
  background: rgba(212,168,87,.18);
  border: 1px solid rgba(212,168,87,.45);
  color: var(--accent-gold);
  box-shadow: 0 0 8px rgba(212,168,87,.35);
}

/* Vice Leader */
.role-badge:has(.role-icon.vice) {
  background: rgba(160,180,200,.14);
  border: 1px solid rgba(160,180,200,.35);
  color: #cfd9e3;
}

/* Member */
.role-badge:has(.role-icon.member) {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.18);
  color: var(--text-muted);
}

/* ================= JOINED DATE (LORE) ================= */

#members .member-joined {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  opacity: 0.55;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.2s ease;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

#members .member-row:hover .member-joined {
  opacity: 0.85;
}

/* ================= ACTIVITY DOT ================= */

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(0,0,0,.25);
}

/* ================= BUTTONS ================= */

.btn {
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.10);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

#members .member-actions {
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

#members .member-row:hover .member-actions {
  opacity: 1;
}

.btn-primary {
  background: rgba(212,168,87,.30);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.btn-danger {
  background: rgba(212,106,106,.30);
  border-color: var(--danger-red);
  color: var(--danger-red);
}

/* ================= MODAL ================= */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.modal {
  background: var(--bg-acrylic);
  padding: 24px;
  padding-bottom: 32px;
  border-radius: var(--radius);
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 18px;
  text-align: center;
  font-size: 14px;
}

/* ⭐ NEW: Gold member name */
.modal-member-name {
  color: var(--accent-gold);
  font-weight: 700;
}

/* ⭐ NEW: Mode text (Editing / Remove / Add Member) */
.modal-mode-text {
  font-weight: 600;
}

/* ================= MODAL FIELD POLISH ================= */

.modal .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.modal .field:first-of-type {
  margin-top: -6px;
}

.modal .field + .field {
  margin-top: 10px;
}

.modal .field label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

.modal-member-name {
  color: var(--accent-gold);
  font-weight: 700;
}

/* ================= MODAL INPUT HARMONIZATION ================= */

.modal input[type="text"] {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  color: var(--text-main);
  font-size: 14px;
  text-align: center;
}

.modal input[type="text"]::placeholder {
  color: var(--text-muted);
}

.modal input[type="text"]:focus {
  outline: none;
  border-color: var(--accent-gold);
}

/* ================= CUSTOM SELECT ================= */

.custom-select {
  position: relative;
  cursor: pointer;
  margin-top: 6px;
}

.custom-select-value {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  font-size: 14px;
}

.custom-select.open .custom-select-value {
  border-color: var(--accent-gold);
}

.custom-select-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--bg-acrylic);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.15);
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  z-index: 50;
}

.custom-select-item {
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
}

.custom-select-item:hover {
  background: rgba(212,168,87,.15);
}

/* ================= ROLE ERROR ================= */

.role-error {
  color: var(--danger-red);
  font-size: 13px;
  margin-top: -6px;
  margin-bottom: 6px;
}

/* ================= MODAL ACTIONS SPACING ================= */

.modal-actions {
  margin-top: 12px;
}

/* ================= THEME TOGGLE ================= */

.theme-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-acrylic);
  border: 1px solid var(--border-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2000;
}

#themeIcon {
  font-size: 18px;
}

/* ================= DRAG HANDLE (REORDER) ================= */

#members .drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 6px;
  margin-right: 6px;
  font-size: 14px;
  line-height: 1;
  cursor: grab;
  user-select: none;
  opacity: 0.55;
  transition:
    opacity 0.15s ease,
    transform 0.12s ease;
}

#members .member-row:hover .drag-handle {
  opacity: 0.9;
}

#members .drag-handle:active {
  cursor: grabbing;
  transform: scale(1.05);
}

/* ================= REORDER ANIMATION ================= */

#members .member-row {
  transition:
    background 0.15s ease,
    transform 0.12s ease,
    box-shadow 0.12s ease;
}

#members .member-row.reordering {
  box-shadow:
    0 8px 22px rgba(0,0,0,.35),
    inset 0 0 0 1px rgba(212,168,87,.25);
  transform: scale(1.01);
  z-index: 2;
}
