/* =============================================================================
   Hostingowy — Dashboard Styles
   Dark mode, mobile responsiveness, and dashboard-specific enhancements
   ============================================================================= */

/* ── CSS Custom Properties (Light Default) ──────────────────────────────── */
:root {
  --bg-body: #f5f5f7;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-dark: #f0f0f2;
  --bg-hover: #e8e8eb;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-muted: #86868b;
  --border: #d2d2d7;
  --border-light: #e5e5ea;
  --accent: #0071e3;
  --accent-hover: #0060c0;
  --accent-secondary: #5e5ce6;
  --danger: #ff3b30;
  --success: #34c759;
  --warning: #ff9500;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --sidebar-width: 240px;
  --header-height: 64px;
  --transition: 0.2s ease;
}

/* ── Dark Mode ──────────────────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg-body: #1c1c1e;
  --bg-card: #2c2c2e;
  --bg-sidebar: #1c1c1e;
  --bg-dark: #3a3a3c;
  --bg-hover: #3a3a3c;
  --text-primary: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-muted: #8e8e93;
  --border: #48484a;
  --border-light: #3a3a3c;
  --accent: #0a84ff;
  --accent-hover: #409cff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
}

/* ── Dashboard Layout ───────────────────────────────────────────────────── */
.dash-layout {
  display: flex;
  min-height: 100vh;
  background: var(--bg-body);
  transition: background var(--transition);
}

.dash-sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  transition: background var(--transition), border-color var(--transition), transform 0.3s ease;
  overflow-y: auto;
}

.dash-sidebar .logo {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 24px;
  display: block;
  color: var(--text-primary);
  text-decoration: none;
}

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

.dash-sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.9375rem;
  font-weight: 500;
  transition: all var(--transition);
  text-decoration: none;
}

.dash-sidebar nav a:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.dash-sidebar nav a.active {
  background: var(--accent);
  color: #fff;
}

/* ── Main Content Area ──────────────────────────────────────────────────── */
.dash-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 24px 32px;
  padding-top: calc(var(--header-height) + 24px);
  min-height: 100vh;
  transition: margin-left 0.3s ease, padding var(--transition);
}

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

.dash-header h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
}

.dash-header .user-info {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 2px;
}

/* ── Tab Navigation ─────────────────────────────────────────────────────── */
.dash-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.dash-tabs::-webkit-scrollbar { display: none; }

.dash-tab {
  padding: 10px 18px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  user-select: none;
}

.dash-tab:hover {
  color: var(--text-primary);
}

.dash-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* ── Tab Content ────────────────────────────────────────────────────────── */
.tab-content {
  display: none;
  animation: fadeIn 0.2s ease;
}

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

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

.tab-content h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

/* ── Dashboard Grid / Cards ─────────────────────────────────────────────── */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.dash-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  transition: all var(--transition);
}

.dash-card:hover {
  box-shadow: var(--shadow-sm);
}

.card-label {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.card-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 4px;
}

.card-sub {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

/* ── Quick Actions ──────────────────────────────────────────────────────── */
.quick-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.quick-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.quick-action-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

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

.quick-action-btn.primary:hover {
  background: var(--accent-hover);
}

/* ── Service Table ──────────────────────────────────────────────────────── */
.service-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.service-table thead th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.service-table tbody td {
  padding: 12px;
  font-size: 0.875rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

.service-table tbody tr:hover {
  background: var(--bg-hover);
}

.service-table tbody tr:last-child td {
  border-bottom: none;
}

/* ── Status Badges ──────────────────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 100px;
  background: var(--bg-dark);
  color: var(--text-muted);
}

.status-badge.status-active {
  background: rgba(52, 199, 89, 0.15);
  color: var(--success);
}

.status-badge.status-pending {
  background: rgba(255, 149, 0, 0.15);
  color: var(--warning);
}

/* ── Progress Bar ───────────────────────────────────────────────────────── */
.progress-bar {
  background: var(--bg-dark);
  border-radius: 100px;
  overflow: hidden;
  height: 8px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 100px;
  transition: width 0.5s ease;
}

/* ── Notifications ──────────────────────────────────────────────────────── */
.notif-bell {
  position: relative;
  cursor: pointer;
  padding: 4px;
}

.notif-badge {
  position: absolute;
  top: -2px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notif-panel {
  position: absolute;
  top: 100%;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  width: 360px;
  max-height: 400px;
  overflow-y: auto;
  display: none;
  z-index: 200;
  margin-top: 8px;
}

.notif-panel.open {
  display: block;
}

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

.notif-panel-header h4 {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-primary);
}

.notif-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--transition);
}

.notif-item:hover {
  background: var(--bg-hover);
}

.notif-item.unread {
  background: rgba(0, 113, 227, 0.05);
}

.notif-item:last-child {
  border-bottom: none;
}

.notif-empty {
  padding: 32px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

/* ── Onboarding ─────────────────────────────────────────────────────────── */
.onboarding-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 24px;
}

.onboarding-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 0;
}

.step-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.step-icon.pending {
  background: var(--bg-dark);
  color: var(--text-muted);
}

.step-icon.done {
  background: var(--success);
  color: #fff;
}

/* ── Auth Card ──────────────────────────────────────────────────────────── */
.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  max-width: 440px;
  margin: 0 auto;
  box-shadow: var(--shadow-md);
}

.auth-card h2 {
  text-align: center;
  margin-bottom: 4px;
}

.auth-card .subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 24px;
}

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-body);
  color: var(--text-primary);
  font-size: 0.9375rem;
  transition: border-color var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

select.form-input {
  cursor: pointer;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 20px;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1.2;
}

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

.btn-primary:hover, .btn:hover:not(.btn-outline) {
  background: var(--accent-hover);
  box-shadow: var(--shadow-sm);
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-primary);
}

.btn-outline:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8125rem;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-ghost {
  background: transparent;
  border: none;
  color: var(--accent);
}

.btn-ghost:hover {
  text-decoration: underline;
}

/* ── Resource Charts Container ──────────────────────────────────────────── */
.resource-charts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 768px) {
  .resource-charts {
    grid-template-columns: 1fr;
  }
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

.chart-card h4 {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
}

.chart-card canvas {
  width: 100% !important;
  height: 180px !important;
}

/* ── Theme Toggle ───────────────────────────────────────────────────────── */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--bg-dark);
  border: 1px solid var(--border);
  border-radius: 100px;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  transition: all var(--transition);
  user-select: none;
}

.theme-toggle:hover {
  background: var(--bg-hover);
}

.theme-toggle .toggle-icon {
  font-size: 1rem;
}

/* ── Mobile Sidebar Toggle ─────────────────────────────────────────────── */
.mobile-sidebar-toggle {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  cursor: pointer;
  font-size: 1.25rem;
  color: var(--text-primary);
}

@media (max-width: 768px) {
  .mobile-sidebar-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
  }
}

/* ── Mobile Responsive ──────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .dash-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .dash-sidebar {
    transform: translateX(-100%);
  }

  .dash-sidebar.open {
    transform: translateX(0);
  }

  .dash-main {
    margin-left: 0;
    padding: 16px;
    padding-top: calc(var(--header-height) + 16px);
  }

  .dash-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .dash-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .dash-header h1 {
    font-size: 1.375rem;
  }

  .dash-tabs {
    gap: 0;
    margin-bottom: 16px;
  }

  .dash-tab {
    padding: 8px 12px;
    font-size: 0.8125rem;
  }

  .dash-card {
    padding: 16px;
  }

  .card-value {
    font-size: 1.5rem;
  }

  .service-table {
    font-size: 0.8125rem;
  }

  .service-table thead th,
  .service-table tbody td {
    padding: 8px;
  }

  .notif-panel {
    width: 300px;
    right: -60px;
  }

  .resource-charts {
    grid-template-columns: 1fr;
  }

  .quick-actions {
    gap: 8px;
  }

  .quick-action-btn {
    padding: 8px 14px;
    font-size: 0.8125rem;
  }

  .auth-card {
    padding: 24px;
    margin: 0 8px;
  }
}

@media (max-width: 480px) {
  .dash-main {
    padding: 12px;
    padding-top: calc(var(--header-height) + 12px);
  }

  .dash-tab {
    padding: 6px 10px;
    font-size: 0.75rem;
  }

  .dash-card {
    padding: 12px;
  }

  .card-value {
    font-size: 1.25rem;
  }
}

/* ── Scrollbar Styling ──────────────────────────────────────────────────── */
.dash-main::-webkit-scrollbar { width: 6px; }
.dash-main::-webkit-scrollbar-track { background: transparent; }
.dash-main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.dash-main::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Toast Notifications ────────────────────────────────────────────────── */
#dashToast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text-primary);
  color: var(--bg-body);
  padding: 12px 24px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.3s ease;
}

/* ── Private Networks ──────────────────────────────────────────────── */
.network-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.network-card {
  padding: 20px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.network-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.network-card h4 {
  margin: 0;
  font-size: 1rem;
}

/* Network detail modal */
#networkDetailContent .dash-card {
  padding: 16px;
}

/* Server list in network detail */
#networkDetailContent .status-badge {
  font-size: 0.75rem;
  padding: 2px 10px;
}
