/* ══════════════════════════════════════════════════════════════
   UVC Lamp Selection System — Design System & Styles
   ══════════════════════════════════════════════════════════════ */

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
  /* Colors — Dark palette with warm amber accents */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.65);
  --bg-card-hover: rgba(17, 24, 39, 0.8);
  --bg-input: rgba(30, 41, 59, 0.6);
  --bg-input-focus: rgba(30, 41, 59, 0.9);

  --border-subtle: rgba(148, 163, 184, 0.1);
  --border-input: rgba(148, 163, 184, 0.2);
  --border-focus: #a53692;

  --text-primary: #ffffff;
  --text-secondary: #ffffff;
  --text-muted: #ffffff;
  --text-accent: #a53692;

  --accent-amber: #a53692;
  --accent-amber-light: #a53692;
  --accent-amber-glow: rgba(165, 54, 146, 0.25);
  --accent-blue: #a53692;
  --accent-blue-light: #a53692;
  --accent-cyan: #a53692;
  --accent-emerald: #a53692;

  --gradient-primary: linear-gradient(135deg, #a53692 0%, #7a286c 100%);
  --gradient-blue: linear-gradient(135deg, #a53692 0%, #7a286c 100%);
  --gradient-card: linear-gradient(135deg, rgba(251, 191, 36, 0.05) 0%, rgba(165, 54, 146, 0.05) 100%);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 30px rgba(165, 54, 146, 0.15);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: linear-gradient(rgba(10, 14, 26, 0.8), rgba(10, 14, 26, 0.8)), url('/bg.png');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* --- Screen Management --- */
.screen {
  display: none;
  min-height: 100vh;
}
.screen.active {
  display: flex;
}

/* ═══════════════════════════════════════════════════
   LOGIN SCREEN
   ═══════════════════════════════════════════════════ */
#login-screen {
  align-items: center;
  justify-content: center;
  position: relative;
  background: transparent;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

/* Floating orbs */
.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.4;
  animation: float 20s ease-in-out infinite;
}
.orb-1 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, var(--accent-amber) 0%, transparent 70%);
  top: -100px; left: -100px;
  animation-delay: 0s;
}
.orb-2 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, var(--accent-blue) 0%, transparent 70%);
  bottom: -80px; right: -80px;
  animation-delay: -7s;
}
.orb-3 {
  width: 250px; height: 250px;
  background: radial-gradient(circle, var(--accent-cyan) 0%, transparent 70%);
  top: 40%; right: 20%;
  animation-delay: -14s;
}
.orb-4 {
  width: 300px; height: 300px;
  background: radial-gradient(circle, var(--accent-amber) 0%, transparent 70%);
  top: -50px; right: 10%;
  animation-delay: -5s;
  opacity: 0.25;
}
.orb-5 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, var(--accent-cyan) 0%, transparent 70%);
  bottom: -100px; left: 5%;
  animation-delay: -12s;
  opacity: 0.2;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -40px) scale(1.05); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(15px, 35px) scale(1.02); }
}

/* Glass Card */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
}

.login-card {
  width: 100%;
  max-width: 420px;
  padding: 48px 40px;
  z-index: 1;
  animation: slideUp 0.6s ease-out;
}

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

/* Logo */
.login-logo {
  text-align: center;
  margin-bottom: 36px;
}
.logo-icon {
  width: auto;
  height: 80px;
  margin: 0 auto 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.logo-icon img {
  max-height: 100%;
  max-width: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.2));
}
.logo-icon svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 12px rgba(165, 54, 146, 0.4));
}

@keyframes glow-pulse {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(165, 54, 146, 0.3)); }
  50% { filter: drop-shadow(0 0 20px rgba(165, 54, 146, 0.6)); }
}

.login-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.025em;
}
.login-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* Forms */
.form-group {
  margin-bottom: 20px;
}
.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.01em;
}
.unit {
  font-weight: 400;
  color: var(--text-muted);
}
.input-wrapper {
  position: relative;
}
.input-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color var(--transition-base);
}
.input-wrapper input {
  padding-right: 42px;
}

input[type="email"],
input[type="password"],
input[type="number"] {
  width: 100%;
  padding: 12px 16px;
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  color: var(--text-primary);
  background: var(--bg-input);
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--transition-base);
}
input::placeholder {
  color: var(--text-muted);
}
input:hover {
  border-color: rgba(148, 163, 184, 0.35);
}
input:focus {
  background: var(--bg-input-focus);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-amber-glow);
}
input:focus + .input-icon,
.input-wrapper:focus-within .input-icon {
  color: var(--accent-amber);
}
.input-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Error Message */
.error-message {
  font-size: 0.8125rem;
  color: #f87171;
  margin-bottom: 12px;
  min-height: 0;
  overflow: hidden;
  transition: all var(--transition-base);
}
.error-message:empty {
  margin-bottom: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-sans);
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.btn-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-primary {
  background: var(--gradient-primary);
  color: #ffffff;
  padding: 12px 24px;
  font-size: 0.9375rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md), 0 0 20px rgba(165, 54, 146, 0.2);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg), 0 0 30px rgba(165, 54, 146, 0.35);
}
.btn-primary:active:not(:disabled) {
  transform: translateY(0);
}

.btn-full {
  width: 100%;
}

.btn-calc {
  margin-top: 8px;
  padding: 14px 32px;
  font-size: 1rem;
  border-radius: var(--radius-md);
}

.btn-ghost {
  background: rgba(148, 163, 184, 0.08);
  color: var(--text-secondary);
  padding: 8px 16px;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}
.btn-ghost:hover {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-primary);
  border-color: rgba(148, 163, 184, 0.25);
}

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

/* Button Loader */
.btn-loader {
  display: none;
  width: 18px;
  height: 18px;
  border: 2.5px solid rgba(0, 0, 0, 0.2);
  border-top-color: #1a1a1a;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.btn.loading .btn-text { opacity: 0.6; }
.btn.loading .btn-loader { display: inline-block; }
.btn.loading { pointer-events: none; }

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

/* ═══════════════════════════════════════════════════
   APP SCREEN
   ═══════════════════════════════════════════════════ */
#app-screen {
  flex-direction: column;
  position: relative;
}

/* Header */
.app-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 12px 24px;
  background: rgba(10, 14, 26, 0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-logo-mini img {
  height: 36px;
  width: auto;
  display: block;
}
.header-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  text-align: center;
  margin: 0;
}
.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}
.user-greeting {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* Main */
.app-main {
  flex: 1;
  position: relative;
  padding: 32px 24px 48px;
  overflow-y: auto;
}
.app-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
}

.calculator-container {
  max-width: 800px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* Input Section */
.input-section {
  padding: 32px;
  margin-bottom: 32px;
  animation: slideUp 0.5s ease-out;
}
.section-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 28px;
}
.section-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
.input-icon-wrap {
  background: rgba(165, 54, 146, 0.1);
  color: var(--accent-amber);
}
.section-icon svg {
  width: 22px;
  height: 22px;
}
.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}
.section-desc {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.calc-form .form-group {
  margin-bottom: 0;
}

/* Results */
.results-section {
  animation: fadeInUp 0.5s ease-out;
}
.results-section.hidden {
  display: none;
}

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

.results-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.result-card {
  padding: 28px;
  transition: all var(--transition-slow);
  position: relative;
  overflow: hidden;
}
.result-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.option-1::before {
  background: var(--gradient-primary);
}
.option-2::before {
  background: var(--gradient-blue);
}

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

.result-header {
  margin-bottom: 24px;
}
.result-header h3 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 12px;
  letter-spacing: -0.01em;
}

.option-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.option-badge svg {
  width: 14px;
  height: 14px;
}
.badge-primary {
  background: rgba(165, 54, 146, 0.12);
  color: var(--accent-amber-light);
}
.badge-secondary {
  background: rgba(165, 54, 146, 0.12);
  color: var(--accent-blue-light);
}

.result-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.result-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.result-item:last-child {
  border-bottom: none;
}
.result-label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.result-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.result-value-lg {
  font-size: 1.75rem;
  font-weight: 800;
}
.option-1 .result-value-lg {
  color: var(--accent-amber-light);
}
.option-2 .result-value-lg {
  color: var(--accent-blue-light);
}
.result-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-left: 4px;
}
.result-total {
  padding-top: 16px;
  margin-top: 4px;
  border-top: 1px dashed rgba(148, 163, 184, 0.15);
  border-bottom: none !important;
}

/* ═══════════════════════════════════════════════════
   USER MANAGEMENT (ADMIN)
   ═══════════════════════════════════════════════════ */
.hidden {
  display: none !important;
}

.tab-view {
  animation: fadeIn 0.4s ease-out;
}
.tab-view.hidden {
  display: none !important;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.mgmt-section {
  padding: 32px;
  margin-bottom: 32px;
}

.mgmt-icon-wrap {
  background: rgba(165, 54, 146, 0.1);
  color: var(--accent-cyan);
}

.mgmt-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 40px;
  margin-top: 20px;
}

.panel-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

/* User List */
.user-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 400px;
  overflow-y: auto;
  padding-right: 8px;
}

.user-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all var(--transition-base);
}

.user-item:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}

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

.user-name {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
}

.user-email {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.role-tag {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.03em;
}

.role-admin {
  background: rgba(165, 54, 146, 0.15);
  color: var(--accent-amber-light);
}

.role-user {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text-secondary);
}

.btn-delete {
  color: #f87171;
  opacity: 0.6;
  padding: 6px;
}

.btn-delete:hover {
  opacity: 1;
  background: rgba(248, 113, 113, 0.1);
}

.mgmt-select {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-input);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  outline: none;
  cursor: pointer;
}

.mgmt-select option {
  background: var(--bg-secondary);
}

.loading-spinner {
  text-align: center;
  color: var(--text-secondary);
  padding: 40px 0;
  font-style: italic;
}

.btn-icon-only {
  padding: 8px;
  border-radius: 50%;
}

.btn-group-row {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.btn-grow {
  flex: 1;
}

.mgmt-panel {
  animation: slideUp 0.4s ease-out;
}

.mgmt-panel.hidden {
  display: none;
}

.user-item-btn {
  padding: 6px;
  border-radius: 6px;
  color: var(--text-secondary);
  transition: all var(--transition-base);
}

.user-item-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.btn-edit:hover {
  color: var(--accent-cyan);
}

@media (max-width: 900px) {
  .mgmt-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

/* --- Count-up animation --- */
.result-value.counting {
  animation: countPulse 0.4s ease-out;
}
@keyframes countPulse {
  0% { transform: scale(0.8); opacity: 0; }
  60% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

/* ═══════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .login-card {
    max-width: calc(100% - 32px);
    padding: 36px 28px;
  }
  .app-header {
    padding: 10px 16px;
  }
  .header-title {
    font-size: 0.875rem;
  }
  .user-greeting {
    display: none;
  }
  .app-main {
    padding: 20px 16px 40px;
  }
  .input-section {
    padding: 24px 20px;
  }
  .input-row {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .results-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .result-card {
    padding: 24px 20px;
  }
  .section-header {
    gap: 12px;
    margin-bottom: 20px;
  }
  .section-title {
    font-size: 1.1rem;
  }
  .btn-calc {
    padding: 12px 20px;
    font-size: 0.9375rem;
  }
}

@media (max-width: 400px) {
  .login-card {
    padding: 28px 20px;
  }
  .login-title {
    font-size: 1.5rem;
  }
  .logo-icon {
    width: 52px;
    height: 52px;
  }
}

/* ═══════════════════════════════════════════════════
   UTILITY
   ═══════════════════════════════════════════════════ */
::selection {
  background: rgba(165, 54, 146, 0.3);
  color: var(--text-primary);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.2);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.35);
}

/* Number input spinner hide */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

/* Disclaimer Footer */
.app-disclaimer {
  text-align: center;
  margin-top: 40px;
  padding: 20px;
  font-size: 0.75rem;
  color: var(--text-primary);
  line-height: 1.5;
}
.app-disclaimer p {
  margin-bottom: 8px;
}
