/* ============================================================
   ADMIN PANEL — Design System
   Purple/Violet theme to distinguish from Reseller Panel (blue)
   ============================================================ */

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

/* ---- CSS Variables ---- */
:root {
  --accent:          #8b5cf6;
  --accent-hover:    #7c3aed;
  --accent-glow:     rgba(139, 92, 246, 0.35);
  --accent-muted:    rgba(139, 92, 246, 0.12);

  --bg-base:         #0d0f1a;
  --bg-sidebar:      #0f1120;
  --bg-card:         #141726;
  --bg-card-hover:   #1a1f35;
  --bg-input:        #1a1f35;

  --border:          rgba(255,255,255,0.07);
  --border-focus:    rgba(139,92,246,0.5);

  --text-primary:    #f1f5f9;
  --text-secondary:  #94a3b8;
  --text-muted:      #64748b;

  --green:           #22c55e;
  --red:             #ef4444;
  --yellow:          #f59e0b;
  --blue:            #3b82f6;

  --radius:          12px;
  --radius-sm:       8px;
  --radius-pill:     999px;
  --speed:           200ms;
  --ease:            cubic-bezier(0.4, 0, 0.2, 1);

  --sidebar-w:       220px;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ============================================================
   ANIMATIONS
   ============================================================ */

@keyframes fadeIn  { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }
@keyframes pulse   { 0%,100%{ box-shadow:0 0 0 0 var(--accent-glow); } 50%{ box-shadow:0 0 0 6px transparent; } }
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes slideUp { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-base);
  background-image:
    radial-gradient(ellipse 60% 50% at 50% -10%, rgba(139,92,246,0.18) 0%, transparent 70%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 40px 36px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5), 0 0 0 1px rgba(139,92,246,0.08);
  animation: slideUp 0.4s var(--ease);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon {
  width: 60px; height: 60px;
  border-radius: 16px;
  background: var(--accent-muted);
  border: 1px solid rgba(139,92,246,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  margin: 0 auto 16px;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.login-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.input-wrap { position: relative; }

.form-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color var(--speed) var(--ease), box-shadow var(--speed) var(--ease);
}

.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(139,92,246,0.12);
}

textarea.form-input { resize: vertical; }

.login-error {
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 13px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--speed) var(--ease), box-shadow var(--speed) var(--ease), transform var(--speed) var(--ease);
  margin-top: 4px;
}

.btn-primary:hover  { background: var(--accent-hover); box-shadow: 0 4px 20px var(--accent-glow); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

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

.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 0;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 18px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.brand-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.admin-brand {
  background: var(--accent-muted);
  border: 1px solid rgba(139,92,246,0.3);
}

.brand-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-nav { flex: 1; padding: 0 10px; display: flex; flex-direction: column; gap: 2px; }

.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 8px 10px 6px;
  text-transform: uppercase;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--speed) var(--ease);
}

.nav-item:hover   { background: var(--accent-muted); color: var(--text-secondary); }
.nav-item.active  { background: var(--accent-muted); color: var(--accent); font-weight: 600; border-left: 3px solid var(--accent); padding-left: 9px; }

.nav-icon { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-footer {
  padding: 16px 18px 0;
  border-top: 1px solid var(--border);
  margin-top: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.user-avatar {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent-muted);
  border: 1px solid rgba(139,92,246,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.admin-avatar { color: var(--accent); }

.logout-btn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--speed) var(--ease);
  flex-shrink: 0;
}

.logout-btn:hover { border-color: rgba(239,68,68,0.5); color: var(--red); background: rgba(239,68,68,0.08); }

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---- Topbar ---- */
.topbar {
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-sidebar);
  flex-shrink: 0;
}

.topbar-title { font-size: 18px; font-weight: 700; color: var(--text-primary); }
.topbar-sub   { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.admin-badge {
  padding: 5px 12px;
  background: var(--accent-muted);
  border: 1px solid rgba(139,92,246,0.3);
  border-radius: var(--radius-pill);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

/* ---- Tab Pages ---- */
.tab-page {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  animation: fadeIn 0.25s var(--ease);
}

.tab-page.active { display: block; }

/* ============================================================
   STATS GRID (Dashboard)
   ============================================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color var(--speed) var(--ease), transform var(--speed) var(--ease);
}

.stat-card:hover { border-color: rgba(139,92,246,0.3); transform: translateY(-2px); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.stat-info { min-width: 0; }

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Server stats */
.server-stat {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.server-stat-label { font-size: 13px; color: var(--text-muted); }
.server-stat-value { font-size: 14px; font-weight: 600; color: var(--text-primary); }

/* ============================================================
   TABLE CARD
   ============================================================ */

.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.table-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.table-count { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead tr { background: rgba(139,92,246,0.05); }

th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  vertical-align: middle;
  color: var(--text-secondary);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: rgba(139,92,246,0.04); }

/* ============================================================
   FILTERS
   ============================================================ */

.codes-filters {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.table-search {
  padding: 8px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color var(--speed) var(--ease);
}

.table-search:focus { border-color: var(--border-focus); }

.filter-select {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  outline: none;
  cursor: pointer;
  transition: border-color var(--speed) var(--ease);
  min-width: 140px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.filter-select:focus { border-color: var(--border-focus); }
.filter-select option { background: #1a1f2e; color: var(--text-primary); }

.filter-pills { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

.filter-pill {
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: all var(--speed) var(--ease);
  white-space: nowrap;
}

.filter-pill:hover { background: var(--bg-card-hover); color: var(--text-secondary); }

.filter-pill.active         { background: var(--accent-muted); color: var(--accent); border-color: rgba(139,92,246,0.4); }

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

.action-btns { display: flex; gap: 4px; align-items: center; }

.action-btn {
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: rgba(255,255,255,0.75);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all var(--speed) var(--ease);
  position: relative;
  flex-shrink: 0;
}

.action-btn:hover         { border-color: rgba(255,255,255,0.2); }
.action-btn.edit:hover    { background: rgba(139,92,246,0.15); border-color: rgba(139,92,246,0.4); color: var(--accent); }
.action-btn.reset:hover   { background: rgba(59,130,246,0.15);  border-color: rgba(59,130,246,0.4);  color: var(--blue); }
.action-btn.disable:hover { background: rgba(239,68,68,0.15);   border-color: rgba(239,68,68,0.4);   color: var(--red); }
.action-btn.renew:hover   { background: rgba(34,197,94,0.15);   border-color: rgba(34,197,94,0.4);   color: var(--green); }
.action-btn.delete:hover  { background: rgba(239,68,68,0.15);   border-color: rgba(239,68,68,0.4);   color: var(--red); }

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

.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-green  { background: rgba(34,197,94,0.12);   color: var(--green);  border: 1px solid rgba(34,197,94,0.25); }
.badge-red    { background: rgba(239,68,68,0.12);   color: var(--red);    border: 1px solid rgba(239,68,68,0.25); }
.badge-blue   { background: rgba(59,130,246,0.12);  color: var(--blue);   border: 1px solid rgba(59,130,246,0.25); }
.badge-grey   { background: rgba(100,116,139,0.12); color: #94a3b8;       border: 1px solid rgba(100,116,139,0.25); }
.badge-purple { background: var(--accent-muted);    color: var(--accent); border: 1px solid rgba(139,92,246,0.3); }

/* ============================================================
   EMPTY / LOADING STATES
   ============================================================ */

.loading-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px;
  color: var(--text-muted);
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(139,92,246,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  flex-shrink: 0;
}

.loading-text { font-size: 13px; color: var(--text-muted); }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-icon { font-size: 32px; opacity: 0.5; }
.empty-text { font-size: 14px; color: var(--text-muted); }

/* ============================================================
   SECTION HEADING
   ============================================================ */

.section-heading {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ============================================================
   MESSAGES
   ============================================================ */

.message-card {
  background: var(--bg-card-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  transition: border-color var(--speed) var(--ease);
}

.message-card:hover { border-color: rgba(139,92,246,0.25); }

.message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.message-to      { font-size: 13px; font-weight: 600; color: var(--accent); }
.message-subject { font-size: 13px; color: var(--text-secondary); }
.message-time    { font-size: 11px; color: var(--text-muted); }
.message-body    { font-size: 13px; color: var(--text-secondary); line-height: 1.6; white-space: pre-wrap; }

/* ============================================================
   TOAST
   ============================================================ */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  background: #1e2235;
  border: 1px solid var(--border);
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(8px);
  transition: all 0.3s var(--ease);
  max-width: 320px;
}

.toast.show { opacity: 1; transform: translateY(0); }

.toast-success { background: rgba(34,197,94,0.15);  border-color: rgba(34,197,94,0.3);  }
.toast-error   { background: rgba(239,68,68,0.15);  border-color: rgba(239,68,68,0.3);  }
.toast-info    { background: rgba(139,92,246,0.15); border-color: rgba(139,92,246,0.3); }
