/* ═══════════════════════════════════════════════════════════════
   MDOJ Modmail Panel - Styles
   Deep navy  ·  Court Gold  ·  Shield Purple  ·  Glassmorphism
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* ── Backgrounds ── */
  --bg-page:      #060711;
  --bg-dark:      #060711;
  --bg-card:      #0c0e1a;
  --bg-secondary: #101320;
  --bg-elevated:  #161a2a;
  --bg-input:     #0a0c16;
  --bg-hover:     rgba(124, 92, 191, 0.07);
  --bg-tertiary:  #0d0f19;

  /* ── Gold ── */
  --gold:            #c9a84c;
  --gold-light:      #e2c06e;
  --gold-dim:        rgba(201, 168, 76, 0.10);
  --gold-border:     rgba(201, 168, 76, 0.22);
  --gold-border-hv:  rgba(201, 168, 76, 0.50);
  --accent-gold:     #c9a84c;
  --accent-gold-light: #e2c06e;
  --accent-gold-dim:   rgba(201,168,76,.10);

  /* ── Purple ── */
  --purple:        #7c5cbf;
  --purple-light:  #a07ee0;
  --purple-dim:    rgba(124, 92, 191, 0.10);
  --purple-border: rgba(124, 92, 191, 0.22);
  --purple-glow:   rgba(124, 92, 191, 0.14);

  /* ── Mixed accent gradient ── */
  --gradient-brand: linear-gradient(135deg, var(--purple) 0%, var(--gold) 100%);
  --gradient-brand-light: linear-gradient(135deg, var(--purple-light) 0%, var(--gold-light) 100%);

  /* ── Semantic ── */
  --primary:       #5865f2;
  --primary-dark:  #4752c4;
  --secondary:     #57f287;
  --danger:        #ed4245;
  --warning:       #faa61a;

  /* ── Text ── */
  --text-primary:   #e8eaf0;
  --text-secondary: #7e87a0;
  --text-muted:     #4b526a;

  /* ── Borders ── */
  --border:       rgba(124, 92, 191, 0.10);
  --border-color: rgba(124, 92, 191, 0.10);
  --border-gold:  rgba(201, 168, 76, 0.22);

  /* ── Glass ── */
  --glass-bg:     rgba(12, 14, 26, 0.70);
  --glass-border: rgba(124, 92, 191, 0.12);
  --glass-blur:   16px;

  /* ── Radius ── */
  --radius-sm:  8px;
  --radius-md:  12px;
  --radius-lg:  16px;
  --radius-xl:  20px;
}

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Body ── */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-page);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.55;
  background-image:
    radial-gradient(ellipse 1000px 500px at 50% -100px, rgba(124, 92, 191, 0.12) 0%, transparent 60%),
    radial-gradient(ellipse 800px 400px at 0% 50%, rgba(124, 92, 191, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse 600px 300px at 100% 80%, rgba(201, 168, 76, 0.04) 0%, transparent 50%);
  background-attachment: fixed;
}

/* ════════════════════════════════════════
   NAVBAR
════════════════════════════════════════ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 999;
  background: rgba(6, 7, 17, 0.88);
  border-bottom: 1px solid var(--glass-border);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  box-shadow:
    0 1px 0 rgba(201, 168, 76, 0.08),
    0 4px 30px rgba(0, 0, 0, 0.5);
}
.nav-container {
  max-width: 1400px;
  margin: 0 auto;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  gap: 12px;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.nav-brand-text {
  font-weight: 800;
  font-size: .95rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  background: var(--gradient-brand-light);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.nav-links {
  display: flex;
  gap: 2px;
  flex: 1;
  margin-left: 12px;
}
.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  padding: 7px 15px;
  font-size: .84rem;
  font-weight: 500;
  letter-spacing: .02em;
  transition: all .18s ease;
  position: relative;
  white-space: nowrap;
}
.nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}
.nav-link.active {
  color: var(--purple-light);
  background: var(--purple-dim);
  font-weight: 600;
}
.nav-link.active::after {
  content: "";
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 22px; height: 2px;
  background: var(--gradient-brand);
  border-radius: 2px 2px 0 0;
}

/* ── User Menu ── */
.user-menu { position: relative; flex-shrink: 0; }
.user-menu-button {
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  color: var(--text-primary);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-size: .86rem;
  font-weight: 500;
  transition: all .18s;
  font-family: inherit;
}
.user-menu-button:hover {
  border-color: var(--purple-border);
  background: var(--bg-elevated);
  box-shadow: 0 0 16px rgba(124, 92, 191, 0.08);
}
.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 200px;
  background: var(--bg-elevated);
  border: 1px solid var(--purple-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.6), 0 0 24px rgba(124, 92, 191, 0.06);
}
.user-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text-primary);
  padding: 11px 16px;
  text-decoration: none;
  cursor: pointer;
  font-size: .86rem;
  font-family: inherit;
  transition: background .12s;
}
.user-menu-item:hover { background: var(--bg-hover); }
.user-menu-item-danger { color: #ff9ea1; }

/* ════════════════════════════════════════
   LAYOUT
════════════════════════════════════════ */
.main-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 28px 28px 48px;
}

.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.page-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: .02em;
  background: var(--gradient-brand-light);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.subtitle { color: var(--text-secondary); font-size: .86rem; margin-top: 4px; }

/* ════════════════════════════════════════
   DASHBOARD STATS
════════════════════════════════════════ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 16px;
}
.stat-card {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  transition: border-color .2s, transform .2s, box-shadow .2s;
}
.stat-card:hover {
  border-color: var(--purple-border);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(124, 92, 191, 0.08);
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 3px;
  background: var(--gradient-brand);
}
.stat-card h3 {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.stat-card p {
  font-size: 1.7rem;
  font-weight: 800;
  background: var(--gradient-brand-light);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ════════════════════════════════════════
   TOOL LAYOUT (sidebar + content)
════════════════════════════════════════ */
.command-tools-card {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}
.admin-tools-layout {
  display: grid;
  grid-template-columns: 230px 1fr;
  min-height: 480px;
}
.admin-tools-sidebar {
  border-right: 1px solid var(--border);
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
  max-height: calc(100vh - 130px);
  background: rgba(0, 0, 0, 0.2);
}
.admin-tools-nav-item {
  border: none;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: transparent;
  color: var(--text-secondary);
  text-align: left;
  padding: 10px 14px;
  cursor: pointer;
  font-size: .85rem;
  font-family: inherit;
  font-weight: 500;
  transition: all .16s;
  width: 100%;
}
.admin-tools-nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.admin-tools-nav-item.active {
  border-left-color: var(--purple);
  color: var(--purple-light);
  background: var(--purple-dim);
  font-weight: 600;
}
.admin-tools-content { padding: 22px; }

/* ════════════════════════════════════════
   TOOL CARDS
════════════════════════════════════════ */
.tool-card {
  background: rgba(16, 19, 32, 0.6);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 18px;
  transition: border-color .2s;
}
.tool-card:hover { border-color: var(--purple-border); }
.tool-title {
  font-size: .72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--purple-light);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--purple-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ════════════════════════════════════════
   FORM ELEMENTS
════════════════════════════════════════ */
label {
  display: block;
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .05em;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
}
input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-primary);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: .88rem;
  transition: border-color .18s, box-shadow .18s;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--purple);
  box-shadow: 0 0 0 3px var(--purple-dim), 0 0 16px rgba(124, 92, 191, 0.06);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
textarea { min-height: 70px; resize: vertical; }
select option { background: var(--bg-elevated); }

.config-field { margin-bottom: 16px; }
.config-actions { margin-top: 18px; display: flex; gap: 8px; }
.config-save-status {
  font-size: .78rem;
  margin-left: 8px;
  vertical-align: middle;
}
.config-save-status.success { color: var(--secondary); }
.config-save-status.error { color: #ff9ea1; }

/* ════════════════════════════════════════
   BUTTONS
════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  font-weight: 600;
  font-size: .84rem;
  letter-spacing: .03em;
  transition: all .18s ease;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
}
button.btn, a.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 18px;
  color: #fff;
  background: var(--purple);
  box-shadow: 0 2px 8px rgba(124, 92, 191, 0.2);
}
button.btn:hover, a.btn:hover {
  background: var(--purple-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(124, 92, 191, 0.25);
}
button.btn:active, a.btn:active { transform: translateY(0); box-shadow: none; }

/* Gold accent */
button.btn.accent, a.btn.accent {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
  color: #0a0b0f;
  font-weight: 700;
  box-shadow: 0 2px 12px rgba(201, 168, 76, 0.25);
}
button.btn.accent:hover, a.btn.accent:hover {
  filter: brightness(1.12);
  box-shadow: 0 4px 20px rgba(201, 168, 76, 0.3);
}

/* Secondary (ghost-ish) */
button.btn.secondary, a.btn.secondary {
  background: rgba(124, 92, 191, 0.08);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  box-shadow: none;
}
button.btn.secondary:hover, a.btn.secondary:hover {
  border-color: var(--purple-border);
  color: var(--purple-light);
  background: var(--purple-dim);
  transform: none;
}

/* Danger */
button.btn.danger, a.btn.danger {
  background: rgba(237, 66, 69, 0.12);
  color: #ff9ea1;
  border: 1px solid rgba(237, 66, 69, 0.2);
  box-shadow: none;
}
button.btn.danger:hover, a.btn.danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  box-shadow: 0 4px 16px rgba(237, 66, 69, 0.25);
}

/* Ghost */
.btn.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  box-shadow: none;
}
.btn.btn-ghost:hover {
  background: var(--purple-dim);
  border-color: var(--purple-border);
  color: var(--purple-light);
}

/* ════════════════════════════════════════
   TABLES
════════════════════════════════════════ */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(10, 12, 22, 0.4);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .86rem;
}
thead { position: sticky; top: 0; z-index: 1; }
th {
  color: var(--purple-light);
  background: rgba(16, 19, 32, 0.9);
  backdrop-filter: blur(8px);
  font-size: .70rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 12px 14px;
  border-bottom: 1px solid var(--purple-border);
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(124, 92, 191, 0.06);
  color: var(--text-primary);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(124, 92, 191, 0.04); }

/* ════════════════════════════════════════
   MISC UTILITY
════════════════════════════════════════ */
.muted { color: var(--text-secondary); font-size: .86rem; }
.message { margin-top: 8px; font-size: .86rem; min-height: 1.2em; }
.success { color: var(--secondary); }
.error { color: #ff9ea1; }
.inline-row { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 8px; }
.inline-row > * { flex: 1; min-width: 120px; }
.inline-row > .btn { flex: 0 0 auto; margin-bottom: 0; }

/* ════════════════════════════════════════
   CHIPS
════════════════════════════════════════ */
.chip-list { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  border-radius: 16px;
  background: var(--purple-dim);
  color: var(--purple-light);
  font-size: .76rem;
  font-weight: 600;
  border: 1px solid var(--purple-border);
  letter-spacing: .03em;
}
.chip .chip-x { cursor: pointer; opacity: .7; font-size: .9rem; }
.chip .chip-x:hover { opacity: 1; }

/* ════════════════════════════════════════
   EMPTY STATES
════════════════════════════════════════ */
.empty-state {
  text-align: center;
  padding: 56px 24px;
}
.empty-state-icon {
  font-size: 3.2rem;
  margin-bottom: 14px;
  opacity: .35;
  display: block;
}
.empty-state-title, .empty-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--purple-light);
  letter-spacing: .03em;
  margin-bottom: 6px;
}
.empty-state-desc, .empty-desc {
  font-size: .86rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

/* ════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════ */
.nav-hamburger {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 5px 9px;
  border-radius: var(--radius-sm);
  font-family: inherit;
}
.nav-hamburger:hover { border-color: var(--purple-border); background: var(--bg-hover); }

@media (max-width: 920px) {
  .nav-hamburger { display: block; }
  .nav-links {
    display: none;
    position: absolute;
    top: 60px; left: 0; right: 0;
    background: rgba(12, 14, 26, 0.97);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--purple-border);
    flex-direction: column;
    padding: 10px 14px 14px;
    gap: 2px;
    z-index: 998;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
  }
  .nav-links.open { display: flex; }
  .admin-tools-layout { grid-template-columns: 1fr; min-height: auto; }
  .admin-tools-sidebar {
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    max-height: none;
    padding: 8px;
  }
  .admin-tools-nav-item {
    border-left: none;
    border-bottom: 2px solid transparent;
    border-radius: var(--radius-sm);
    white-space: nowrap;
  }
  .admin-tools-nav-item.active {
    border-left: none;
    border-bottom-color: var(--purple);
  }
  .page-header { flex-direction: column; align-items: flex-start; }
  .stats-grid { grid-template-columns: 1fr; }
}

/* ════════════════════════════════════════
   USER SELECT
════════════════════════════════════════ */
.nav-brand-text, .nav-hamburger, .tool-nav-item, .admin-tools-nav-item,
.user-menu-button, .page-header .btn {
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

/* ════════════════════════════════════════
   SCROLLBAR
════════════════════════════════════════ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(124, 92, 191, 0.2);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(124, 92, 191, 0.35); }
