:root {
  --bg-dark: #020617;
  --bg-card: #0f172a;
  --bg-sidebar: #0f172a;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --primary: #22c55e;
  --primary-hover: #16a34a;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --border: #1e293b;
  --sidebar-width: 260px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
}

/* Auth Page Specifics */
body.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top, #1e293b, #020617);
}

/* Sidebar */
#sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  z-index: 50;
}

.sidebar-header {
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, #0f172a, #1e293b);
}

/* Page Header */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* User Profile in Sidebar */
.user-profile-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.user-info-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.user-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid var(--primary);
  background-color: var(--bg-card);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.user-name {
  color: var(--text-primary);
  font-weight: 600;
  font-size: 14px;
  text-align: center;
}

.user-phone {
  color: var(--text-secondary);
  font-size: 10px; /* Smaller font as requested */
  font-weight: 400;
  text-align: center;
  opacity: 0.8;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: 8px;
  transition: all 0.2s;
  font-size: 14px;
  font-weight: 500;
}

.nav-item:hover, .nav-item.active {
  background-color: rgba(34, 197, 94, 0.1);
  color: var(--primary);
}

.nav-item i {
  width: 20px;
  text-align: center;
}

.sidebar-footer {
  padding: 24px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-secondary);
  font-size: 12px;
}

/* Main Content */
#main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 32px;
  width: calc(100% - var(--sidebar-width));
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
}

.page-title {
  font-size: 24px;
  font-weight: 600;
}

/* Cards */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
}

.card-body {
  /* Generic body container */
}

/* Buttons */
.btn {
  padding: 10px 20px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.2s;
  text-decoration: none;
}

.btn:hover {
  opacity: 0.9;
}

.btn-primary {
  background-color: var(--primary);
  color: #064e3b;
}

.btn-danger {
  background-color: var(--danger);
  color: white;
}

.btn-secondary {
  background-color: #334155;
  color: white;
}

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

/* Utilities */
.text-danger {
  color: var(--danger) !important;
}

.text-danger:hover {
  background-color: rgba(239, 68, 68, 0.1) !important;
  color: var(--danger-hover) !important;
}

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

.form-label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}

.form-input {
  width: 100%;
  padding: 12px;
  background-color: #1e293b;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
}

.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-switch .slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(148, 163, 184, 0.25);
  border: 1px solid rgba(148, 163, 184, 0.25);
  transition: 0.2s;
  border-radius: 999px;
}

.toggle-switch .slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  background-color: #e2e8f0;
  transition: 0.2s;
  border-radius: 999px;
}

.toggle-switch input:checked + .slider {
  background-color: rgba(34, 197, 94, 0.25);
  border-color: rgba(34, 197, 94, 0.35);
}

.toggle-switch input:checked + .slider:before {
  transform: translate(20px, -50%);
  background-color: var(--primary);
}

.toggle-switch input:focus + .slider {
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

.toggle-switch input:disabled + .slider {
  cursor: not-allowed;
  opacity: 0.65;
}

/* Lists */
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

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

/* Mobile Toggle */
.mobile-toggle {
  display: none;
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 100;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: 8px;
  color: var(--text-primary);
  cursor: pointer;
}

/* Status Badges */
.status-badge {
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
  display: inline-block;
}

/* QR Loading Spinner */
.qr-loading {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 4px solid rgba(148, 163, 184, 0.4);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
  #sidebar {
    transform: translateX(-100%);
  }
  
  #sidebar.active {
    transform: translateX(0);
  }
  
  #main-content {
    margin-left: 0;
    width: 100%;
    padding: 20px;
    padding-top: 80px; /* Space for top buttons */
  }
  
  .mobile-toggle {
    display: block;
  }

  .logout-top-right {
    top: 16px;
    right: 64px; /* Space for toggle */
    padding: 8px 12px;
  }
  
  .logout-top-right span {
    display: none; /* Hide text on mobile */
  }
}

/* Utilities */
.text-muted { color: var(--text-secondary); }
.text-center { text-align: center; }
.text-danger { color: var(--danger); }
.d-flex { display: flex; }
.gap-2 { gap: 8px; }
.justify-content-center { justify-content: center; }
.justify-content-end { justify-content: flex-end; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }

.logo-badge {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(34, 197, 94, 0.14);
  border: 1px solid rgba(34, 197, 94, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
}

.status {
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-secondary);
  border-radius: 12px;
  padding: 10px 12px;
}

.status-success {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.10);
  color: #86efac;
}

.status-error {
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.10);
  color: #fca5a5;
}

#login-message {
  margin-top: 16px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 200;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

.modal-close {
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-secondary);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  opacity: 0.9;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 24px;
  font-size: 14px;
  color: var(--text-secondary);
}

.breadcrumb-item {
  color: var(--text-secondary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.breadcrumb-item.active {
  color: var(--text-primary);
  font-weight: 500;
}

.breadcrumb-separator {
  color: var(--border);
}

.breadcrumb-item:hover:not(.active) {
  color: var(--primary);
}

/* Plan Card */
.plan-card {
  border: 1px solid var(--primary);
  background: linear-gradient(to bottom right, var(--bg-card), rgba(34, 197, 94, 0.05));
}

.plan-details {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.plan-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 24px;
}

.plan-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.plan-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  font-weight: 600;
}

.plan-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.plan-actions {
  display: flex;
  gap: 12px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

/* Table Styles */
.table-responsive {
  overflow-x: auto;
}

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

.table th {
  text-align: left;
  padding: 16px;
  color: var(--text-secondary);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
  vertical-align: middle;
}

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

.table tr:hover td {
  background-color: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge-success {
  background-color: rgba(34, 197, 94, 0.1);
  color: var(--primary);
  border-color: rgba(34, 197, 94, 0.2);
}

.badge-warning {
  background-color: rgba(234, 179, 8, 0.1);
  color: #fbbf24;
  border-color: rgba(234, 179, 8, 0.2);
}

.badge-danger {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.2);
}

/* Icon Buttons */
.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: all 0.2s;
}

.btn-icon:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.text-warning { color: #fbbf24; }
.text-primary { color: var(--primary); }

@media (max-width: 768px) {
  .plan-actions {
    flex-direction: column;
  }
  
  .plan-info-grid {
    grid-template-columns: 1fr;
  }
}

/* Documentation Styles */
.doc-section h2 {
  color: var(--text-primary);
  margin-top: 30px;
  font-size: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.endpoint {
  background: rgba(2, 6, 23, 0.5);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
  margin-top: 15px;
}

.method {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 4px;
  font-weight: bold;
  font-size: 14px;
  color: white;
}

.method.get { background-color: #4A8FD1; }
.method.post { background-color: #3DAA78; }
.method.put { background-color: #D48828; }
.method.patch { background-color: #3FBFA4; }
.method.delete { background-color: #D73232; }

.url {
  font-family: monospace;
  font-size: 16px;
  margin-left: 10px;
  color: var(--text-secondary);
  font-weight: 500;
}

.code-block {
  background: #020617;
  color: #cbd5e1;
  padding: 15px;
  border-radius: 6px;
  overflow-x: auto;
  font-family: 'Courier New', Courier, monospace;
  font-size: 14px;
  margin-top: 10px;
  white-space: pre;
  border: 1px solid var(--border);
}

.api-key-box {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 30px;
  word-break: break-all;
}

.api-key-label {
  font-weight: bold;
  margin-bottom: 8px;
  display: block;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.copy-btn, .regenerate-btn {
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  margin-top: 12px;
  font-weight: 500;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: white;
}

.copy-btn { background: #3b82f6; }
.copy-btn:hover { background: #2563eb; }

.regenerate-btn { background: #f59e0b; margin-left: 10px; }
.regenerate-btn:hover { background: #d97706; }

.sensitive-warning {
  display: flex;
  align-items: center;
  gap: 12px;
  background-color: rgba(234, 179, 8, 0.1);
  color: #fbbf24;
  border: 1px solid rgba(234, 179, 8, 0.2);
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 15px;
  font-size: 14px;
}

.doc-section h3 {
  font-size: 1.1rem;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.doc-section h4 {
  font-size: 1rem;
  margin-top: 1rem;
  color: var(--text-secondary);
}

.doc-section ul {
  margin-top: 0.5rem;
  padding-left: 1.5rem;
  color: var(--text-secondary);
}

.doc-section li { margin-bottom: 0.25rem; }
