/* Global Variables & Colors */
:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #121829;
  --accent-cyan: #06b6d4;
  --accent-blue: #3b82f6;
  --accent-purple: #8b5cf6;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --glass-bg: rgba(255, 255, 255, 0.04);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glow-shadow: 0 0 20px rgba(6, 182, 212, 0.3);
  --transition-speed: 0.25s;
}

/* Reset and Base Styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

/* Ambient Ambient Light Blobs */
.blob {
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  filter: blur(120px);
  z-index: 0;
  opacity: 0.25;
  pointer-events: none;
}

.blob-blue {
  background: var(--accent-blue);
  top: -10%;
  left: -10%;
  animation: float-blob 20s infinite alternate ease-in-out;
}

.blob-purple {
  background: var(--accent-purple);
  bottom: -10%;
  right: -10%;
  animation: float-blob 25s infinite alternate-reverse ease-in-out;
}

@keyframes float-blob {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(80px, 50px) scale(1.2); }
}

/* App Main Container */
#app-container {
  width: 100%;
  max-width: 1200px;
  min-height: 85vh;
  margin: 2rem;
  z-index: 10;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Shared Premium Card Styling */
.card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  padding: 2.5rem;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  transition: all var(--transition-speed) ease;
}

/* Login Panel */
#login-section {
  width: 100%;
  max-width: 480px;
}

#login-section.hidden, #dashboard-section.hidden {
  display: none !important;
}

.header-container {
  text-align: center;
  margin-bottom: 2rem;
}

.brand-logo-login {
  width: 90px;
  height: 90px;
  border-radius: 18px;
  margin-bottom: 1.2rem;
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.glow-text {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 300;
}

/* Input & Form Styling */
.form-group {
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
}

label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.val-display {
  color: var(--accent-cyan);
  font-family: monospace;
  font-size: 1rem;
}

input[type="text"], input[type="password"], input[type="number"] {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text-main);
  outline: none;
  width: 100%;
  min-width: 0;
  transition: all var(--transition-speed) ease;
}

input[type="text"]:focus, input[type="password"]:focus, input[type="number"]:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.2);
  background: rgba(0, 0, 0, 0.4);
}

/* HTML5 Range Sliders Custom Tuning */
input[type="range"] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 8px var(--accent-cyan);
  transition: transform 0.1s ease;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Button Custom Designing */
.glow-btn {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-purple));
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.95rem 1.5rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
  transition: all var(--transition-speed) ease;
  position: relative;
  overflow: hidden;
}

.glow-btn:hover {
  box-shadow: 0 6px 20px rgba(6, 182, 212, 0.6);
  transform: translateY(-2px);
}

.glow-btn:active {
  transform: translateY(1px);
}

.sec-btn {
  background: transparent;
  color: var(--text-main);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
}

.sec-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--text-muted);
}

/* Dashboard Section Layout */
#dashboard-section {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 0.5rem;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-logo-dash {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.logo-text {
  font-weight: 800;
  font-size: 1.8rem;
  letter-spacing: 3px;
  background: linear-gradient(135deg, var(--text-main), var(--text-muted));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge {
  font-size: 0.75rem;
  vertical-align: middle;
  background: var(--accent-cyan);
  -webkit-text-fill-color: #000;
  color: #000;
  font-weight: 800;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  margin-left: 0.5rem;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-role {
  font-size: 0.85rem;
  color: var(--accent-cyan);
  border: 1px solid rgba(6, 182, 212, 0.3);
  padding: 0.25rem 0.65rem;
  border-radius: 30px;
}

/* Grid Layout definitions */
.dashboard-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1.5rem;
  align-items: stretch;
}

.sidebar {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sidebar h2 {
  font-size: 1.15rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 0.75rem;
  margin-bottom: 0.5rem;
}

.level-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  max-height: 60vh;
}

/* Level Item Card Buttons */
.level-item {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid transparent;
  padding: 1rem;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all var(--transition-speed) ease;
}

.level-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--glass-border);
}

.level-item.active {
  background: rgba(6, 182, 212, 0.1);
  border-color: rgba(6, 182, 212, 0.4);
  box-shadow: inset 0 0 10px rgba(6, 182, 212, 0.15);
}

.level-info {
  display: flex;
  flex-direction: column;
}

.level-id {
  font-size: 0.7rem;
  color: var(--accent-cyan);
  font-weight: 600;
  text-transform: uppercase;
}

.level-name {
  font-size: 0.95rem;
  font-weight: 600;
}

.arrow-icon {
  font-size: 1.2rem;
  color: var(--text-muted);
  transition: transform var(--transition-speed) ease;
}

.level-item:hover .arrow-icon, .level-item.active .arrow-icon {
  color: var(--accent-cyan);
  transform: translateX(4px);
}

/* Editor Workspace Styling */
.editor-workspace {
  padding: 2rem;
  display: flex;
  flex-direction: column;
}

.workspace-header {
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 1rem;
}

.workspace-header h2 {
  font-size: 1.6rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text-main);
}

/* Fieldset Section Grid Layouts */
.section-fieldset {
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  background: rgba(0, 0, 0, 0.15);
}

.section-fieldset legend {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--accent-cyan);
  padding: 0 0.75rem;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
}

/* Action Footer with status messages */
.action-footer {
  display: flex;
  align-items: center;
  gap: 2rem;
  margin-top: 1rem;
}

.error-msg {
  color: #ef4444;
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.status-msg {
  font-size: 0.95rem;
  font-weight: 500;
  transition: opacity 0.5s ease;
}

.status-msg.success {
  color: #10b981;
}

.status-msg.error {
  color: #ef4444;
}

/* Empty State / Water Toy Micro-Animations */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  color: var(--text-muted);
  text-align: center;
  padding: 4rem;
}

.water-rings-animation {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.ring-circle {
  position: absolute;
  border: 3px solid rgba(6, 182, 212, 0.4);
  border-radius: 50%;
  animation: float-rings 6s infinite ease-in-out;
}

.ring-1 {
  width: 30px;
  height: 30px;
  animation-delay: 0s;
}

.ring-2 {
  width: 50px;
  height: 50px;
  border-color: rgba(139, 92, 246, 0.4);
  animation-delay: 1.5s;
}

.ring-3 {
  width: 70px;
  height: 70px;
  animation-delay: 3s;
}

@keyframes float-rings {
  0% { transform: translateY(15px) rotate(0deg); opacity: 0.3; }
  50% { transform: translateY(-15px) rotate(180deg) scale(1.1); opacity: 0.8; }
  100% { transform: translateY(15px) rotate(360deg); opacity: 0.3; }
}

/* Preview Card & Canvas Layout */
#editor-workspace-content {
  display: flex;
  flex-direction: row;
  align-items: flex-start; /* Prevents stretched height, letting sticky work */
  gap: 2rem;
  width: 100%;
}

#editor-workspace-content.hidden {
  display: none !important;
}

#editor-form {
  flex: 1;
  width: 50%;
  min-width: 0;
}

#level-preview-side-card {
  flex: 1;
  width: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 1.5rem;
  height: fit-content;
  min-width: 320px;
  position: sticky; /* Keeps preview card visible on scroll */
  top: 2rem; /* Spacing from screen top */
  z-index: 10;
}

#level-preview-side-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--accent-cyan);
  align-self: flex-start;
  width: 100%;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.5rem;
}

.canvas-container {
  background: radial-gradient(circle at center, rgba(6, 182, 212, 0.1) 0%, rgba(0, 0, 0, 0.4) 100%);
  border: 2px solid rgba(6, 182, 212, 0.3);
  border-radius: 16px;
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.15);
  padding: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
}

#preview-canvas {
  background: rgba(13, 27, 42, 0.8);
  border-radius: 10px;
  display: block;
}

.preview-legend {
  margin-top: 1rem;
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  display: inline-block;
}

.hook-color {
  background: #d97706;
  border: 1px solid #fbbf24;
}

.tube-color {
  background: rgba(6, 182, 212, 0.18);
  border: 1px solid #22d3ee;
}

.ring-color {
  background: #3b82f6;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.sphere-color {
  background: #10b981;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

@media (max-width: 992px) {
  #editor-workspace-content {
    flex-direction: column;
  }
  #level-preview-side-card {
    width: 100%;
    align-items: center;
  }
}

.hidden {
  display: none !important;
}

/* Tab Navigation Bar styling */
.tab-navbar {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--glass-border);
  padding-bottom: 0.75rem;
  flex-wrap: wrap;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 0.6rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  transition: all var(--transition-speed) ease;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.03);
}

.tab-btn.active {
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.08);
  border-color: rgba(6, 182, 212, 0.2);
  font-weight: 600;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.1);
}

/* Tab View switching display */
.tab-view {
  width: 100%;
}

.tab-view.hidden {
  display: none !important;
}

/* Dropdown Selector overrides */
select {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  font-family: inherit;
  font-size: 1rem;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
  width: 100%;
  transition: all var(--transition-speed) ease;
}

select:focus {
  border-color: var(--accent-cyan);
  background: rgba(0, 0, 0, 0.4);
}

select option {
  background: var(--bg-secondary);
  color: var(--text-main);
}

/* Presets Panels & Grids styling */
.preset-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.dashboard-layout {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  width: 100%;
}

.dashboard-layout > .presets-container {
  flex: 1;
  width: 50%;
  min-width: 0;
}

.presets-single-col {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
}

.preview-side-card {
  flex: 1;
  width: 50%;
  min-width: 0;
  position: sticky;
  top: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.preview-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.25rem;
}

.preset-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  transition: all var(--transition-speed) ease;
  cursor: pointer;
  position: relative;
}

.preset-card.active-preview {
  border-color: var(--accent-cyan) !important;
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.25) !important;
  background: rgba(6, 182, 212, 0.05) !important;
}

.preview-badge {
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.4);
  color: var(--accent-cyan);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.preset-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}

.preset-card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent-cyan);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.5rem;
  margin-bottom: 0.5rem;
}

/* Dynamic rows for items or layout configurations */
.dynamic-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.dynamic-row input, .dynamic-row select {
  padding: 0.5rem;
  font-size: 0.9rem;
  min-width: 0;
}

/* Danger Button designing */
.danger-btn {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #ef4444;
  padding: 0.85rem 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  transition: all var(--transition-speed) ease;
}

.danger-btn:hover {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.3);
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.25);
}

/* Custom Table Layout design */
.table-container {
  padding: 2.5rem;
}

.table-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: -0.25rem;
  margin-bottom: 1.5rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
  font-size: 0.95rem;
}

.admin-table th, .admin-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.admin-table th {
  font-weight: 600;
  color: var(--accent-cyan);
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 1.5px;
}

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

.admin-table td {
  font-weight: 300;
}

/* Toast Notifications Floating Banner */
#toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  color: var(--text-main);
  padding: 0.85rem 1.5rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-success {
  border-color: rgba(16, 185, 129, 0.4);
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.toast-error {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

