/* ============================================
   Modern Admin Layout CSS - Dark Theme
   ============================================ */

/* ---- CSS Variables ---- */
:root {
  --pri: #0066ff;
  --pri-hover: #0052cc;
  --pri-light: rgba(88, 166, 255, 0.06);
  --bg: #0f1117;
  --bg-alt: #1a1d27;
  --sidebar-bg: #14161f;
  --sidebar-hover: rgba(255, 255, 255, 0.08);
  --sidebar-active: rgba(0, 102, 255, 0.25);
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --txt: #e1e4e8;
  --txt-secondary: #8b949e;
  --txt-light: #6e7681;
  --txt-on-dark: rgba(255, 255, 255, 0.85);
  --txt-on-dark-hover: #fff;
  --card: #1a1d27;
  --border: #30363d;
  --border-light: rgba(255, 255, 255, 0.08);
  --err: #ff4444;
  --err-hover: #e63939;
  --success: #22c55e;
  --warn: #f59e0b;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-sm: 6px;
  --transition: all 0.2s ease;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.6;
  overflow-x: hidden;
}
a { color: var(--pri); text-decoration: none; transition: color 0.2s ease; }
a:hover { color: var(--pri-hover); }
img { max-width: 100%; height: auto; display: block; }

/* ============================================
   LAYOUT: Sidebar + Topbar + Main Content
   ============================================ */

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  color: var(--txt-on-dark);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  border-right: 1px solid var(--border-light);
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--txt-on-dark-hover);
  letter-spacing: -0.01em;
  height: var(--topbar-height);
  white-space: nowrap;
}
.sidebar-nav { flex: 1; padding: 0.75rem 0; overflow-y: auto; }
.sidebar-section-title {
  padding: 0.75rem 1.25rem 0.375rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--txt-light);
}
.sidebar-divider { height: 1px; background: var(--border-light); margin: 0.5rem 0.75rem; }
.sidebar-link {
  display: flex;
  align-items: center;
  padding: 0.625rem 1.25rem;
  margin: 0 0.75rem;
  border-radius: var(--radius);
  color: var(--txt-on-dark);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
  white-space: nowrap;
  text-decoration: none;
}
.sidebar-link:hover { background: var(--sidebar-hover); color: var(--txt-on-dark-hover); text-decoration: none; }
.sidebar-link.active { background: var(--sidebar-active); color: #fff; }
.sidebar-link .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 0.75rem;
  width: 20px;
  height: 20px;
  font-size: 1rem;
  flex-shrink: 0;
}

/* --- Topbar --- */
.topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--topbar-height);
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 999;
}
.topbar-left { display: flex; align-items: center; gap: 0.75rem; }
.topbar-left .breadcrumb-sep { color: var(--txt-light); font-size: 0.875rem; }
.page-title { font-size: 1rem; font-weight: 600; color: var(--txt); letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 0.75rem; }
.logout-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.875rem;
  background: transparent;
  color: var(--txt-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
}
.logout-btn:hover { background: var(--sidebar-hover); color: var(--txt); border-color: var(--border); text-decoration: none; }

/* --- Main Content --- */
.main-content {
  margin-left: var(--sidebar-width);
  padding-top: var(--topbar-height);
  min-height: 100vh;
  background: var(--bg);
}
.main-content-inner { padding: 1.5rem; max-width: 1400px; }

/* ============================================
   COMPONENTS
   ============================================ */

/* --- Cards --- */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.card-header h2, .card-header h3 { margin: 0; }
.card h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 0.75rem; color: var(--txt); }
.card h3 { font-size: 1rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--txt); }
.card p { color: var(--txt-secondary); font-size: 0.875rem; margin-bottom: 0.5rem; }

/* --- Buttons --- */
.btn, button, input[type="submit"], input[type="button"] {
  display: inline-block;
  width: auto;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--pri);
  color: #fff;
}
.btn:hover, button:hover, input[type="submit"]:hover, input[type="button"]:hover {
  background: var(--pri-hover);
  text-decoration: none;
}
.btn:disabled, button:disabled, input[type="submit"]:disabled, input[type="button"]:disabled {
  background: var(--txt-light);
  cursor: not-allowed;
  opacity: 0.7;
}
.btn-secondary, .btn-sec { background: #3b82f6; color: #fff; }
.btn-secondary:hover, .btn-sec:hover { background: #2563eb; }
.btn-danger, .btn-err { background: var(--err); color: #fff; }
.btn-danger:hover, .btn-err:hover { background: var(--err-hover); }
.btn-success, .btn-green { background: var(--success); color: #fff; }
.btn-success:hover, .btn-green:hover { background: #16a34a; }
.btn-white { background: var(--bg-alt); color: var(--txt); border: 1px solid var(--border); }
.btn-white:hover { background: var(--border); }

/* Nav Grid - Dashboard Quick Links */
.nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.nav-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--txt);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s ease;
}
.nav-card:hover { background: var(--pri-light); border-color: var(--pri); color: var(--pri); text-decoration: none; }
.nav-card .icon { font-size: 1.25rem; width: 24px; text-align: center; }

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  text-align: center;
}
.stat-card h3 { font-size: 0.8125rem; font-weight: 500; color: var(--txt-secondary); margin-bottom: 0.5rem; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; color: var(--pri); }

/* --- Tables --- */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th {
  background: #161922;
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--txt);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--txt-secondary);
}
tbody tr:hover td { background: var(--pri-light); }
tbody tr:last-child td { border-bottom: none; }
.table-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* --- Forms --- */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.8125rem; font-weight: 500; color: var(--txt-secondary); margin-bottom: 0.375rem; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="url"], input[type="search"], select, textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--txt);
  font-size: 0.875rem;
  line-height: 1.4;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--pri);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.15);
}
input[type="checkbox"], input[type="radio"] {
  width: auto;
  margin-right: 0.5rem;
}
select { appearance: none; padding-right: 2rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; }
textarea { min-height: 80px; resize: vertical; }

/* --- Alerts --- */
.alert { padding: 0.75rem 1rem; border-radius: var(--radius); font-size: 0.8125rem; font-weight: 500; margin-bottom: 1rem; }
.alert-success { background: rgba(34, 197, 94, 0.15); color: #3fb950; border: 1px solid rgba(34, 197, 94, 0.3); }
.alert-danger { background: rgba(255, 68, 68, 0.15); color: #f85149; border: 1px solid rgba(255, 68, 68, 0.3); }
.alert-warning { background: rgba(245, 158, 11, 0.15); color: #d29922; border: 1px solid rgba(245, 158, 11, 0.3); }
.alert-info { background: rgba(0, 102, 255, 0.1); color: var(--pri); border: 1px solid rgba(0, 102, 255, 0.3); }

/* --- Badges --- */
.badge { display: inline-block; padding: 0.125rem 0.5rem; font-size: 0.75rem; font-weight: 500; border-radius: 999px; }
.badge-success { background: rgba(34, 197, 94, 0.15); color: #3fb950; }
.badge-danger { background: rgba(255, 68, 68, 0.15); color: #f85149; }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #d29922; }
.badge-info { background: rgba(0, 102, 255, 0.15); color: var(--pri); }

/* --- Unread Badge --- */
.unread-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: var(--err);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 600;
  border-radius: 999px;
  margin-left: auto;
  line-height: 1;
}

/* --- Pagination --- */
.pagination { display: flex; align-items: center; gap: 0.5rem; justify-content: center; margin-top: 1.5rem; }
.pagination a, .pagination span { padding: 0.375rem 0.75rem; border-radius: var(--radius); font-size: 0.8125rem; border: 1px solid var(--border); color: var(--txt-secondary); transition: all 0.2s ease; }
.pagination a:hover { background: var(--pri-light); border-color: var(--pri); color: var(--pri); }
.pagination .active { background: var(--pri); color: #fff; border-color: var(--pri); }

/* ============================================
   AUTH PAGES (centered card layout)
   ============================================ */
.auth-wrapper { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border-radius: var(--radius-lg); padding: 2rem; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.auth-title { text-align: center; margin-bottom: 1.5rem; font-size: 1.5rem; font-weight: 600; color: var(--txt); letter-spacing: -0.02em; }
.auth-hint { font-size: 0.8125rem; color: var(--txt-secondary); text-align: center; margin-bottom: 1rem; line-height: 1.5; }
.auth-card .form-group { margin-bottom: 1rem; }
.auth-card .btn, .auth-card button, .auth-card input[type="submit"] { width: 100%; margin-top: 0.5rem; }
.auth-card a.btn, .auth-card a { display: block; text-align: center; margin-top: 0.75rem; font-size: 0.875rem; }
.auth-links { display: flex; justify-content: center; gap: 1rem; margin-top: 1rem; font-size: 0.875rem; }
.auth-links a { color: var(--pri); text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }

/* --- Ban IP section --- */
.ban-ip-section { margin-top: 1.5rem; }

/* --- Balance Display --- */
.card p.balance-display { font-size: 1.125rem; margin: 1rem 0; color: #22c55e; }

/* --- Order Page --- */
.order-select {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--txt);
  font-size: 0.9375rem;
  cursor: pointer;
  transition: border-color 0.2s ease;
}
.order-select:focus { outline: none; border-color: var(--pri); box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.15); }
.order-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--txt);
  font-size: 0.9375rem;
  transition: border-color 0.2s ease;
}
.order-input:focus { outline: none; border-color: var(--pri); box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.15); }

/* Custom Dropdown for Categories */
.custom-dropdown { position: relative; }
.dropdown-display {
  padding: 0.75rem 1rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--txt);
  font-size: 0.9375rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: border-color 0.2s ease;
}
.dropdown-display:hover { border-color: var(--pri); }
.dropdown-options {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 0.25rem;
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: var(--shadow-lg);
}
.dropdown-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1rem;
  cursor: pointer;
  font-size: 0.9375rem;
  color: var(--txt);
  transition: background 0.15s ease;
}
.dropdown-option:hover { background: var(--pri-light); }
.dropdown-option img.category-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}
.dropdown-option img.service-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
}
.dropdown-option span.service-id {
  color: #00FF00;
  font-weight: 600;
}
.dropdown-display.has-selection img.service-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  flex-shrink: 0;
}
.dropdown-display.has-selection span.service-id {
  color: #00FF00;
  font-weight: 600;
}
.dropdown-placeholder { color: var(--txt-secondary); }
.dropdown-display.has-selection { color: var(--txt); }
.dropdown-display.has-selection .category-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}
.dropdown-display.has-selection span {
  font-weight: 500;
}

.balance-amount { color: #22c55e; font-size: 2rem; font-weight: 700; }

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablet: sidebar collapses to icons */
@media (max-width: 1024px) {
  .sidebar { width: 64px; }
  .sidebar-brand span, .sidebar-section-title, .sidebar-link span { display: none; }
  .sidebar-link { justify-content: center; padding: 0.75rem 0; }
  .sidebar-link .icon { margin-right: 0; font-size: 1.25rem; }
  .topbar { left: 64px; }
  .main-content { margin-left: 64px; }
  .nav-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Mobile: sidebar hidden */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-width); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-brand span, .sidebar-section-title, .sidebar-link span { display: inline; }
  .sidebar-link { justify-content: flex-start; padding: 0.625rem 1.25rem; margin: 0 0.5rem; }
  .sidebar-link .icon { margin-right: 0.75rem; width: 20px; height: 20px; font-size: 1rem; }
  .topbar { left: 0; padding: 0 1rem; }
  .topbar-left { gap: 0.5rem; }
  .main-content { margin-left: 0; }
  .main-content-inner { padding: 1rem; }
  .form-row { flex-direction: column; gap: 0; }
  .card { padding: 1rem; }
  .stats-grid { grid-template-columns: 1fr; }
  .nav-grid { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-flex !important; }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 999; }
  .sidebar-overlay.active { display: block; }
}

@media (min-width: 769px) {
  .menu-toggle { display: none !important; }
}

/* Batch operations bar */
.batch-bar {
  display: none !important;
  margin-bottom: 1rem;
  padding: .75rem;
  background: rgba(255,255,255,0.05);
  border-radius: var(--radius);
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}
.batch-bar.show { display: flex !important; }
