@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Syne:wght@600;700;800&display=swap');

/* ── Variáveis ──────────────────────────────────────────────────────────────── */
:root {
  --bg:        #f4f6f9;
  --surface:   #ffffff;
  --surface2:  #f8fafc;
  --border:    #e4e8ef;
  --border2:   #d0d7e3;
  --accent:    #1e6fe0;
  --accent-h:  #1558b8;
  --accent-bg: rgba(30,111,224,0.07);
  --green:     #0f9e6e;
  --red:       #d63b3b;
  --amber:     #c97b15;
  --purple:    #6b47d6;
  --text:      #0f1624;
  --text2:     #2f3d54;
  --muted:     #6b7a94;
  --shadow-sm: 0 1px 2px rgba(15,22,36,0.05);
  --shadow:    0 1px 4px rgba(15,22,36,0.07), 0 2px 10px rgba(15,22,36,0.04);
  --shadow-md: 0 4px 20px rgba(15,22,36,0.1), 0 2px 8px rgba(15,22,36,0.05);
  --radius:    10px;
  --radius-lg: 16px;
}

body:not(.theme-light) {
  --bg:        #0b0e15;
  --surface:   #131824;
  --surface2:  #1a2132;
  --border:    #232d40;
  --border2:   #2d3a52;
  --text:      #ffffff;
  --text2:     #b8c2d4;
  --muted:     #94a3b8;
  --shadow:    0 1px 4px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ── Logo switching ─────────────────────────────────────────────────────────── */
.logo-light { display: none !important; }
.logo-dark  { display: block !important; }
body.theme-light .logo-light { display: block !important; }
body.theme-light .logo-dark  { display: none !important; }

/* ══════════════════════════════════════════════════════════════════════════════
   LOGIN SCREEN
══════════════════════════════════════════════════════════════════════════════ */
#loginScreen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

body.theme-light #loginScreen {
  background: linear-gradient(135deg, #eef2f9 0%, #f4f6f9 60%, #edf0f7 100%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 44px 40px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 28px;
}
.login-logo img { height: 44px; }

.login-title {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}
.login-subtitle {
  font-size: 13.5px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 32px;
}

.login-field { margin-bottom: 14px; }
.login-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}
.login-field input {
  width: 100%;
  padding: 11px 14px;
  font-size: 14px;
  font-family: 'Inter', sans-serif;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.login-field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30,111,224,0.12);
}
.login-field input::placeholder { color: var(--muted); opacity: 0.7; }

.login-error {
  font-size: 13px;
  color: var(--red);
  text-align: center;
  min-height: 20px;
  margin-top: 4px;
  margin-bottom: -4px;
}

.login-btn {
  width: 100%;
  margin-top: 20px;
  padding: 12px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.login-btn:hover   { background: var(--accent-h); }
.login-btn:active  { transform: scale(0.99); }
.login-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.login-footer {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

/* ══════════════════════════════════════════════════════════════════════════════
   LOADING OVERLAY
══════════════════════════════════════════════════════════════════════════════ */
#loadingOverlay {
  position: fixed; inset: 0;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  z-index: 999; flex-direction: column; gap: 20px;
  transition: opacity 0.3s;
}
body.theme-light #loadingOverlay { background: #f4f6f9; }

.spinner {
  width: 32px; height: 32px;
  border: 2.5px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ══════════════════════════════════════════════════════════════════════════════
   TOPBAR
══════════════════════════════════════════════════════════════════════════════ */
.calc-topbar {
  height: 58px;
  padding: 0 24px;
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
  box-shadow: var(--shadow-sm);
}
.calc-topbar-left  { display: flex; align-items: center; gap: 20px; }
.calc-topbar-right { display: flex; align-items: center; gap: 8px; }
.calc-topbar-logo img { height: 32px; display: block; }

.topbar-divider {
  width: 1px; height: 24px;
  background: var(--border); flex-shrink: 0;
}

/* ── Topbar icon button ── */
.topbar-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}
.topbar-btn:hover { background: var(--surface2); color: var(--text); border-color: var(--border2); }
.topbar-btn svg   { width: 15px; height: 15px; }

/* logout button has a slight red tint on hover */
.topbar-btn.btn-logout:hover { background: rgba(214,59,59,0.08); color: var(--red); border-color: rgba(214,59,59,0.25); }

/* ── User badge ── */
.topbar-user {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--muted);
  padding: 0 4px;
}
.topbar-user-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-bg);
  border: 1.5px solid var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

/* ── theme toggle alias ── */
.theme-toggle {
  width: 34px; height: 34px; border-radius: 8px;
  background: transparent; border: 1px solid var(--border);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--muted); transition: all 0.15s; flex-shrink: 0;
}
.theme-toggle:hover { background: var(--surface2); color: var(--text); }
.theme-toggle svg   { width: 15px; height: 15px; }

/* ══════════════════════════════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
  cursor: pointer; border: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: 'Inter', sans-serif;
  text-decoration: none;
}
.btn svg { width: 14px; height: 14px; }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }

.btn-ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); border-color: var(--border2); }

/* ══════════════════════════════════════════════════════════════════════════════
   CONTENT
══════════════════════════════════════════════════════════════════════════════ */
.calc-content {
  min-height: calc(100vh - 58px);
}

.page        { display: none; }
.page.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: calc(100vh - 58px);
  padding: 28px 20px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   HUB
══════════════════════════════════════════════════════════════════════════════ */
#page-calc-hub.active {
  display: block;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 24px;
}

.hub-header { margin-bottom: 32px; }
.hub-header-logo { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.hub-header-logo img { height: 36px; }
.hub-divider { height: 1px; background: var(--border); }

.hub-title {
  font-family: 'Syne', sans-serif;
  font-size: 26px; font-weight: 700;
  color: var(--text); letter-spacing: -0.4px;
  margin-bottom: 6px;
}
.hub-subtitle {
  font-size: 14px; color: var(--muted);
}

.calc-hub-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.calc-hub-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 20px 22px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: flex-start; gap: 12px;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-sm);
  text-align: left;
}
.calc-hub-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.calc-hub-icon {
  width: 44px; height: 44px; border-radius: 10px;
  background: var(--accent-bg);
  color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.calc-hub-icon svg { width: 22px; height: 22px; }
.calc-hub-name {
  font-family: 'Syne', sans-serif;
  font-size: 13.5px; font-weight: 700;
  color: var(--text); line-height: 1.35;
}
.calc-hub-desc { font-size: 12px; color: var(--muted); line-height: 1.55; }

/* ══════════════════════════════════════════════════════════════════════════════
   CALC PAGES
══════════════════════════════════════════════════════════════════════════════ */
.calc-back-btn  { margin-bottom: 12px; align-self: flex-start; }
.calc-page-wrap { max-width: 960px;  width: 100%; display: flex; flex-direction: column; }
.calc-page-wide { max-width: 1140px; width: 100%; display: flex; flex-direction: column; }

.calc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 28px 24px;
  box-shadow: var(--shadow);
}

.calc-header {
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; margin-bottom: 20px;
}
.calc-header img { height: 36px; }
.calc-subtitle {
  font-size: 11px; font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.1em; text-transform: uppercase;
  margin-top: 8px;
}

.calc-divider { height: 1px; background: var(--border); margin-bottom: 22px; }

/* ── Form ── */
.calc-capas-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.calc-capas-full { grid-column: 1 / -1; }
.form-group      { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }

.form-label {
  font-size: 11.5px; font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.04em;
}
.form-input, .form-select {
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 13.5px; color: var(--text);
  font-family: 'Inter', sans-serif;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}
.form-input:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(30,111,224,0.1);
}
.form-input::placeholder { color: var(--muted); opacity: 0.6; }

/* ── Section titles ── */
.calc-section-title {
  font-size: 14px; font-weight: 900;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--muted);
  margin: 22px 0 8px;
  display: flex; align-items: center; gap: 8px;
}
.calc-section-title::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ── Result rows ── */
.calc-result-rows {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.calc-result-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.calc-result-row:last-child { border-bottom: none; }
.calc-result-row.highlight  { background: var(--surface2); }

.calc-result-label {
  font-size: 11.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  font-weight: 500;
  flex: 1;
  min-width: 0;
}
.calc-result-val {
  font-family: 'Syne', sans-serif;
  font-size: 15px; font-weight: 700; color: var(--text);
  white-space: nowrap;
}
.calc-result-val.blue   { color: var(--accent); }
.calc-result-val.green  { color: var(--green); }
.calc-result-val.amber  { color: var(--amber); }
.calc-result-val.purple { color: var(--purple); }
.calc-result-unit {
  font-family: 'Inter', sans-serif;
  font-size: 11px; font-weight: 400; color: var(--muted); margin-left: 3px;
}
.calc-fita-ref {
  font-size: 11px; color: var(--muted);
  margin-top: 6px; padding: 0 2px; font-style: italic;
}

/* ── BLFC menu ── */
.blfc-menu-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  margin-bottom: 20px;
}
.blfc-menu-btn {
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 18px 14px;
  cursor: pointer; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: border-color 0.15s, background 0.15s;
  font-family: 'Inter', sans-serif;
}
.blfc-menu-btn:hover  { border-color: var(--accent); background: var(--surface); }
.blfc-menu-btn.active { border-color: var(--accent); background: var(--accent-bg); }
.blfc-menu-icon       { font-size: 22px; color: var(--muted); }
.blfc-menu-btn.active .blfc-menu-icon { color: var(--accent); }
.blfc-menu-label {
  font-size: 12.5px; font-weight: 600;
  color: var(--muted); line-height: 1.35;
}
.blfc-menu-btn.active .blfc-menu-label { color: var(--accent); }

/* ── Fita radio labels ── */
.fita-radio-label {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  flex: 1; transition: border-color 0.15s, background 0.15s; color: var(--text);
  font-family: 'Inter', sans-serif; font-size: 13px;
}
.fita-radio-label:has(input:checked) {
  border-color: var(--accent); background: var(--accent-bg); color: var(--accent);
}

/* ══════════════════════════════════════════════════════════════════════════════
   AUX CALCULATORS
══════════════════════════════════════════════════════════════════════════════ */
.aux-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 9px; margin-bottom: 18px;
}
.aux-btn {
  background: var(--surface2); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 14px 10px;
  cursor: pointer; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  transition: border-color .15s, background .15s; color: var(--text);
  font-family: 'Inter', sans-serif;
}
.aux-btn:hover  { border-color: var(--accent); background: var(--surface); }
.aux-btn.active { border-color: var(--accent); background: var(--accent-bg); }
.aux-icon   { font-size: 20px; color: var(--muted); }
.aux-btn.active .aux-icon  { color: var(--accent); }
.aux-label  { font-size: 11.5px; font-weight: 500; color: var(--muted); line-height: 1.35; }
.aux-btn.active .aux-label { color: var(--accent); }

.aux-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
}
.aux-panel-title {
  font-size: 15px; font-weight: 600;
  margin-bottom: 5px;
  font-family: 'Syne', sans-serif; color: var(--text);
}
.aux-panel-formula {
  font-size: 12px; color: var(--muted);
  font-family: 'Courier New', monospace;
  background: var(--surface2); padding: 8px 12px;
  border-radius: 8px; margin-bottom: 18px;
}
.aux-field { margin-bottom: 14px; }
.aux-field label {
  display: block; font-size: 11.5px; font-weight: 600;
  color: var(--muted); letter-spacing: 0.04em; margin-bottom: 5px;
}
.aux-field input, .aux-field select {
  width: 100%; padding: 9px 12px; font-size: 13px;
  border: 1.5px solid var(--border); border-radius: var(--radius);
  background: var(--surface2); color: var(--text);
  font-family: 'Inter', sans-serif; outline: none;
  transition: border-color .15s;
}
.aux-field input:focus, .aux-field select:focus { border-color: var(--accent); }
.aux-error { color: var(--red); font-size: 13px; margin-top: 10px; display: none; }
.aux-result-area { margin-top: 18px; display: none; }
.aux-result-area.show { display: block; }
.aux-result-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.aux-result-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px;
}
.aux-result-label {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.07em;
  margin-bottom: 4px; font-weight: 500;
}
.aux-result-value {
  font-family: 'Syne', sans-serif; font-size: 22px;
  font-weight: 700; color: var(--accent);
}
.aux-result-unit {
  font-family: 'Inter', sans-serif; font-size: 12px;
  font-weight: 400; color: var(--muted); margin-left: 4px;
}

/* ══════════════════════════════════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed; bottom: 22px; right: 22px;
  z-index: 999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 11px 16px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; min-width: 250px;
  animation: toastIn 0.25s ease;
  box-shadow: var(--shadow-md);
}
@keyframes toastIn {
  from { transform: translateX(36px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast-icon    { width: 17px; height: 17px; flex-shrink: 0; }
.toast.success .toast-icon { color: var(--green); }
.toast.error   .toast-icon { color: var(--red); }

/* ══════════════════════════════════════════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════════════════════════════════════════ */
.empty-state { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty-state svg { width: 40px; height: 40px; margin: 0 auto 12px; display: block; opacity: 0.25; }
.empty-state p   { font-size: 13.5px; }

/* ══════════════════════════════════════════════════════════════════════════════
   LAYOUT LADO A LADO (inputs esquerda / resultados direita)
══════════════════════════════════════════════════════════════════════════════ */
.calc-side-layout {
  display: flex;
  gap: 28px;
  align-items: flex-start;
}

.calc-inputs-panel {
  flex: 0 0 290px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.calc-inputs-panel .calc-capas-grid {
  grid-template-columns: 1fr;
  gap: 12px;
}

.calc-inputs-panel .calc-capas-full {
  grid-column: 1;
}

.calc-inputs-panel .btn-primary {
  width: 100%;
  justify-content: center;
  margin-top: 12px;
}

.calc-results-panel {
  flex: 1;
  min-width: 0;
}

.calc-results-panel .calc-section-title:first-child,
.calc-results-panel > div > .calc-section-title:first-child {
  margin-top: 0;
}
.bltr-cci-only .calc-section-title:first-child,
.bltr-sci-only .calc-section-title:first-child { margin-top: 0; }

.calc-results-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 180px;
  border: 1.5px dashed var(--border2);
  border-radius: var(--radius);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  padding: 24px;
}

.calc-results-empty svg { width: 32px; height: 32px; opacity: 0.35; }

/* Oculta o placeholder quando o div de resultados está visível */
.calc-results-panel:has(> [id$="-resultado"]:not([style*="none"])) .calc-results-empty { display: none; }

/* ══════════════════════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 880px) {
  .calc-hub-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 800px) {
  .calc-side-layout {
    flex-direction: column;
    gap: 20px;
  }
  .calc-inputs-panel {
    flex: 0 0 auto;
    width: 100%;
  }
  .calc-results-empty { min-height: 120px; }
}

@media (max-width: 768px) {
  .calc-topbar { padding: 0 16px; }
  .page.active { padding: 16px 14px; }
  .calc-capas-grid { grid-template-columns: 1fr !important; }
  .calc-capas-full { grid-column: 1 !important; }
  .blfc-menu-grid  { grid-template-columns: 1fr; }
  #page-calc-hub.active { padding: 24px 16px; }
  .topbar-user-email { display: none; }
}
@media (max-width: 480px) {
  .calc-hub-grid { grid-template-columns: 1fr; }
  .aux-grid      { grid-template-columns: repeat(2, 1fr); }
  .aux-result-row{ grid-template-columns: 1fr; }
  .calc-card     { padding: 22px 18px; }
  .login-card    { padding: 32px 24px 28px; }
}
