/* ======================================================
   VPSTTT Portal – Premium Design System
   Inspired by Vultr / modern cloud-portal aesthetics
   ====================================================== */

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

/* ---------- Design Tokens ---------- */
:root {
  /* Colour palette – light */
  --bg: #f0f4f9;
  --bg-gradient: linear-gradient(168deg, #f0f4f9 0%, #e4ecf7 100%);
  --surface: #ffffff;
  --surface-alt: #f7f9fc;
  --surface-glass: rgba(255, 255, 255, 0.78);
  --text: #111827;
  --text-secondary: #4b5563;
  --muted: #6b7280;
  --border: #e2e8f0;
  --border-hover: #cbd5e1;

  /* Accent */
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-soft: rgba(37, 99, 235, 0.08);
  --primary-glow: rgba(37, 99, 235, 0.18);

  /* Status */
  --success: #059669;
  --success-soft: rgba(5, 150, 105, 0.1);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.1);
  --danger: #dc2626;
  --danger-soft: rgba(220, 38, 38, 0.1);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow: 0 4px 16px rgba(0,0,0,.06);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.08);
  --shadow-glow: 0 0 0 3px var(--primary-glow);

  /* Layout */
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 999px;

  /* Transition */
  --ease: cubic-bezier(.4,0,.2,1);
  --duration: .2s;
}

/* ---------- Dark mode ---------- */
html[data-theme="dark"] {
  --bg: #0c111b;
  --bg-gradient: linear-gradient(168deg, #0c111b 0%, #111827 100%);
  --surface: #1a2234;
  --surface-alt: #1f2b3f;
  --surface-glass: rgba(26, 34, 52, 0.88);
  --text: #f1f5f9;
  --text-secondary: #94a3b8;
  --muted: #64748b;
  --border: #2d3a4f;
  --border-hover: #3b4a63;
  --primary: #60a5fa;
  --primary-hover: #93c5fd;
  --primary-soft: rgba(96, 165, 250, 0.12);
  --primary-glow: rgba(96, 165, 250, 0.22);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, 0.12);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.2);
  --shadow: 0 4px 16px rgba(0,0,0,.2);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.3);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg-gradient);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea, summary { font: inherit; color: inherit; }
img { display: block; max-width: 100%; height: auto; }
summary { list-style: none; cursor: pointer; }
summary::-webkit-details-marker { display: none; }

/* ---------- App Shell ---------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   SIDEBAR – Desktop
   ============================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--surface-glass);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 40;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--duration) var(--ease);
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.sidebar + .app-main {
  margin-left: var(--sidebar-w);
}

/* Logo */
.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo img {
  width: 100%;
  max-width: 140px;
  height: auto;
}

/* Section */
.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 12px 0;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  padding: 8px 12px 4px;
}

.sidebar-bottom-links {
  margin-top: auto;
  padding-bottom: 16px;
}

/* Nav items */
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  text-align: left;
  position: relative;
}

.nav-item:hover {
  background: var(--primary-soft);
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.nav-item:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.nav-danger {
  color: var(--danger) !important;
}

.nav-danger:hover {
  background: var(--danger-soft) !important;
}

/* ============================================================
   TOPBAR – User header
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  height: var(--topbar-h);
  padding: 0 24px;
  background: var(--surface-glass);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  border-bottom: 1px solid var(--border);
}

.topbar-news {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 13px;
  color: var(--muted);
}

.topbar-news strong {
  color: var(--primary);
  flex-shrink: 0;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.topbar-news span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.topbar-user {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}

.topbar-balance {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
  white-space: nowrap;
  text-decoration: none;
}

.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
  box-shadow: var(--shadow-glow);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: var(--border);
}

.btn-ghost:hover {
  background: var(--surface-alt);
  border-color: var(--border-hover);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger-soft);
}

/* ============================================================
   DROPDOWN
   ============================================================ */
.dropdown { position: relative; }

.dropdown > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration) var(--ease);
}

.dropdown > summary:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-glow);
}

.dropdown > summary::after {
  content: '';
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  transition: transform var(--duration) var(--ease);
}

.dropdown[open] > summary::after {
  transform: rotate(180deg);
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 220px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 50;
  animation: slideDown .18s var(--ease);
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--duration) var(--ease);
  text-align: left;
}

.dropdown-item:hover { background: var(--primary-soft); }
.dropdown-item:disabled { opacity: .5; cursor: not-allowed; }
.dropdown-item:disabled:hover { background: transparent; }

.dropdown-empty {
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.link-item { display: block; }
.danger { color: var(--danger); }

/* ============================================================
   CONTENT AREA
   ============================================================ */
.content {
  flex: 1;
  padding: 24px;
}

.auth-content {
  padding-top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-gradient);
}

/* Blank/placeholder panel */
.blank-panel {
  min-height: calc(100vh - var(--topbar-h) - 48px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.blank-panel-admin {
  min-height: calc(100vh - 48px);
}

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-card {
  width: min(100%, 440px);
  padding: 40px 36px 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  animation: fadeUp .35s var(--ease);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-card-admin {
  border-top: 3px solid var(--primary);
}

.auth-brand {
  text-align: center;
  margin-bottom: 28px;
}

.auth-brand img {
  width: 72px;
  height: auto;
  margin: 0 auto 16px;
  border-radius: var(--radius-lg);
}

.auth-brand h1 {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 6px;
}

.auth-brand p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.auth-form input {
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  font-size: 14px;
  transition: border-color var(--duration) var(--ease), box-shadow var(--duration) var(--ease);
  outline: none;
}

.auth-form input:focus {
  border-color: var(--primary);
  box-shadow: var(--shadow-glow);
}

.auth-form .btn {
  margin-top: 4px;
  padding: 12px;
  font-size: 14px;
}

.auth-links {
  margin-top: 20px;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.auth-links a,
.auth-links button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  transition: all var(--duration) var(--ease);
}

.auth-links a:hover,
.auth-links button:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

/* ============================================================
   ALERTS & TOASTS
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
}

.alert-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(220, 38, 38, .15);
}

.alert-success {
  background: var(--success-soft);
  color: var(--success);
  border: 1px solid rgba(5, 150, 105, .15);
}

.toast {
  margin: 16px 24px 0;
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  animation: slideDown .3s var(--ease);
}

.toast-success {
  border-left: 3px solid var(--success);
  color: var(--success);
}

.toast-error,
.toast-danger {
  border-left: 3px solid var(--danger);
  color: var(--danger);
}

.toast-info {
  border-left: 3px solid var(--primary);
  color: var(--primary);
}

/* ============================================================
   MOBILE BOTTOM NAVIGATION
   ============================================================ */
.mobile-nav {
  display: none;
}

/* ============================================================
   ADMIN SIDEBAR extra styles
   ============================================================ */
.admin-sidebar {
  border-right-color: var(--border);
}

/* ============================================================
   RESPONSIVE – Tablet
   ============================================================ */
@media (max-width: 991px) {
  :root { --sidebar-w: 220px; }

  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding: 12px 16px;
    gap: 8px;
  }

  .topbar-news {
    width: 100%;
    order: 1;
  }

  .topbar-actions {
    width: 100%;
    order: 2;
    flex-wrap: wrap;
  }
}

/* ============================================================
   RESPONSIVE – Mobile
   ============================================================ */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    display: none;
  }

  .sidebar + .app-main {
    margin-left: 0;
  }

  .topbar {
    height: auto;
    padding: 10px 14px;
    gap: 6px;
    border-radius: 0;
    border-bottom: 1px solid var(--border);
  }

  .topbar-actions {
    display: none;
  }

  .topbar-news {
    width: 100%;
    font-size: 12px;
  }

  .content {
    padding: 14px 14px 100px;
  }

  .blank-panel {
    min-height: calc(100vh - 160px);
    border-radius: var(--radius-lg);
  }

  /* ---- Mobile bottom nav ---- */
  .mobile-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--surface-glass);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border-top: 1px solid var(--border);
    z-index: 60;
  }

  /* Nav item in mobile bar */
  .mobile-nav-item {
    position: relative;
  }

  .mobile-nav-item > summary,
  .mobile-nav-item.plain-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    width: 100%;
    min-height: 52px;
    padding: 6px 4px;
    background: transparent;
    color: var(--muted);
    border: none;
    border-radius: var(--radius);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--duration) var(--ease);
    text-align: center;
  }

  .mobile-nav-item > summary:hover,
  .mobile-nav-item.plain-button:hover {
    color: var(--primary);
    background: var(--primary-soft);
  }

  /* Center item (logo / khởi tạo) */
  .mobile-nav-center > summary {
    background: var(--primary) !important;
    color: #fff !important;
    border-radius: var(--radius-lg);
    min-height: 56px;
    margin-top: -8px;
    box-shadow: 0 4px 16px rgba(37, 99, 235, .3);
  }

  .mobile-nav-center img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    filter: brightness(0) invert(1);
  }

  /* Mobile sheet (dropdown from bottom nav) */
  .mobile-sheet {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 8px);
    transform: translateX(-50%);
    width: min(260px, calc(100vw - 24px));
    max-height: 60vh;
    overflow-y: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    z-index: 70;
    animation: slideUp .2s var(--ease);
  }

  @keyframes slideUp {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
  }

  /* Mobile nav icons using emoji/text */
  .mobile-nav-item .nav-icon {
    font-size: 18px;
    line-height: 1;
  }

  /* Auth page mobile */
  .auth-content {
    padding: 16px 12px 60px;
    align-items: flex-start;
    padding-top: 10vh;
  }

  .auth-card {
    width: 100%;
    padding: 28px 20px;
    border-radius: var(--radius-lg);
  }

  .toast {
    margin: 12px 14px 0;
  }
}

/* ============================================================
   UTILITY
   ============================================================ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.placeholder-card {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* Focus visible */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Selection */
::selection {
  background: var(--primary-soft);
  color: var(--primary);
}
