@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Vazirmatn:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ==========================================================================
   CSS Variables & Design Tokens (Dark & Light Dual Modes)
   ========================================================================== */

:root, [data-theme="dark"] {
  --theme-mode: 'dark';

  /* Backgrounds */
  --bg-deep: #080c14;
  --bg-sidebar: #0d1322;
  --bg-header: rgba(8, 12, 20, 0.85);
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(22, 33, 60, 0.85);
  --bg-input: rgba(10, 15, 26, 0.85);
  --bg-code: #050810;
  --bg-table-header: rgba(255, 255, 255, 0.02);
  --bg-table-hover: rgba(255, 255, 255, 0.03);

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(99, 102, 241, 0.3);
  --border-input: rgba(255, 255, 255, 0.12);

  /* Accents & Brand */
  --primary: #6366f1;
  --primary-glow: rgba(99, 102, 241, 0.4);
  --cyan: #06b6d4;
  --cyan-glow: rgba(6, 182, 212, 0.35);
  --emerald: #10b981;
  --emerald-glow: rgba(16, 185, 129, 0.35);
  --amber: #f59e0b;
  --rose: #f43f5e;

  /* Typography Colors */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --text-inverse: #0f172a;

  /* Shadows */
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --shadow-panel: 0 20px 40px -15px rgba(0, 0, 0, 0.7);

  /* Gradients */
  --mesh-gradient: 
    radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 85% 30%, rgba(6, 182, 212, 0.10) 0%, transparent 40%),
    radial-gradient(circle at 50% 85%, rgba(16, 185, 129, 0.08) 0%, transparent 45%);
}

[data-theme="light"] {
  --theme-mode: 'light';

  /* Backgrounds */
  --bg-deep: #f8fafc;
  --bg-sidebar: #ffffff;
  --bg-header: rgba(255, 255, 255, 0.88);
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f8fafc;
  --bg-code: #0f172a;
  --bg-table-header: #f8fafc;
  --bg-table-hover: #f1f5f9;

  /* Borders */
  --border-subtle: #e2e8f0;
  --border-glow: rgba(99, 102, 241, 0.2);
  --border-input: #cbd5e1;

  /* Accents & Brand */
  --primary: #4f46e5;
  --primary-glow: rgba(79, 70, 229, 0.2);
  --cyan: #0891b2;
  --cyan-glow: rgba(8, 145, 178, 0.2);
  --emerald: #059669;
  --emerald-glow: rgba(5, 150, 105, 0.2);
  --amber: #d97706;
  --rose: #e11d48;

  /* Typography Colors */
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --text-inverse: #ffffff;

  /* Shadows */
  --shadow-card: 0 4px 20px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.03);
  --shadow-panel: 0 10px 30px -5px rgba(15, 23, 42, 0.08);

  /* Gradients */
  --mesh-gradient: 
    radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 85% 30%, rgba(6, 182, 212, 0.06) 0%, transparent 40%),
    radial-gradient(circle at 50% 85%, rgba(16, 185, 129, 0.04) 0%, transparent 45%);
}

/* Base Sizing & Typography */
:root {
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --font-main: 'Outfit', 'Vazirmatn', -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --sidebar-width: 270px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-deep);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  background-image: var(--mesh-gradient);
  background-attachment: fixed;
  line-height: 1.6;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* ==========================================================================
   App Shell & Sidebar Layout
   ========================================================================== */

.app-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
}

/* Sidebar (RTL: on Right) */
.app-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-subtle);
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-card);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.3s ease;
  overflow-y: auto;
}

.sidebar-brand-box {
  padding: 1.5rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: -0.5px;
}

.brand-icon-chip {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--cyan), var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px var(--primary-glow);
  color: #fff;
  flex-shrink: 0;
}

.sidebar-nav-menu {
  list-style: none;
  padding: 1.25rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex: 1;
}

.nav-section-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  color: var(--text-dim);
  padding: 0.75rem 0.75rem 0.35rem 0.75rem;
  font-weight: 700;
}

.sidebar-item-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.9rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.92rem;
  transition: all 0.2s ease;
}

.sidebar-item-link:hover {
  background: var(--bg-card-hover);
  color: var(--text-main);
}

.sidebar-item-link.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.15), rgba(6, 182, 212, 0.15));
  color: var(--primary);
  font-weight: 700;
  border: 1px solid var(--border-glow);
}

[data-theme="light"] .sidebar-item-link.active {
  background: #eef2ff;
  color: var(--primary);
  border-color: rgba(99, 102, 241, 0.25);
}

.sidebar-footer-box {
  padding: 1.25rem 1rem;
  border-top: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.02);
}

/* User Card in Sidebar */
.user-sidebar-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  margin-bottom: 0.85rem;
}

/* Main Content Area */
.app-main {
  flex: 1;
  margin-right: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-right 0.3s ease;
}

/* Top App Header */
.app-header {
  height: 70px;
  background: var(--bg-header);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 90;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: padding 0.2s ease, height 0.2s ease;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  flex: 1;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-shrink: 0;
}

.header-page-title {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.2px;
}

.mobile-nav-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-main);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
  flex-shrink: 0;
}

.mobile-nav-toggle:hover {
  background: var(--bg-card-hover);
}

.mobile-sidebar-close {
  display: none;
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.35rem;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.mobile-sidebar-close:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
}

/* Theme Toggle Button (Sun / Moon) */
.theme-toggle-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.theme-toggle-btn:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
  border-color: var(--primary);
  transform: scale(1.05);
}

/* Glass & Card Classes */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.glass-panel:hover {
  border-color: rgba(99, 102, 241, 0.25);
}

/* Containers & Page Headers */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

.page-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.page-header-title {
  font-size: clamp(1.3rem, 3.2vw, 1.85rem);
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  line-height: 1.35;
}

.page-header-subtitle {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-top: 0.35rem;
  line-height: 1.6;
}

.page-header-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Metric Cards */
.grid-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.stat-card {
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.stat-title {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.75px;
  color: var(--text-muted);
  font-weight: 600;
}

.stat-value {
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  font-family: var(--font-mono);
  color: var(--text-main);
}

.stat-sub {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 0.35rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Dashboard Grid */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

@media (max-width: 1100px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

/* Interactive Playground */
.playground-card {
  padding: 1.75rem;
}

.section-title-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.section-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.form-control, .form-select {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.95rem;
  outline: none;
  transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-decoration: none;
  font-family: var(--font-main);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4338ca);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-cyan {
  background: linear-gradient(135deg, var(--cyan), #0891b2);
  color: #fff;
  box-shadow: 0 4px 14px var(--cyan-glow);
}

.btn-cyan:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--cyan-glow);
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  color: var(--rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

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

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.btn-secondary:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-input);
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
}

/* Response Terminal / Stream Output */
.response-box {
  background: var(--bg-code);
  color: #f8fafc;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  margin-top: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  min-height: 120px;
  position: relative;
  overflow-x: auto;
}

.response-meta {
  display: flex;
  gap: 1.25rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.7rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.badge-healthy {
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

[data-theme="light"] .badge-healthy {
  background: #ecfdf5;
  color: #059669;
  border-color: #a7f3d0;
}

.badge-degraded {
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

[data-theme="light"] .badge-degraded {
  background: #fffbeb;
  color: #d97706;
  border-color: #fde68a;
}

.badge-unhealthy {
  background: rgba(244, 63, 94, 0.15);
  color: var(--rose);
  border: 1px solid rgba(244, 63, 94, 0.3);
}

[data-theme="light"] .badge-unhealthy {
  background: #fff1f2;
  color: #e11d48;
  border-color: #fecdd3;
}

.badge-failover {
  background: rgba(245, 158, 11, 0.2);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

/* Live Pulse Indicator */
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
  animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {
  0% { transform: scale(0.95); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.7; }
}

/* Tables */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th {
  text-align: right;
  padding: 0.85rem 1rem;
  background: var(--bg-table-header);
  color: var(--text-muted);
  font-weight: 700;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  text-transform: uppercase;
}

.data-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

.data-table tr:hover td {
  background: var(--bg-table-hover);
}

/* Code Snippet Box */
.code-container {
  position: relative;
  background: var(--bg-code);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #e2e8f0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.code-container pre {
  margin: 0;
  padding-top: 1.25rem;
}

.copy-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  left: auto;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--border-subtle);
  color: #e2e8f0;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.75rem;
  transition: all 0.2s ease;
  z-index: 2;
}

.copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  width: 95%;
  max-width: 520px;
  padding: 2rem;
  position: relative;
  background: var(--bg-card);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.close-modal {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}

/* Sidebar Backdrop on Mobile */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 95;
  transition: opacity 0.25s ease;
}

body.sidebar-locked {
  overflow: hidden;
}

/* Multi-column Grid Utilities */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.modal-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

/* Playground Responsive Actions */
.playground-actions-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.playground-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

/* Key Display Row */
.key-display-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  background: var(--bg-card);
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  min-width: 0;
}

.key-code-text {
  font-size: 0.8rem;
  color: var(--cyan);
  direction: ltr;
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

/* Catalog Search & Filters */
.catalog-search-wrap {
  position: relative;
  min-width: 280px;
}

.catalog-search-wrap .form-control {
  padding: 0.6rem 2.4rem 0.6rem 1rem;
}

.search-icon-inside {
  position: absolute;
  right: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  width: 17px;
  height: 17px;
  color: var(--text-dim);
  pointer-events: none;
}

.brand-filter-bar {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 1.75rem;
  flex-wrap: wrap;
}

.filter-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-left: 0.5rem;
}

.filter-pills-scroll {
  display: flex;
  gap: 0.45rem;
  align-items: center;
  flex-wrap: wrap;
}

.catalog-count-badge {
  background: var(--bg-input);
  color: var(--text-muted);
  margin-right: auto;
}

.catalog-grid, .providers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
  gap: 1.35rem;
}

/* Filter Toolbar */
.filter-toolbar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
}

/* Auth Cards */
.auth-container {
  max-width: 480px;
  margin: 3.5rem auto;
}

.auth-card {
  padding: 2.25rem;
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
}

/* Brand Filter Pills in Model Catalog */
.brand-filter-pill {
  transition: all var(--transition-fast);
  cursor: pointer;
  border-radius: 20px;
  padding: 0.35rem 0.95rem;
}

.brand-filter-pill.active {
  background: var(--primary) !important;
  color: #fff !important;
  border-color: var(--primary) !important;
  box-shadow: 0 2px 10px var(--primary-glow);
}

/* Registration Banner */
.reg-banner-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.reg-banner-info {
  display: flex;
  align-items: center;
  gap: 1.15rem;
}

/* ==========================================================================
   Unified Modern Popups, Modals & Toast Notifications (OJE-AI Design System)
   ========================================================================== */

.oje-toast-container {
  position: fixed;
  top: 1.5rem;
  left: 1.5rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 420px;
  width: calc(100vw - 3rem);
  pointer-events: none;
}

.oje-toast {
  pointer-events: auto;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.95rem 1.15rem;
  border-radius: var(--radius-md);
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glow);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  animation: ojeToastSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: all 0.25s ease;
}

[data-theme="light"] .oje-toast {
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

@keyframes ojeToastSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.oje-toast-fadeout {
  opacity: 0 !important;
  transform: translateY(-15px) scale(0.95) !important;
}

.oje-toast-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
}

.oje-toast-success .oje-toast-icon {
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald);
}
.oje-toast-success {
  border-right: 4px solid var(--emerald);
}

.oje-toast-error .oje-toast-icon,
.oje-toast-danger .oje-toast-icon {
  background: rgba(244, 63, 94, 0.15);
  color: var(--rose);
}
.oje-toast-error,
.oje-toast-danger {
  border-right: 4px solid var(--rose);
}

.oje-toast-warning .oje-toast-icon {
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber);
}
.oje-toast-warning {
  border-right: 4px solid var(--amber);
}

.oje-toast-info .oje-toast-icon {
  background: rgba(6, 182, 212, 0.15);
  color: var(--cyan);
}
.oje-toast-info {
  border-right: 4px solid var(--cyan);
}

.oje-toast-body {
  flex: 1;
  font-size: 0.9rem;
  color: var(--text-main);
  line-height: 1.5;
  font-weight: 500;
}

.oje-toast-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
  transition: color var(--transition-fast);
}

.oje-toast-close:hover {
  color: var(--text-main);
}

.oje-toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: currentColor;
  opacity: 0.35;
  transform-origin: left;
  animation: ojeToastProgress linear forwards;
}

@keyframes ojeToastProgress {
  from { width: 100%; }
  to { width: 0%; }
}

/* Unified Dialog Modal Box */
.oje-dialog-overlay {
  z-index: 9999;
}

.oje-dialog-box {
  max-width: 460px;
  width: 90%;
  padding: 1.75rem;
  position: relative;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.5);
  animation: ojeDialogScale 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes ojeDialogScale {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.oje-dialog-icon-chip {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(6, 182, 212, 0.15);
  color: var(--cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
}

.oje-dialog-icon-chip.success {
  background: rgba(16, 185, 129, 0.15);
  color: var(--emerald);
  border-color: rgba(16, 185, 129, 0.3);
}

.oje-dialog-icon-chip.danger,
.oje-dialog-icon-chip.error {
  background: rgba(244, 63, 94, 0.15);
  color: var(--rose);
  border-color: rgba(244, 63, 94, 0.3);
}

.oje-dialog-icon-chip.warning {
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber);
  border-color: rgba(245, 158, 11, 0.3);
}

.oje-dialog-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 0.35rem;
}

.oje-dialog-message {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.oje-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.oje-dialog-close-btn {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.4rem;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.oje-dialog-close-btn:hover {
  color: var(--rose);
}

/* Header Token Counter Widget */
.token-counter {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--bg-card);
  border: 1px solid var(--border-glow);
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-md);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  transition: all var(--transition-fast);
  cursor: default;
}

.token-counter:hover {
  border-color: var(--cyan);
  box-shadow: 0 4px 14px var(--cyan-glow);
  transform: translateY(-1px);
}

.token-counter-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--amber);
  flex-shrink: 0;
}

.token-counter-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.token-counter-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  font-weight: 600;
}

.token-counter-value-row {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
}

.token-counter-value {
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
}

.token-counter-unit {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* User Table Token Balance Badge */
.token-balance-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--cyan);
  font-size: 0.92rem;
}

.token-balance-badge i {
  color: var(--amber);
}

/* ==========================================================================
   Multi-Device Responsive System (Laptops, Tablets, Mobile Phones)
   ========================================================================== */

/* 1. Large Displays & Laptops (<= 1200px) */
@media (max-width: 1200px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }
}

/* 2. Tablets & Small Laptops (<= 992px) */
@media (max-width: 992px) {
  .app-sidebar {
    transform: translateX(100%);
    width: min(290px, 85vw);
    box-shadow: -10px 0 35px rgba(0, 0, 0, 0.6);
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  .app-main {
    margin-right: 0;
  }

  .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-sidebar-close {
    display: inline-flex;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 95;
    transition: opacity 0.25s ease;
  }

  .sidebar-backdrop.active {
    display: block;
  }

  body.sidebar-locked {
    overflow: hidden;
  }

  .app-header {
    padding: 0 1.25rem;
  }

  .container {
    padding: 1.25rem 1rem;
  }
}

/* 3. Small Tablets & Landscape Mobile (<= 768px) */
@media (max-width: 768px) {
  .form-grid-2 {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .page-header-row {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
    margin-bottom: 1.5rem;
  }

  .page-header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .reg-banner-wrap {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .reg-banner-wrap .btn {
    width: 100%;
    justify-content: center;
  }

  .reg-banner-info {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.85rem;
  }

  .filter-toolbar {
    width: 100%;
  }

  .filter-toolbar > * {
    flex: 1 1 calc(50% - 0.5rem);
    min-width: 140px;
  }

  .filter-toolbar > .badge,
  .filter-toolbar > span.badge {
    flex: 0 0 auto;
  }

  .catalog-search-wrap {
    width: 100%;
    min-width: 0;
  }

  .brand-filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .filter-pills-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.35rem;
    flex-wrap: nowrap;
    scrollbar-width: thin;
  }

  .filter-pills-scroll .brand-filter-pill {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .catalog-count-badge {
    margin-right: 0;
    align-self: flex-start;
  }

  .table-responsive {
    border-radius: var(--radius-sm);
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.2);
    -webkit-overflow-scrolling: touch;
  }

  .data-table th, .data-table td {
    padding: 0.75rem 0.85rem;
    font-size: 0.84rem;
    white-space: nowrap;
  }

  .modal-content {
    padding: 1.5rem;
    max-height: 90vh;
  }

  .grid-stats {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
    gap: 1rem;
  }

  .stat-card {
    padding: 1.25rem;
  }

  .stat-value {
    font-size: 1.85rem;
  }
}

/* 4. Mobile Phones (<= 576px) */
@media (max-width: 576px) {
  .app-header {
    height: 62px;
    padding: 0 0.85rem;
  }

  .header-left {
    gap: 0.5rem;
  }

  .header-right {
    gap: 0.5rem;
  }

  .header-page-title {
    max-width: 140px;
    font-size: 0.88rem;
  }

  .token-counter {
    padding: 0.3rem 0.55rem;
    gap: 0.4rem;
  }

  .token-counter-icon {
    width: 26px;
    height: 26px;
    border-radius: 6px;
  }

  .token-counter-icon i {
    width: 14px !important;
    height: 14px !important;
  }

  .token-counter-label {
    display: none;
  }

  .token-counter-unit {
    display: none;
  }

  .token-counter-value {
    font-size: 0.84rem;
  }

  .theme-toggle-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .container {
    padding: 0.85rem 0.65rem;
  }

  .page-header-title {
    font-size: 1.35rem;
  }

  .page-header-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .page-header-actions .btn {
    width: 100%;
    justify-content: center;
  }

  .playground-card {
    padding: 1.15rem;
  }

  .playground-actions-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .playground-actions-bar .btn {
    width: 100%;
    justify-content: center;
  }

  .filter-toolbar > * {
    flex: 1 1 100%;
    width: 100% !important;
  }

  .catalog-grid, .providers-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .catalog-model-card {
    padding: 1.25rem !important;
  }

  .modal-grid-2 {
    grid-template-columns: 1fr;
    gap: 0.65rem;
  }

  .modal-content {
    padding: 1.25rem 1rem;
    width: 96%;
    max-height: 94vh;
  }

  .modal-header {
    margin-bottom: 1rem;
  }

  .data-table th, .data-table td {
    padding: 0.6rem 0.7rem;
    font-size: 0.8rem;
  }

  .oje-toast-container {
    top: 0.75rem;
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    max-width: none;
  }

  .oje-dialog-box {
    padding: 1.25rem;
    width: 95%;
  }

  .auth-container {
    margin: 1.5rem auto;
    padding: 0 0.5rem;
  }

  .auth-card {
    padding: 1.5rem 1.15rem;
  }

  .btn {
    font-size: 0.9rem;
    padding: 0.65rem 1.1rem;
  }

  .btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }
}

/* 5. Extra Small Devices (<= 380px) */
@media (max-width: 380px) {
  .header-page-title {
    max-width: 110px;
    font-size: 0.82rem;
  }

  .token-counter-value {
    font-size: 0.78rem;
  }

  .stat-value {
    font-size: 1.6rem;
  }
}



