/* ═══════════════════════════════════════════
   3D CALC — FUTURISTIC STYLESHEET
   ═══════════════════════════════════════════ */

:root {
  --bg: #040810;
  --bg2: #070e1a;
  --surface: #0a1525;
  --surface2: #0d1e35;
  --border: #0e3a6e;
  --border2: #1a5295;
  --accent: #00d4ff;
  --accent2: #00ff9d;
  --accent3: #ff6b35;
  --text: #c8e0f0;
  --text-dim: #4a7aa0;
  --text-bright: #e8f4ff;
  --danger: #ff3a5c;
  --glow: 0 0 20px rgba(0, 212, 255, 0.3);
  --glow-green: 0 0 20px rgba(0, 255, 157, 0.3);
  --font-mono: 'Share Tech Mono', monospace;
  --font-display: 'Orbitron', monospace;
  --font-body: 'Rajdhani', sans-serif;
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --radius: 4px;
}

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

html { font-size: 16px; scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 1rem;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── BACKGROUND EFFECTS ── */
.grid-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(0,212,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}

.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0,0,0,0.08) 2px,
    rgba(0,0,0,0.08) 4px
  );
  animation: scanMove 8s linear infinite;
}

@keyframes scanMove {
  0% { background-position: 0 0; }
  100% { background-position: 0 100px; }
}

/* ── TOPBAR ── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: rgba(4,8,16,0.95);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  z-index: 200;
  backdrop-filter: blur(10px);
}

.topbar::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  animation: borderPulse 3s ease-in-out infinite;
}

@keyframes borderPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.logo-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.logo-icon {
  font-size: 1.8rem;
  color: var(--accent);
  animation: spin 10s linear infinite;
  text-shadow: var(--glow);
}

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

.logo-text { display: flex; flex-direction: column; }

.logo-main {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: var(--text-bright);
}

.logo-main .accent { color: var(--accent); }

.logo-sub {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  color: var(--text-dim);
  letter-spacing: 0.15em;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--accent2);
  letter-spacing: 0.1em;
}

.dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent2);
  box-shadow: 0 0 8px var(--accent2);
  animation: blink 1.5s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.2; }
}

.clock {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  letter-spacing: 0.1em;
}

.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  margin-left: auto;
}

.hamburger span {
  display: block;
  width: 22px; height: 2px;
  background: var(--accent);
  transition: all 0.3s;
}

/* ── LAYOUT ── */
.layout {
  display: flex;
  margin-top: var(--topbar-h);
  min-height: calc(100vh - var(--topbar-h));
  position: relative;
  z-index: 1;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  min-height: calc(100vh - var(--topbar-h));
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: var(--topbar-h);
  left: 0;
  bottom: 0;
  z-index: 150;
  overflow-y: auto;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
}

.sidebar-label {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.25em;
  color: var(--text-dim);
  padding: 1.2rem 1rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.nav-list {
  list-style: none;
  padding: 0.5rem 0;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.03em;
  border-left: 3px solid transparent;
  transition: all 0.2s;
  position: relative;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(0,212,255,0.05);
  border-left-color: var(--border2);
}

.nav-item.active {
  color: var(--accent);
  background: rgba(0,212,255,0.08);
  border-left-color: var(--accent);
}

.nav-item.active::after {
  content: '';
  position: absolute;
  right: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--accent);
  box-shadow: var(--glow);
}

.nav-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
}

.nav-text { font-family: var(--font-body); }

.sidebar-footer {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.sidebar-footer-text {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  letter-spacing: 0.15em;
  color: var(--text-dim);
}

/* ── MAIN CONTENT ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 2rem;
  max-width: 900px;
}

/* ── TAB PANELS ── */
.tab-panel { display: none; animation: fadeIn 0.3s ease; }
.tab-panel.active { display: block; }

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

/* ── PANEL HEADER ── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-bright);
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.panel-icon { color: var(--accent); }

.panel-badge {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.2em;
  color: var(--accent2);
  background: rgba(0,255,157,0.08);
  border: 1px solid rgba(0,255,157,0.25);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius);
}

.panel-desc {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

/* ── CARD GRID ── */
.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

/* ── CARD ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
}

.card-title {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--accent);
  margin-bottom: 1rem;
}

/* ── FORM FIELDS ── */
.field-group {
  margin-bottom: 1rem;
}

.field-group label {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
}

.input-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
  transition: border-color 0.2s;
}

.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(0,212,255,0.2);
}

.input-wrap input,
.input-wrap select {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-bright);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  padding: 0.55rem 0.75rem;
}

.input-wrap select {
  cursor: pointer;
}

.unit {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-dim);
  padding: 0 0.6rem;
  background: rgba(0,212,255,0.05);
  border-left: 1px solid var(--border);
  height: 100%;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.55rem 0.75rem;
  border-radius: var(--radius);
  width: 100%;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}

select:focus { border-color: var(--accent); }

/* ── BUTTON ── */
.btn-calc {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.7rem 1.5rem;
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  border-radius: var(--radius);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.2s;
}

.btn-calc::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: translateX(-100%);
  transition: transform 0.2s;
  z-index: -1;
}

.btn-calc:hover {
  color: var(--bg);
  box-shadow: var(--glow);
}

.btn-calc:hover::before { transform: translateX(0); }

.btn-calc:active { transform: scale(0.98); }

/* ── RESULT CARD ── */
.result-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.result-card::before {
  background: linear-gradient(90deg, var(--accent2), transparent);
}

.result-big {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 900;
  color: var(--accent2);
  text-shadow: var(--glow-green);
  letter-spacing: 0.05em;
  margin: 0.5rem 0 0.25rem;
}

.result-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.result-sub {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.75rem;
  line-height: 1.6;
}

/* ── CODE BLOCK ── */
.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent2);
  margin-top: 1rem;
  white-space: pre;
  overflow-x: auto;
  line-height: 1.6;
}

.code-block.scrollable {
  max-height: 280px;
  overflow-y: auto;
}

code {
  background: rgba(0,212,255,0.08);
  border: 1px solid rgba(0,212,255,0.15);
  border-radius: 3px;
  padding: 0.1em 0.4em;
  font-family: var(--font-mono);
  font-size: 0.85em;
  color: var(--accent);
}

/* ── INFO BOX ── */
.info-box {
  background: rgba(0,212,255,0.04);
  border: 1px solid rgba(0,212,255,0.15);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
}

.info-title {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.info-box p {
  font-size: 0.88rem;
  color: var(--text-dim);
  line-height: 1.7;
}

/* ── RESULT ROW (retraction) ── */
.ret-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.ret-row:last-child { border-bottom: none; }

.ret-key {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
}

.ret-val {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent2);
}

/* ── TEMP TABLE ── */
.temp-table {
  margin-top: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.temp-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.temp-row span:first-child { color: var(--text-dim); }
.temp-row span:last-child { color: var(--accent); }

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── SIDEBAR OVERLAY (mobile) ── */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.45);
  z-index: 148;
  pointer-events: none;
}

.sidebar-overlay.active {
  display: block;
  pointer-events: auto;
}

/* ══════════════════════════
   RESPONSIVE / MOBILE
══════════════════════════ */

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

@media (max-width: 720px) {
  :root { --topbar-h: 56px; }

  .hamburger { display: flex; }

  .topbar-right .status-indicator { display: none; }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 30px rgba(0,0,0,0.5);
  }

  .main {
    margin-left: 0;
    padding: 1.25rem;
  }

  .logo-sub { display: none; }

  .result-big { font-size: 1.5rem; }
}

@media (max-width: 480px) {
  .panel-header { flex-direction: column; align-items: flex-start; }
  .main { padding: 1rem; }
  .card { padding: 1rem; }
}
