/* ─── RESET ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #eef2f7;
  color: #0f172a;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ─── LOGIN SCREEN ───────────────────────────────────── */
#loginScreen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0a1628 0%, #0e2a4a 50%, #0a3d62 100%);
  z-index: 1000;
}

/* subtle animated grid dots in the background */
#loginScreen::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(0,168,232,0.18) 1px, transparent 1px);
  background-size: 38px 38px;
  pointer-events: none;
}

.login-card {
  position: relative;
  width: 420px;
  max-width: 95vw;
  padding: 44px 40px 36px;
  border-radius: 20px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(0,168,232,0.28);
  backdrop-filter: blur(18px);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.05),
    0 32px 80px rgba(0,0,0,0.45),
    0 0 60px rgba(0,120,200,0.12);
  animation: cardIn 0.45s ease;
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

/* ── Logo on login ── */
.login-logo-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.login-logo {
  width: 170px;
  height: auto;
  /* logo has a white background — give it a slight border-radius + shadow
     so it sits naturally on the dark card without looking pasted */
  border-radius: 14px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.92);
  box-shadow: 0 4px 24px rgba(0,0,0,0.35);
}

.login-title {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
}

.login-sub {
  text-align: center;
  margin-top: 6px;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.01em;
}

/* ── Form ── */
.login-form {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-field label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.84rem;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.login-field input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid rgba(0,168,232,0.3);
  border-radius: 10px;
  background: rgba(255,255,255,0.07);
  color: #fff;
  font-size: 0.98rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.login-field input::placeholder { color: rgba(255,255,255,0.3); }

.login-field input:focus {
  border-color: #00a8e8;
  box-shadow: 0 0 0 3px rgba(0,168,232,0.2);
}

.pw-wrap {
  position: relative;
}

.pw-wrap input {
  padding-right: 44px;
}

.pw-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: auto !important;
  min-height: unset;
  padding: 4px 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 1.05rem;
  color: rgba(255,255,255,0.55);
  line-height: 1;
}

.pw-toggle:hover { background: transparent; color: #fff; }

.login-error {
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(220,38,38,0.18);
  border: 1px solid rgba(220,38,38,0.4);
  color: #fca5a5;
  font-size: 0.88rem;
  text-align: center;
}

.login-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #0077b6, #00a8e8);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 6px 22px rgba(0,120,200,0.38);
}

.login-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(0,120,200,0.48);
  background: linear-gradient(135deg, #0077b6, #00a8e8);
}

.login-btn:active { transform: translateY(0); }

.login-footer {
  margin-top: 28px;
  text-align: center;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.28);
}

/* ─── MAIN APP ─────────────────────────────────────────── */
#app {
  display: flex;
  width: 100vw;
  height: 100vh;
}

/* ── Left panel ── */
#leftPanel {
  width: 300px;
  flex: 0 0 300px;
  overflow-y: auto;
  padding: 18px;
  color: #fff;
  background: #0b1e36;
  display: flex;
  flex-direction: column;
}

/* ── Brand ── */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

/* Logo in sidebar — white bg pill so it's crisp on dark sidebar */
.brand-logo {
  width: 52px;
  height: 52px;
  object-fit: contain;
  border-radius: 10px;
  padding: 4px;
  background: rgba(255,255,255,0.94);
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  flex-shrink: 0;
}

.brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.1;
  letter-spacing: 0.03em;
}

.brand p {
  margin-top: 3px;
  color: #64a7cc;
  font-size: 0.82rem;
}

/* ── Shared button/input resets ── */
button, input, select, textarea { font: inherit; }

button, input[type='file'] { width: 100%; }

button {
  min-height: 40px;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: #0077b6;
  cursor: pointer;
  transition: background 0.18s;
}

button:hover { background: #005f92; }

/* ── Panel sections ── */
.panel-section { margin-top: 16px; }

.tool-section {
  margin-top: 16px;
  padding: 13px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
}

.tool-section > h2 {
  margin-bottom: 10px;
  color: #f0f9ff;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
}

.panel-section h2, .panel-section h3 {
  margin-bottom: 8px;
  color: #38bdf8;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 68px;
  gap: 8px;
}

.success { background: #059669; }
.success:hover { background: #047857; }
.danger  { background: #991b1b; }
.danger:hover  { background: #7f1d1d; }
.subtle  { background: #334155; }
.subtle:hover  { background: #475569; }

.field-label {
  display: block;
  margin-bottom: 6px;
  color: #bae6fd;
  font-size: 0.84rem;
  font-weight: 600;
}

.panel-section select,
.tool-section select {
  width: 100%;
  min-height: 40px;
  padding: 9px 10px;
  border: 1px solid rgba(255,255,255,0.13);
  border-radius: 8px;
  color: #f0f9ff;
  background: #0d2237;
}

.active-tool {
  background: #0369a1 !important;
  box-shadow: 0 0 0 2px rgba(56,189,248,0.45) inset;
}

/* ── Sliders ── */
input[type='range'] {
  display: block;
  width: 100%;
  height: 26px;
  margin-top: 2px;
  background: transparent;
  cursor: pointer;
  appearance: none;
}

input[type='range']::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 4px;
  background: #1e3a5f;
}

input[type='range']::-moz-range-track {
  height: 5px;
  border-radius: 4px;
  background: #1e3a5f;
}

input[type='range']::-webkit-slider-thumb {
  width: 17px;
  height: 17px;
  margin-top: -6px;
  border: 2px solid #f0f9ff;
  border-radius: 50%;
  background: #00a8e8;
  appearance: none;
  cursor: pointer;
}

input[type='range']::-moz-range-thumb {
  width: 17px;
  height: 17px;
  border: 2px solid #f0f9ff;
  border-radius: 50%;
  background: #00a8e8;
  cursor: pointer;
}

/* ── Selected info ── */
#selectedInfo {
  padding: 8px 10px;
  border-radius: 6px;
  background: rgba(0,168,232,0.08);
  font-size: 0.86rem;
  color: #94a3b8;
}

#selectedInfo span { color: #38bdf8; font-weight: 700; }

/* ── Help text ── */
.help-text {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.09);
  color: #64748b;
  font-size: 0.84rem;
  line-height: 1.5;
}

/* ── Logout section ── */
.logout-section {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255,255,255,0.09);
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
  margin-bottom: 10px;
}

.user-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0077b6, #00a8e8);
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-name {
  font-size: 0.9rem;
  color: #e2e8f0;
  font-weight: 600;
}

.logout-btn {
  background: rgba(153,27,27,0.3);
  border: 1px solid rgba(220,38,38,0.35);
  color: #fca5a5;
  font-size: 0.88rem;
  transition: background 0.18s;
}

.logout-btn:hover {
  background: rgba(153,27,27,0.6);
}

/* ─── WORKSPACE ─────────────────────────────────────────── */
#workspace {
  position: relative;
  flex: 1;
  min-width: 0;
  height: 100vh;
  background: #e2e8f0;
}

.workspace-panel {
  position: absolute;
  inset: 0;
  display: none;
}

.workspace-panel.active { display: block; }

#viewer {
  position: relative;
  width: 100%;
  height: 100%;
}

#viewer canvas {
  display: block;
  position: relative;
  z-index: 1;
}

/* ── Zoom controls overlay ── */
.view-zoom-controls {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 3;
  display: flex;
  gap: 8px;
}

.view-zoom-controls button {
  display: grid;
  width: 40px;
  height: 40px;
  min-height: 40px;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 8px;
  background: rgba(11,30,54,0.84);
  font-size: 1.3rem;
  line-height: 1;
  width: 40px;
}

.view-zoom-controls button:hover {
  background: rgba(0,119,182,0.9);
}

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 900px) {
  #app { flex-direction: column; }

  #leftPanel {
    width: 100%;
    flex: 0 0 auto;
    max-height: 44vh;
  }

  #workspace { height: 56vh; }
}
