/* ======================================== */
/* CSS RESET                               */
/* ======================================== */

/* Full reset to neutralize browser default styles for dashboard pages */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font: inherit;
  font-size: 100%;
  vertical-align: baseline;
}

article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
  display: block;
}

body {
  line-height: 1;
  min-height: 100vh;
  background: transparent;
}

ol, ul {
  list-style: none;
}

blockquote, q {
  quotes: none;
}

blockquote:before, blockquote:after,
q:before, q:after {
  content: '';
  content: none;
}

table {
  border-collapse: collapse;
  border-spacing: 0;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

/* ======================================== */
/* GLOBAL THEME VARIABLES & BASE STYLING    */
/* ======================================== */

/* ======================================== */
/* LIGHT MODE (Default)                     */
/* ======================================== */

:root {
  /* Background Colors */
  --bg: #f8fafc;
  --surface: #ffffff;
  --card-bg: #ffffff;
  
  /* Text Colors */
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  /* Border Colors */
  --border: #e2e8f0;
  --border-light: #f1f5f9;
  --border-dark: #cbd5e1;
  
  /* Input Colors */
  --input-bg: #ffffff;
  --input-border: #cbd5e1;
  --placeholder: #94a3b8;
  
  /* Primary Colors */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-dark: #1e40af;
  --primary-light: #60a5fa;
  --primary-bg: rgba(37, 99, 235, 0.1);
  
  /* Status Colors */
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.1);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.1);
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
  --shadow-soft: 0 6px 18px rgba(15, 23, 42, 0.08);
  --shadow-strong: 0 10px 30px rgba(15, 23, 42, 0.12);
  
  /* Border Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition: 0.25s ease;
  --transition-slow: 0.35s ease;
  
  /* Discord Button Colors */
  --btn-color-primary: #5865f2;
  --btn-color-secondary: #4752c4;
  --btn-color-hover: #6a77ff;
  --btn-gradient: linear-gradient(135deg, #5865f2 0%, #4752c4 100%);
  --btn-gradient-hover: linear-gradient(135deg, #6a77ff 0%, #5a2ba8 100%);
  --btn-shadow: rgba(88, 101, 242, 0.25);
  --btn-shadow-hover: rgba(88, 101, 242, 0.35);
  --btn-border-color: rgba(88, 101, 242, 0.4);
  --btn-focus-ring: rgba(88, 101, 242, 0.4);
  --bg-page: var(--bg);
  --bg-body: var(--bg);
  --bg-surface: var(--surface);
  --bg-hover: rgba(15, 23, 42, 0.03);
  --text-primary: var(--text);
  --text-light: var(--text-muted);
  --focus-ring: rgba(37, 99, 235, 0.18);
  --shadow-brand: 0 8px 32px rgba(37, 99, 235, 0.15);
}

/* ======================================== */
/* DARK MODE                                */
/* ======================================== */

[data-theme="dark"] {
  /* Background Colors */
  --bg: #121722;
  --surface: #1a2130;
  --card-bg: #1b2233;
  
  /* Text Colors */
  --text: #f3f6fb;
  --text-secondary: #b8c1d1;
  --text-muted: #8d97a8;
  
  /* Border Colors */
  --border: #2e3547;
  --border-light: #232938;
  --border-dark: #3b4559;
  
  /* Input Colors */
  --input-bg: #171d2a;
  --input-border: #374253;
  --placeholder: #6e778a;
  
  /* Primary Colors */
  --primary: #5b8cff;
  --primary-hover: #4a7cf6;
  --primary-dark: #3d6fe1;
  --primary-light: #8bb0ff;
  --primary-bg: rgba(91, 140, 255, 0.16);
  
  /* Status Colors */
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.15);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.15);
  --info: #3b82f6;
  --info-bg: rgba(59, 130, 246, 0.15);
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.28);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.35), 0 2px 4px -2px rgb(0 0 0 / 0.35);
  --shadow-md: 0 10px 15px -3px rgb(0 0 0 / 0.35), 0 4px 6px -4px rgb(0 0 0 / 0.35);
  --shadow-lg: 0 20px 25px -5px rgb(0 0 0 / 0.4), 0 8px 10px -6px rgb(0 0 0 / 0.4);
  --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.25);
  --shadow-strong: 0 10px 30px rgba(0, 0, 0, 0.3);
  
  /* Discord Button Colors - Dark Mode */
  --btn-color-primary: #5b8cff;
  --btn-color-secondary: #2f3b51;
  --btn-color-hover: #7aa3ff;
  --btn-gradient: linear-gradient(135deg, #5b8cff 0%, #3d6fe1 100%);
  --btn-gradient-hover: linear-gradient(135deg, #7aa3ff 0%, #4a7cf6 100%);
  --btn-shadow: rgba(91, 140, 255, 0.22);
  --btn-shadow-hover: rgba(91, 140, 255, 0.28);
  --btn-border-color: rgba(91, 140, 255, 0.35);
  --btn-focus-ring: rgba(91, 140, 255, 0.25);
  --bg-page: var(--bg);
  --bg-body: var(--bg);
  --bg-surface: var(--surface);
  --bg-hover: #232a3a;
  --text-primary: var(--text);
  --text-light: #8d97a8;
  --focus-ring: rgba(91, 140, 255, 0.2);
  --shadow-brand: 0 8px 32px rgba(91, 140, 255, 0.16);
}

/* ======================================== */
/* GLOBAL RESET & BASE STYLES               */
/* ======================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  font-family: 'Inter', 'Segoe UI', 'Noto Kufi Arabic', 'Tajawal', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background-color var(--transition), color var(--transition);
  line-height: 1.6;
}

body, body * {
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

main {
  background: transparent;
  padding-block: 0.25rem;
}

.container,
.container-fluid {
  max-width: 100%;
  padding-inline: 1.1rem;
}

.row {
  --bs-gutter-x: 1.25rem;
  --bs-gutter-y: 1.25rem;
}

.row > [class*="col-"],
.row > [class*="col"] {
  padding-top: calc(var(--bs-gutter-y) / 2);
  padding-bottom: calc(var(--bs-gutter-y) / 2);
}

.card,
.section-card,
.settings-section,
.guild-header,
.panel-details-card .card,
.publish-panel-card,
.modal-content {
  margin-bottom: 1.25rem;
}

.card-body > * + *,
.settings-section > * + *,
.section-card > * + *,
.form-group > * + *,
.form-row > * + *,
.accordion-body > * + *,
.list-group > * + * {
  margin-top: 0.9rem;
}

.d-flex:not(.flex-column) > * + * {
  margin-inline-start: 0.75rem;
}

.d-flex.flex-column > * + * {
  margin-top: 0.75rem;
}

.btn + .btn,
.form-control + .form-control,
.form-select + .form-select,
.form-check + .form-check {
  margin-inline-start: 0.75rem;
}

.page-header + .row,
.page-header + .section-card,
.section-heading + .section-card,
.section-heading + .settings-section {
  margin-top: 1rem;
}

.section-heading + .section-heading {
  margin-top: 1.5rem;
}

@media (max-width: 768px) {
  .container,
  .container-fluid {
    padding-inline: 0.9rem;
  }

  .row {
    --bs-gutter-x: 0.9rem;
    --bs-gutter-y: 0.9rem;
  }
}

.card,
.table,
.form-control,
.form-select,
.btn,
.alert,
.badge,
.list-group-item,
.nav-tabs .nav-link {
  transition: background-color var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast);
}

::selection {
  background: var(--primary-bg);
  color: var(--primary);
}

::-moz-selection {
  background: var(--primary-bg);
  color: var(--primary);
}

::placeholder {
  color: var(--placeholder);
  opacity: 1;
}

.form-control,
.form-select,
.form-check-input,
textarea,
input,
select {
  background-color: var(--input-bg);
  color: var(--text);
  border-color: var(--input-border);
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  background-color: var(--input-bg);
  color: var(--text);
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem var(--focus-ring);
}

.table {
  color: var(--text);
}

.table thead th {
  color: var(--text-secondary);
  border-color: var(--border);
}

.table td,
.table th {
  border-color: var(--border);
}

.badge,
.alert,
.btn {
  border-radius: 999px;
}

.badge.bg-primary {
  background-color: var(--primary) !important;
  color: #ffffff !important;
}

.badge.bg-secondary {
  background-color: var(--surface) !important;
  color: var(--text) !important;
  border: 1px solid var(--border);
}

/* ======================================== */
/* LINKS                                    */
/* ======================================== */

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--primary-hover);
}

/* ======================================== */
/* TEXT UTILITIES                           */
/* ======================================== */

.text-muted {
  color: var(--text-muted) !important;
}

.text-primary {
  color: var(--primary) !important;
}

.text-success {
  color: var(--success) !important;
}

.text-danger {
  color: var(--danger) !important;
}

.text-warning {
  color: var(--warning) !important;
}

.text-secondary {
  color: var(--text-secondary) !important;
}

/* ======================================== */
/* BACKGROUND UTILITIES                     */
/* ======================================== */

.bg-primary {
  background-color: var(--primary) !important;
}

.bg-success {
  background-color: var(--success) !important;
}

.bg-danger {
  background-color: var(--danger) !important;
}

.bg-warning {
  background-color: var(--warning) !important;
}

.bg-light {
  background: var(--surface) !important;
}

[data-theme="dark"] .bg-light {
  background: var(--surface) !important;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text) !important;
}

.table-light,
.table-light > th,
.table-light > td,
.table-light > tr {
  background-color: var(--surface) !important;
  color: var(--text) !important;
}

/* ======================================== */
/* CARDS                                    */
/* ======================================== */

.card {
  background: var(--card-bg) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  overflow: hidden;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.card-header {
  background: var(--surface) !important;
  border-bottom: 1px solid var(--border) !important;
}

.card-footer {
  background: var(--surface) !important;
  border-top: 1px solid var(--border) !important;
}

/* ======================================== */
/* BUTTONS                                  */
/* ======================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.2rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 999px;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
  letter-spacing: 0.01em;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

[data-theme="dark"] .btn-primary {
  background: #ffffff;
  color: #000000;
}

[data-theme="dark"] .btn-primary:hover {
  background: #e2e8f0;
}

.btn-secondary {
  background: var(--text-muted);
  color: white;
}

.btn-secondary:hover {
  background: var(--text-secondary);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--success);
  color: white;
}

.btn-success:hover {
  background: #16a34a;
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-danger:hover {
  background: #dc2626;
  transform: translateY(-1px);
}

.btn-outline-primary {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
}

.btn-outline-primary:hover {
  background: var(--primary);
  color: white;
}

.btn-outline-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline-secondary:hover {
  background: var(--border);
  border-color: var(--primary);
  color: var(--primary);
}

[data-theme="dark"] .btn-outline-secondary:hover {
  background: var(--border);
}

/* ======================================== */
/* FORM CONTROLS                            */
/* ======================================== */

.form-control,
.form-select {
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 0.625rem 0.875rem;
  transition: all var(--transition-fast);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-bg);
  outline: none;
}

.form-control::placeholder {
  color: var(--placeholder);
}

.form-label {
  color: var(--text-secondary);
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

/* ======================================== */
/* CHECKBOX & RADIO                         */
/* ======================================== */

.form-check-input {
  -webkit-appearance: none;
  appearance: none;
  width: 1.125rem;
  height: 1.125rem;
  margin-top: 0.125rem;
  background-color: var(--input-bg);
  border: 2px solid var(--border);
  border-radius: 0.25rem;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.form-check-input:checked {
  background-color: var(--primary);
  border-color: var(--primary);
  position: relative;
}

.form-check-input:checked::after {
  content: "✓";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 0.7rem;
  font-weight: bold;
}

[data-theme="dark"] .form-check-input:checked::after {
  color: #000000;
}

.form-check-input:focus {
  box-shadow: 0 0 0 3px var(--primary-bg);
  outline: none;
}

/* Toggle Switch */
.form-switch .form-check-input {
  width: 2.5rem;
  height: 1.25rem;
  border-radius: 2rem;
  background-color: var(--border);
  border: none;
}

.form-switch .form-check-input:checked {
  background-color: var(--primary);
}

.form-switch .form-check-input::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(1.25rem - 6px);
  height: calc(1.25rem - 6px);
  background-color: white;
  border-radius: 50%;
  transition: transform var(--transition-fast);
}

.form-switch .form-check-input:checked::before {
  transform: translateX(1.25rem);
}

[data-theme="dark"] .form-switch .form-check-input::before {
  background-color: #888888;
}

[data-theme="dark"] .form-switch .form-check-input:checked::before {
  background-color: #000000;
}

/* ======================================== */
/* TABLES                                   */
/* ======================================== */

.table {
  color: var(--text);
  border-color: var(--border);
}

.table thead th {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  color: var(--text-secondary);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
}

.table tbody tr:hover {
  background: var(--primary-bg);
}

.table tbody tr {
  transition: background-color var(--transition-fast);
}

.table td,
.table th {
  border-color: var(--border);
}

/* ======================================== */
/* MODALS                                   */
/* ======================================== */

.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.modal-header {
  border-bottom: 1px solid var(--border);
}

.modal-footer {
  border-top: 1px solid var(--border);
}

.modal-title {
  color: var(--text);
  font-weight: 600;
}

/* ======================================== */
/* DROPDOWNS                                */
/* ======================================== */

.dropdown-menu {
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.dropdown-item {
  color: var(--text);
}

.dropdown-item:hover {
  background: var(--border);
  color: var(--text);
}

.dropdown-divider {
  border-top-color: var(--border);
}

/* ======================================== */
/* ALERTS                                   */
/* ======================================== */

.alert {
  border-radius: var(--radius-md);
  border: none;
}

.alert-success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.alert-danger {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-warning {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-info {
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

/* ======================================== */
/* BADGES                                   */
/* ======================================== */

.badge {
  padding: 0.35rem 0.75rem;
  font-weight: 500;
  border-radius: 2rem;
}

/* ======================================== */
/* NAVIGATION TABS                          */
/* ======================================== */

.nav-tabs {
  border-bottom: 2px solid var(--border);
}

.nav-tabs .nav-link {
  color: var(--text-secondary);
  border: none;
  padding: 0.75rem 1.25rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}

.nav-tabs .nav-link:hover {
  color: var(--primary);
  background: var(--border);
}

.nav-tabs .nav-link.active {
  color: var(--primary);
  background: transparent;
  border-bottom: 2px solid var(--primary);
}

/* ======================================== */
/* SCROLLBAR                                */
/* ======================================== */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--border);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--text-muted);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ======================================== */
/* UTILITY CLASSES                          */
/* ======================================== */

.d-none { display: none !important; }
.d-block { display: block !important; }
.d-flex { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }

.w-100 { width: 100% !important; }
.h-100 { height: 100% !important; }

.text-center { text-align: center !important; }
.text-start { text-align: left !important; }
.text-end { text-align: right !important; }

[dir="rtl"] .text-start { text-align: right !important; }
[dir="rtl"] .text-end { text-align: left !important; }

.rounded { border-radius: var(--radius-md) !important; }
.rounded-lg { border-radius: var(--radius-lg) !important; }
.rounded-circle { border-radius: 50% !important; }

.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow { box-shadow: var(--shadow) !important; }
.shadow-md { box-shadow: var(--shadow-md) !important; }
.shadow-lg { box-shadow: var(--shadow-lg) !important; }

/* ======================================== */
/* RESPONSIVE                               */
/* ======================================== */

@media (max-width: 768px) {
  :root {
    --radius-lg: 12px;
    --radius-md: 8px;
  }
  
  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.8125rem;
  }
  
  .card-body {
    padding: 1rem;
  }
}

@media (max-width: 576px) {
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
}