:root {
  --bg: #ffffff; /* Pure white background */
  --bg-2: #f9fafb; /* Soft off-white for secondary elements */
  --panel: rgba(255, 255, 255, 0.85); /* Semi-transparent white panels for depth */
  --panel-strong: rgba(255, 255, 255, 0.95); /* Stronger white for emphasis */
  --border: rgba(0, 0, 0, 0.08); /* Subtle dark borders for contrast */
  --fg: #353535; /* Deep black foreground text for readability */
  --muted: #6b7280; /* Muted gray for secondary text */
  --primary: #00b300; /* Keeping neon green for Web3 vibe, but can adjust if needed */
  --primary-2: #008000; /* Deeper green variant */
  --success: #00ff88;
  --error: #ff4d4d;
  --radius: 16px; /* Slightly larger radius for modern, rounded feel */
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.08); /* Softer shadows for elevation */
  --blur: blur(16px); /* Increased blur for glassy, modern effect */
  --grad: linear-gradient(135deg, var(--primary), var(--primary-2)); /* Gradient for accents */
}

:root.dark {
  --bg: #121212; /* Dark background */
  --bg-2: #1e1e1e; /* Darker secondary elements */
  --panel: rgba(30, 30, 30, 0.85); /* Semi-transparent dark panels */
  --panel-strong: rgba(30, 30, 30, 0.95); /* Stronger dark for emphasis */
  --border: rgba(255, 255, 255, 0.08); /* Subtle light borders for contrast */
  --fg: #e0e0e0; /* Light foreground text for readability */
  --muted: #a0a0a0; /* Muted light gray for secondary text */
  --primary: #00b300; /* Keep primary green */
  --primary-2: #008000; /* Keep deeper green */
  --success: #00ff88;
  --error: #ff4d4d;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.12); /* Adjusted shadows for dark mode */
  --grad: linear-gradient(135deg, var(--primary), var(--primary-2)); /* Keep gradient */
}

*,
*:before,
*:after{
  box-sizing: border-box;
}

body {
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(900px 600px at 85% -10%, rgba(0, 255, 136, 0.06), transparent 60%),
    radial-gradient(900px 700px at -10% 110%, rgba(0, 255, 136, 0.06), transparent 60%),
    var(--bg); /* White base with subtle green glow for Web3 futurism */
  color: var(--fg);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  letter-spacing: .01em;
}

/* Dark mode background adjustment */
:root.dark body {
  background:
    radial-gradient(900px 600px at 85% -10%, rgba(0, 255, 136, 0.12), transparent 60%),
    radial-gradient(900px 700px at -10% 110%, rgba(0, 255, 136, 0.12), transparent 60%),
    var(--bg); /* Darker base with adjusted glow */
}

/* Layout */
.container {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 200px;
  background: linear-gradient(180deg, var(--panel-strong), var(--panel));
  padding-left: 20px;
  padding-right: 20px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  box-shadow: var(--shadow);
}

.sidebar-logo {
  width: 150px;
  margin-bottom: 20px;
  padding: 20px;
  border-radius: 12px;
}

.sidebar-link {
  display: block;
  color: var(--fg);
  text-decoration: none;
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 10px;
  border: 1px solid transparent;
  transition: all .18s ease;
}

.sidebar-link:hover {
  background-color: rgba(0, 255, 136, 0.08);
  border-color: var(--border);
}

.sidebar-link.active {
  background: var(--grad);
  color: #ffffff;
  font-weight: 700;
}

/* Logout Button */
.logout {
  margin-top: auto;
  background: var(--grad);
  color: #ffffff;
  padding: 10px 20px;
  margin-bottom: 20px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  transition: transform .04s ease, opacity .2s ease;
}

.logout:hover { opacity: .92; }
.logout:active { transform: translateY(1px); }

/* Hamburger */
.hamburger-menu {
  display: none;
  flex-direction: column;
  justify-content: space-around;
  width: 30px;
  height: 30px;
  padding: 10px;
  cursor: pointer;
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 100;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  backdrop-filter: var(--blur);
}

.hamburger-menu span {
  width: 30px;
  height: 4px;
  background-color: var(--fg);
  border-radius: 2px;
}

/* Mobile Menu */
.mobile-menu {
  display: none;
  position: fixed;
  top: 60px;
  left: 0;
  width: 100%;
  background: linear-gradient(180deg, var(--panel-strong), var(--panel));
  padding: 20px;
  z-index: 99;
  border-bottom: 1px solid var(--border);
  flex-direction: column;
  backdrop-filter: var(--blur);
}

.mobile-menu.active { display: flex; }

.mobile-menu .sidebar-link {
  display: block;
  color: var(--fg);
  text-decoration: none;
  padding: 10px;
  margin-bottom: 10px;
  border-radius: 10px;
}

.mobile-menu .sidebar-link:hover { background-color: rgba(0, 255, 136, 0.08); }

.mobile-menu .sidebar-link.active { background: var(--grad); color: #00170c; }

.mobile-menu .logout { margin-top: auto; }

/* Auth / Dashboard Containers */
.login-container {
  background: var(--panel);
  padding: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 400px;
  text-align: center;
  margin: auto;
  vertical-align: middle;
}

.dashboard-container, .usage-container, .key-endpoints-container, .settings-container, .plan-billing-container {
  background: var(--panel);
  padding: 40px;
  width: 100%;
  max-width: 1000px;
  margin-left: 200px;
  flex-grow: 1;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.dashboard-content, .settings-content {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 20px;
  text-align: center;
}

.usage-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 20px;
}

.dashboard-left, .dashboard-right, .settings-left, .settings-right { width: 500px; }

.settings-left, .settings-right { flex: 1; }

/* Cards */
.plan-details, .credit-usage, .credit-usage-graph, .api-usage, .websocket-usage, .widget-usage, .endpoint-box {
  background: var(--bg-2); /* Off-white cards for subtle layering */
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 20px;
  border: 1px solid var(--border); /* Added subtle border for definition */
  min-height: 180px;
}

.settings-box {
  background: var(--bg-2); /* Off-white cards for subtle layering */
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 20px;
  border: 1px solid var(--border); /* Added subtle border for definition */
  min-height: 430px;
}

.settings-box-support{
  background: var(--bg-2); /* Off-white cards for subtle layering */
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 20px;
  border: 1px solid var(--border); /* Added subtle border for definition */
  justify-content: center;
  text-align: center;
}

.plan-details p { text-align: center; }

/* Keep original adjacent-spacing rules */
.credit-usage-graph + .api-usage,
.credit-usage-graph + .websocket-usage,
.api-usage + .widget-usage { margin-top: 0; }

/* Toggle Buttons */
.toggle-buttons {
  margin-bottom: 15px;
  display: flex;
  justify-content: center;
  gap: 10px;
}

.toggle-button {
  padding: 8px 15px;
  background: var(--grad);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  transition: transform .04s ease, opacity .2s ease;
}

.toggle-button:hover { opacity: .92; }

.toggle-button.active {
  background-color: black;
}

/* Dark mode toggle button adjustments */
:root.dark .toggle-button.active {
  background-color: #ffffff;
  color: #121212;
}

/* Headings */
h1 {
  color: var(--fg);
  margin-bottom: 20px;
  font-weight: 800;
  letter-spacing: .2px;
  text-shadow: 0 0 18px rgba(0, 255, 136, 0.12); /* Subtle glow for Web3 feel */
}

h2 {
  color: #353535;
  margin-bottom: 15px;
  font-size: 1.5em;
  font-weight: 800;
}

/* Dark mode heading adjustments */
:root.dark h2 {
  color: var(--fg);
}

/* Forms */
form { display: flex; flex-direction: column; gap: 15px; }

label { color: var(--muted); text-align: left; }

input, select {
  padding: 12px 14px;
  background-color: var(--bg-2); /* Off-white inputs */
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 255, 136, 0.16);
}

/* Generic buttons */
button {
  padding: 10px;
  background: var(--grad);
  color: #ffffff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  transition: transform .04s ease, opacity .2s ease;
}

button:hover { opacity: .92; }

button:active { transform: translateY(1px); }

/* Hints */
.param-hint { color: #9fb3aa; font-size: 12px; }

/* Dark mode hint adjustments */
:root.dark .param-hint { color: #7a8f86; }

/* API Key */
.api-key-section {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-direction: column;
  text-align: center;
}

.api-key-label { text-align: center; width: 100%; color: var(--muted); }

.api-key-section input { width: 400px; max-width: 80%; }

/* Endpoints */
.endpoint-box { margin-bottom: 20px; }

.endpoint-form {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.endpoint-form-content {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.endpoint-url {
  flex-grow: 1;
  max-width: 400px;
  padding: 12px 14px;
  background-color: var(--bg-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 16px;
  outline: none;
}

.endpoint-url:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(0, 255, 136, 0.16);
}

.param-container {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
  min-width: 150px;
}

.test-button {
  background: var(--grad);
  color: #ffffff;
  font-weight: 700;
  border-radius: 12px;
  flex-shrink: 0;
  padding: 10px 16px;
  transition: transform .04s ease, opacity .2s ease;
}

.test-button:hover { opacity: .92; }

.test-button:active { transform: translateY(1px); }

/* Results */
.endpoint-result {
  color: var(--fg);
  border-radius: 12px;
  padding: 12px;
  word-break: break-all;
}

/* Credit usage area */
.credit-usage {
  text-align: center;
}

.credit-count { font-weight: 800; font-size: 1.2em; margin: 10px 0; }

.credit-label { font-size: 0.9em; margin: 5px 0; color: var(--muted); }

/* Tables */
table {
  width: 100%;
  margin-top: 20px;
  border-collapse: separate;
  border-spacing: 0 8px;
}

th, td {
  padding: 10px;
  text-align: left;
  color: var(--fg);
}

th { font-weight: 800; color: #353535; }

/* Dark mode table headings */
:root.dark th { color: var(--fg); }

tbody tr {
  background-color: var(--bg-2);
  border: 1px solid var(--border);
}

tbody tr td:first-child { border-top-left-radius: 12px; border-bottom-left-radius: 12px; }

tbody tr td:last-child { border-top-right-radius: 12px; border-bottom-right-radius: 12px; }

/* Canvas / charts */
canvas {
  margin-top: 20px;
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.01)); /* Subtle gradient for charts */
  border-radius: 12px;
}

/* Dark mode canvas */
:root.dark canvas {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01));
}

/* Alerts */
.error { color: var(--error); margin-bottom: 10px; font-weight: 700; }

.success { color: var(--success); margin-bottom: 10px; font-weight: 700; }

/* Plan & Billing */
.plan-billing-container { text-align: center; }

.current-plan p { font-size: 1.5em; font-weight: 700; margin-bottom: 30px; }

.plans-container {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.plan-box {
  background: var(--bg-2);
  border-radius: var(--radius);
  padding: 20px;
  width: 290px;
  text-align: center;
  box-shadow: var(--shadow);
  border: 1px solid var(--border); /* Added for consistency */
}

.plan-box h2 { font-size: 1.8em; }

.plan-box h3 { color: var(--primary); font-size: 1.5em; }

.plan-box ul { list-style: none; padding: 0; }

.plan-box li { margin-bottom: 10px; }

.plan-box button { margin-top: 15px; }

/* Payment History Table */
table { margin-top: 20px; }

/* Responsive Design */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .hamburger-menu { display: flex; height: 50px; width: 50px; }
  .dashboard-container, .usage-container, .key-endpoints-container, .settings-container, .plan-billing-container {
    max-width: 90%;
    margin-left: 0;
  }
  .dashboard-content, .usage-content, .settings-content {
    flex-direction: column;
    align-items: stretch;
  }
  .dashboard-left, .dashboard-right, .settings-left, .settings-right { width: 100%; }
  .usage-content .api-usage, .usage-content .websocket-usage, .usage-content .widget-usage {
    width: 100%;
  }
  .toggle-buttons { flex-wrap: wrap; }
  .api-key-section input { width: 100%; }
  .endpoint-form { flex-direction: column; }
}

/* Adjustments for usage boxes in dashboard and usage */
.usage-boxes {
  display: flex;
  flex-direction: row;
  gap: 20px;
  justify-content: space-between;
  width: 100%; /* Full width */
}

.widget-usage, .websocket-usage, .rest-api-usage {
  background: var(--bg-2); /* Consistent off-white */
  flex: 1; /* Equal width */
  border-radius: var(--radius);
  padding: 15px;
  margin-bottom: 20px;
  border: 1px solid var(--border); /* Added for modern outline */
}

/* For usage.html - wrap the three sections in a flex container */
.usage-content .usage-boxes {
  display: flex;
  flex-direction: row;
  gap: 20px;
  justify-content: space-between;
  width: 100%; /* Full width */
}

/* Dark Mode Toggle Switch Styles */
.switch {
  position: relative;
  width: 60px;
  height: 30px;
  border-radius: 15px;
  overflow: hidden;
  align-self: center;
  margin-top: auto;
  margin-bottom: 10px;
}

.switch__label {
  display: block;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(149deg, #00b300, #008000);
  border: 2px solid green;
  border-radius: 15px;
  transition: background-color .25s ease;
  cursor: pointer;
}

.switch__label::after {
  content: '';
  display: block;
  box-sizing: border-box;
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  background: #ffffff;
  border-radius: 15px;
  transition: left .25s ease, background-color .25s ease;
}

.switch__checkbox:checked + .switch__label {
  background-color: #498FFF;
}

.switch__checkbox:checked + .switch__label::after {
  left: 32px;
  background-color: #fff;
}

.switch__checkbox {
  position: absolute;
  left: -20px;
}

/* Dark mode adjustments for toggle switch */
:root.dark .switch__label {
  background-color: #121212;
  border: 2px solid #000000;
}

:root.dark .switch__label::after {
  background: #498FFF;
}

:root.dark .switch__checkbox:checked + .switch__label {
  background-color: #498FFF;
}

:root.dark .switch__checkbox:checked + .switch__label::after {
  background-color: #121212;
}