/* ============================================================
   ContaboPanel – Main Stylesheet
   Theme: Primary #2154FF | Sidebar #0B1220 | BG #F5F7FB | Card #fff
   ============================================================ */

:root {
  --primary:     #2154FF;
  --primary-d:   #1740d6;
  --primary-l:   #e8eeff;
  --sidebar:     #0B1220;
  --sidebar-l:   #141e33;
  --bg:          #F5F7FB;
  --card:        #FFFFFF;
  --border:      #e2e8f0;
  --text:        #0f172a;
  --muted:       #64748b;
  --success:     #10b981;
  --warning:     #f59e0b;
  --danger:      #ef4444;
  --info:        #3b82f6;
  --radius:      12px;
  --radius-sm:   8px;
  --shadow:      0 2px 16px rgba(33,84,255,.08);
  --shadow-lg:   0 8px 40px rgba(33,84,255,.15);
  --sidebar-w:   240px;
  --topbar-h:    64px;
  --transition:  .18s ease;
  --font:        -apple-system,BlinkMacSystemFont,'Segoe UI','Inter',sans-serif;
  --mono:        'SF Mono','Fira Code',monospace;
}

/* Reset */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Layout ─────────────────────────────────────────────────── */

.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 1.5rem 1.4rem 1rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-logo .logo-icon {
  width: 34px; height: 34px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.sidebar-logo .logo-text {
  font-size: 1rem; font-weight: 700;
  color: #fff; letter-spacing: -.2px;
}
.sidebar-logo .logo-version {
  font-size: .65rem; color: rgba(255,255,255,.4);
  display: block; margin-top: 1px;
}

.sidebar-section {
  padding: 1rem 0 .5rem;
}
.sidebar-section-label {
  font-size: .65rem; font-weight: 700;
  color: rgba(255,255,255,.3);
  letter-spacing: .08em;
  text-transform: uppercase;
  padding: 0 1.4rem .4rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1.4rem;
  color: rgba(255,255,255,.6);
  font-size: .875rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
}
.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,.06);
  text-decoration: none;
}
.nav-item.active {
  color: #fff;
  background: rgba(33,84,255,.25);
  border-left-color: var(--primary);
}
.nav-item .nav-icon { width: 18px; text-align: center; font-size: 1rem; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: .65rem;
  padding: .1rem .45rem;
  border-radius: 20px;
  font-weight: 700;
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem 1.4rem;
  border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: .75rem;
  color: rgba(255,255,255,.7);
  font-size: .8rem;
}
.sidebar-user .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name { font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .user-role { font-size: .7rem; color: rgba(255,255,255,.4); }

/* Main content */
.main { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

/* Topbar */
.topbar {
  height: var(--topbar-h);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.75rem;
  gap: 1rem;
  position: sticky;
  top: 0; z-index: 50;
}
.topbar-title { font-size: 1.1rem; font-weight: 700; color: var(--text); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: .75rem; }

.btn-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  font-size: 1rem;
  transition: all var(--transition);
}
.btn-icon:hover { background: var(--primary-l); color: var(--primary); border-color: var(--primary); }

/* Page content */
.page { padding: 1.75rem; flex: 1; }

/* ── Cards ──────────────────────────────────────────────────── */

.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.5rem;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}
.card-title { font-size: 1rem; font-weight: 700; color: var(--text); }
.card-subtitle { font-size: .8rem; color: var(--muted); margin-top: .15rem; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
  display: flex;
  gap: 1rem;
  align-items: center;
}
.stat-icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-icon.blue   { background: #eff6ff; color: var(--primary); }
.stat-icon.green  { background: #ecfdf5; color: var(--success); }
.stat-icon.yellow { background: #fffbeb; color: var(--warning); }
.stat-icon.red    { background: #fef2f2; color: var(--danger); }
.stat-icon.purple { background: #f5f3ff; color: #7c3aed; }

.stat-value { font-size: 1.6rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-label { font-size: .78rem; color: var(--muted); margin-top: .2rem; }

/* ── Grid layouts ────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); color:#fff; text-decoration:none; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-success  { background: var(--success); color: #fff; }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-warning  { background: var(--warning); color: #fff; }
.btn-ghost    { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-l); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--bg); }
th { padding: .75rem 1rem; text-align: left; font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); }
td { padding: .75rem 1rem; font-size: .875rem; border-bottom: 1px solid var(--border); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 700;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-running  { background: #ecfdf5; color: var(--success); }
.badge-stopped  { background: #fef2f2; color: var(--danger);  }
.badge-pending  { background: #fffbeb; color: var(--warning); }
.badge-rescue   { background: #f0fdf4; color: #16a34a; }
.badge-admin    { background: #eff6ff; color: var(--primary); }
.badge-user     { background: #f5f3ff; color: #7c3aed; }
.badge-active   { background: #ecfdf5; color: var(--success); }
.badge-inactive { background: #f1f5f9; color: var(--muted); }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .8rem; font-weight: 600; color: var(--text); margin-bottom: .35rem; }
.form-control {
  width: 100%;
  padding: .6rem .9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  background: #fff;
  color: var(--text);
  transition: border var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary); }
.form-hint { font-size: .75rem; color: var(--muted); margin-top: .3rem; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }

/* ── Server card ─────────────────────────────────────────────── */
.server-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  transition: box-shadow var(--transition), transform var(--transition);
}
.server-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.server-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: .75rem; }
.server-name { font-weight: 700; font-size: .95rem; color: var(--text); }
.server-ip   { font-size: .78rem; color: var(--muted); font-family: var(--mono); margin-top: .15rem; }
.server-specs { display: flex; gap: .75rem; margin-top: .75rem; flex-wrap: wrap; }
.spec-chip {
  display: flex; align-items: center; gap: .3rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .25rem .6rem;
  font-size: .75rem;
  color: var(--muted);
}
.server-actions { display: flex; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }

/* ── Modals ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(11,18,32,.6);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
  background: var(--card);
  border-radius: 16px;
  width: 90%; max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
  transform: translateY(16px);
  transition: transform var(--transition);
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.modal-title { font-size: 1.15rem; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 1.3rem; color: var(--muted); padding: .25rem; line-height: 1; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert { padding: .85rem 1rem; border-radius: var(--radius-sm); font-size: .875rem; margin-bottom: 1rem; border-left: 4px solid; }
.alert-success { background: #f0fdf4; color: #15803d; border-color: var(--success); }
.alert-error   { background: #fef2f2; color: #dc2626; border-color: var(--danger); }
.alert-warning { background: #fffbeb; color: #92400e; border-color: var(--warning); }
.alert-info    { background: #eff6ff; color: #1d4ed8; border-color: var(--info); }

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; }
.tab {
  padding: .65rem 1.1rem;
  font-size: .875rem;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all var(--transition);
  background: none;
  border-top: none; border-left: none; border-right: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Sidebar toggle (mobile) ─────────────────────────────────── */
.sidebar-toggle {
  display: none;
  background: none; border: none;
  font-size: 1.3rem; color: var(--muted);
}

/* ── Dropdown ────────────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .4rem 0;
  min-width: 160px;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  display: none;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
  display: block;
  padding: .55rem 1rem;
  font-size: .875rem;
  color: var(--text);
  transition: background var(--transition);
}
.dropdown-item:hover { background: var(--bg); text-decoration: none; }
.dropdown-divider { height: 1px; background: var(--border); margin: .3rem 0; }

/* ── Loading / spinner ───────────────────────────────────────── */
.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: absolute; inset: 0;
  background: rgba(255,255,255,.8);
  display: flex; align-items: center; justify-content: center;
  border-radius: inherit;
  z-index: 10;
}

/* ── Terminal output ─────────────────────────────────────────── */
.terminal {
  background: #0d1117;
  color: #e6edf3;
  font-family: var(--mono);
  font-size: .8rem;
  padding: 1rem;
  border-radius: var(--radius-sm);
  line-height: 1.6;
  max-height: 300px;
  overflow-y: auto;
}
.terminal .line-ok   { color: #3fb950; }
.terminal .line-err  { color: #f85149; }
.terminal .line-warn { color: #d29922; }

/* ── Notifications toast ─────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: .6rem;
  z-index: 500;
}
.toast {
  background: var(--sidebar);
  color: #fff;
  padding: .75rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  display: flex; align-items: center; gap: .75rem;
  box-shadow: var(--shadow-lg);
  animation: toastin .25s ease;
  min-width: 240px;
  max-width: 360px;
}
.toast-success { border-left: 4px solid var(--success); }
.toast-error   { border-left: 4px solid var(--danger); }
.toast-info    { border-left: 4px solid var(--primary); }
@keyframes toastin { from { opacity:0; transform:translateX(20px); } to { opacity:1; transform:none; } }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-240px); width: 240px; }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .sidebar-toggle { display: flex; align-items: center; justify-content: center; width:38px;height:38px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page { padding: 1rem; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ── Utilities ───────────────────────────────────────────────── */
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.ml-auto { margin-left: auto; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-muted { color: var(--muted); }
.text-sm { font-size: .8rem; }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Unified admin/user VPS list */
.user-server-list-card .dropdown-menu { min-width: 210px; }
.user-server-list-card .table-wrap { overflow: visible; }
.user-server-list-card table { min-width: 1050px; }
.user-server-list-card tbody tr:hover { background: var(--bg-hover, #f8fafc); }

@media (max-width: 900px) {
  .user-server-list-header { align-items: flex-start; gap: .85rem; flex-direction: column; }
  .user-server-list-actions { width: 100%; }
  .user-server-list-actions .btn { width: 100%; justify-content: center; }
  .server-list-toolbar .d-flex { align-items: stretch !important; }
  .server-list-toolbar .form-group,
  .server-list-toolbar .btn { width: 100%; min-width: 0 !important; }
  .user-server-list-card .table-wrap { overflow: visible; }
  .user-server-list-card table,
  .user-server-list-card thead,
  .user-server-list-card tbody,
  .user-server-list-card th,
  .user-server-list-card td,
  .user-server-list-card tr { display: block; min-width: 0; width: 100%; }
  .user-server-list-card thead { display: none; }
  .user-server-list-card tbody { padding: .75rem; }
  .user-server-list-card tbody tr {
    border: 1px solid var(--border);
    border-radius: var(--radius, 10px);
    margin-bottom: .75rem;
    padding: .35rem .8rem;
    background: var(--card-bg, #fff);
  }
  .user-server-list-card tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    border: 0;
    border-bottom: 1px solid var(--border);
    padding: .7rem 0;
    text-align: right;
  }
  .user-server-list-card tbody td:last-child { border-bottom: 0; }
  .user-server-list-card tbody td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    text-align: left;
  }
  .user-server-list-card .dropdown-menu {
    position: fixed;
    right: 1rem;
    left: auto;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
  }
}
