/* VPN Self-Hosted Panel v2 — Production Styles */
:root {
  --bg: #0f1117;
  --bg-card: #1a1d27;
  --bg-sidebar: #141720;
  --bg-input: #232736;
  --border: #2a2e3d;
  --text: #e4e6eb;
  --text-dim: #8b8fa3;
  --accent: #FF6B35;
  --accent-hover: #FF8555;
  --success: #00b894;
  --warning: #fdcb6e;
  --danger: #e17055;
  --info: #74b9ff;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Inter', -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; background: var(--bg-sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; height: 100vh; z-index: 100;
}
.sidebar-logo { padding: 20px; font-size: 18px; font-weight: 700; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.sidebar-logo span { color: var(--accent); }
.sidebar-nav { flex: 1; padding: 12px; overflow-y: auto; }
.nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-dim);
  padding: 14px 12px 6px;
  opacity: 0.75;
}
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--radius-sm);
  color: var(--text-dim); cursor: pointer; transition: all 0.2s; font-size: 14px; margin-bottom: 2px;
}
.nav-item:hover { background: var(--bg-input); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-item .badge {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 11px;
  padding: 2px 7px; border-radius: 10px; min-width: 20px; text-align: center;
}
.sidebar-footer { padding: 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-dim); }

.main {
  flex: 1; margin-left: 240px;
  background-image: url('/img/fox-bg/fox-pattern.svg');
  background-repeat: repeat;
  background-size: 400px 400px;
  background-attachment: fixed;
}
.topbar {
  height: 60px; border-bottom: 1px solid var(--border); display: flex;
  align-items: center; justify-content: space-between; padding: 0 24px; background: var(--bg-sidebar);
}
.topbar-meta { display: flex; flex-direction: column; gap: 2px; }
.topbar-subtitle {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.topbar-title { font-size: 18px; font-weight: 600; }
.topbar-actions { display: flex; gap: 12px; align-items: center; }

/* Mobile menu toggle */
.menu-toggle {
  display: none; position: fixed; top: 12px; left: 12px; z-index: 200;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 12px; cursor: pointer; color: var(--text);
}
.menu-toggle:hover { background: var(--bg-input); }

.content { padding: 24px; }

/* Cards */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-label { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-change { font-size: 12px; margin-top: 4px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }
.text-muted { color: var(--text-dim); }

.card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 20px; overflow: hidden;
}
.card-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-header h3 { font-size: 16px; font-weight: 600; }
.card-body { padding: 20px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--text-dim); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; }
tr:hover td { background: rgba(255,107,53,0.05); }
tr:last-child td { border-bottom: none; }

/* Badges */
.badge { display: inline-block; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.badge-success { background: rgba(0,184,148,0.15); color: var(--success); }
.badge-warning { background: rgba(253,203,110,0.15); color: var(--warning); }
.badge-danger { background: rgba(225,112,85,0.15); color: var(--danger); }
.badge-info { background: rgba(116,185,255,0.15); color: var(--info); }
.badge-neutral { background: var(--bg-input); color: var(--text-dim); }

/* Buttons */
.btn {
  padding: 8px 16px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-input); color: var(--text); cursor: pointer; font-size: 13px;
  transition: all 0.2s; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px 8px; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
input[type="text"], input[type="password"], input[type="number"], input[type="email"],
select, textarea {
  width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 14px; outline: none; transition: border 0.2s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }

/* Modal */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.6);
  display: none; align-items: center; justify-content: center; z-index: 1000;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  width: 90%; max-width: 560px; max-height: 80vh; overflow-y: auto;
}
.modal.modal-wide {
  width: 96%;
  max-width: 1200px;
}
.modal-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; }
.modal-close { cursor: pointer; color: var(--text-dim); font-size: 20px; background: none; border: none; }
.modal-body { padding: 20px; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* Tabs */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 10px 16px; cursor: pointer; font-size: 14px; color: var(--text-dim);
  border-bottom: 2px solid transparent; transition: all 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Ticket chat */
.ticket-chat { max-height: 400px; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.chat-msg { max-width: 80%; padding: 10px 14px; border-radius: 12px; font-size: 14px; line-height: 1.5; }
.chat-msg.user { background: var(--bg-input); align-self: flex-start; border-bottom-left-radius: 4px; }
.chat-msg.admin { background: var(--accent); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-msg .meta { font-size: 11px; color: var(--text-dim); margin-top: 4px; }
.chat-msg.admin .meta { color: rgba(255,255,255,0.7); }
.chat-attachment {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.08);
  font-size: 12px;
}
.chat-msg.admin .chat-attachment {
  background: rgba(255, 255, 255, 0.18);
}
.chat-attachment-preview {
  display: none;
  margin-top: 10px;
}
.chat-attachment-preview.open {
  display: block;
}
.chat-attachment-preview img {
  width: 100%;
  max-width: 360px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* Progress bar */
.progress { height: 6px; background: var(--bg-input); border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s; }
.progress-bar.warning { background: var(--warning); }
.progress-bar.danger { background: var(--danger); }

/* Toast */
.toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 12px 20px; border-radius: var(--radius-sm); color: #fff; font-size: 14px;
  animation: slideIn 0.3s ease; box-shadow: var(--shadow);
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Empty state */
.empty-state { text-align: center; padding: 40px; color: var(--text-dim); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 12px; opacity: 0.5; }

/* Responsive */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 16px; }
  .modal { max-width: 90%; }
}

@media (max-width: 768px) {
  .menu-toggle { display: block; }
  .sidebar {
    width: 240px; transform: translateX(-100%); transition: transform 0.3s;
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .topbar { padding-left: 60px; }
  .stats-grid { grid-template-columns: 1fr; }
  .card-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters select, .filters input { width: 100%; }
  table { font-size: 12px; display: block; overflow-x: auto; white-space: nowrap; }
  th, td { padding: 8px 10px; }
  .modal { max-width: 95%; padding: 16px; }
  .modal-body { max-height: 70vh; overflow-y: auto; }
  .chat-msg { max-width: 90%; }
  .form-group { margin-bottom: 12px; }
  .form-group input, .form-group select, .form-group textarea { font-size: 16px; }
  .btn { padding: 10px 16px; font-size: 14px; }
}

@media (max-width: 480px) {
  .topbar { padding: 0 12px 0 50px; }
  .topbar-title { font-size: 16px; }
  .content { padding: 12px; }
  .card-body { padding: 12px; }
  .stat-card { padding: 14px; }
  .stat-value { font-size: 22px; }
  .login-box { padding: 24px; }
  table { font-size: 11px; }
  th, td { padding: 6px 8px; }
}

/* Login page */
.login-page {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: var(--bg) url('/img/fox-bg/fox-pattern.svg') repeat;
  background-size: 400px 400px;
}
.login-box {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 40px; width: 100%; max-width: 400px;
}
.login-box h2 { margin-bottom: 24px; text-align: center; }
.login-box .btn { width: 100%; justify-content: center; margin-top: 8px; }

/* Pagination */
.pagination { display: flex; gap: 4px; align-items: center; margin-top: 16px; justify-content: center; }
.pagination .btn { min-width: 36px; justify-content: center; }
.pagination .btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Search */
.search-box { position: relative; }
.search-box input { padding-left: 36px; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-dim); width: 16px; }

/* Filters */
.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filters select { width: auto; min-width: 140px; }

/* QoE trends */
.qoe-trends {
  min-width: 170px;
}
.qoe-trend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.qoe-trend-row:last-child {
  margin-bottom: 0;
}
.qoe-trend-label {
  font-size: 11px;
  color: var(--text-dim);
  min-width: 56px;
}
.qoe-sparkline-svg {
  width: 148px;
  height: 28px;
  display: block;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.01);
}
.qoe-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.qoe-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 12px;
}
.qoe-legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.qoe-detail-chart {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.01);
}
.qoe-detail-chart-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.qoe-detail-chart svg {
  width: 100%;
  height: 220px;
  display: block;
}
