/* ============================================================
   UTOOL — Design System Moderno
   ============================================================ */

:root {
  --primary: #059669;
  --primary-dark: #047857;
  --primary-darker: #065f46;
  --primary-light: #d1fae5;
  --primary-lighter: #ecfdf5;
  --surface: #ffffff;
  --bg: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --border: #e2e8f0;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -1px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
  --transition: 0.2s ease;
}

/* --- Base --- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  margin: 0;
  padding-top: 64px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Page Container --- */
.page-container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

/* --- Navbar --- */
.navbar {
  background: linear-gradient(135deg, #047857 0%, #059669 100%);
  position: fixed;
  top: 0; left: 0;
  width: 100%;
  height: 64px;
  z-index: 1000;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
.navbar-title {
  color: #fff;
  font-weight: 600;
  font-size: 1.05em;
  letter-spacing: 0.02em;
  display: block;
  text-align: center;
  line-height: 64px;
  padding: 0 56px;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hamburger */
.hamburger-button {
  background: rgba(255,255,255,0.12);
  border: none;
  cursor: pointer;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 44px;
  min-height: 44px;
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  justify-content: center;
  align-items: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
}
.hamburger-button:hover { background: rgba(255,255,255,0.2); }
.hamburger-line {
  display: block;
  width: 16px;
  border-bottom: 2px solid #fff;
  border-radius: 1px;
  transition: transform var(--transition), opacity var(--transition);
}

/* Dropdown */
.dropdown-menu {
  display: none;
  position: absolute;
  top: 64px; left: 0;
  background-color: #fff;
  box-shadow: var(--shadow-xl);
  z-index: 1001;
  width: 280px;
  max-width: 100vw;
  flex-direction: column;
  padding: 8px 0;
  border-radius: 0 0 var(--radius) 0;
  border: 1px solid var(--border);
}
.dropdown-menu.open { display: flex; }
.dropdown-menu a {
  color: var(--text);
  padding: 14px 20px;
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  border-left: 3px solid transparent;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.dropdown-menu a:hover {
  background: var(--primary-lighter);
  color: var(--primary-dark);
  border-left-color: var(--primary);
}

/* --- Content Frame --- */
.content-frame {
  flex-grow: 1;
  border: none;
  display: block;
  width: 100%;
}

/* --- EULA Popup --- */
.popup-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-color: rgba(15,23,42,0.6);
  backdrop-filter: blur(4px);
  z-index: 1001;
  justify-content: center;
  align-items: center;
  padding: 20px;
}
.popup-content {
  background: #fff;
  padding: 32px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: popupIn 0.3s ease;
}
@keyframes popupIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.popup-content h2 {
  margin: 0 0 16px;
  color: var(--text);
  text-align: center;
  font-size: 1.35em;
  font-weight: 700;
}
.eula-text-container {
  border: 1px solid var(--border);
  padding: 16px;
  margin-bottom: 20px;
  max-height: 45vh;
  overflow-y: auto;
  background: #f8fafc;
  font-size: 0.88em;
  line-height: 1.6;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  flex-shrink: 1;
}
.eula-text-container h2 { font-size: 1em; text-align: left; margin: 16px 0 8px; color: var(--text); }

@media (max-width: 480px) {
  .navbar-title { font-size: 0.92em; padding: 0 52px; }
  .popup-content { padding: 24px 16px; }
  .eula-text-container { font-size: 0.84em; }
  .popup-content h2 { font-size: 1.15em; }
  .dropdown-menu a { font-size: 14px; padding: 12px 16px; }
}
.popup-buttons { text-align: center; padding-top: 8px; display: flex; gap: 12px; justify-content: center; }
.popup-buttons button {
  padding: 12px 32px;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1em;
  font-weight: 600;
  min-height: 44px;
  transition: background var(--transition), opacity var(--transition), transform var(--transition);
}
.popup-buttons button:active { transform: scale(0.97); }
.popup-accept-btn { background: var(--primary); color: #fff; }
.popup-accept-btn:hover:not(:disabled) { background: var(--primary-dark); }
.popup-accept-btn:disabled { background: #cbd5e1; color: #94a3b8; cursor: not-allowed; }
.popup-reject-btn { background: #f1f5f9; color: var(--text-secondary); }
.popup-reject-btn:hover { background: #e2e8f0; }

/* --- Content Blocked --- */
.content-blocked-overlay {
  display: none;
  position: absolute;
  top: 64px; left: 0;
  width: 100%;
  height: calc(100vh - 64px);
  background-color: rgba(255,255,255,0.92);
  backdrop-filter: blur(4px);
  z-index: 999;
  justify-content: center;
  align-items: center;
  text-align: center;
  font-size: 1.1em;
  color: var(--text-secondary);
  font-weight: 500;
}
.content-blocked-overlay p {
  background: #fff;
  padding: 24px 32px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  line-height: 1.6;
}

/* --- Footer --- */
.footer {
  background: linear-gradient(135deg, #047857 0%, #059669 100%);
  color: rgba(255,255,255,0.85);
  text-align: center;
  padding: 16px 0;
  flex-shrink: 0;
}
.footer p { margin: 0; font-size: 0.85em; letter-spacing: 0.01em; }

/* --- Calculator Shared Styles --- */
.calc-body { font-family: 'Inter', sans-serif; }
.calc-body sub { line-height: 0; font-size: 0.72em; vertical-align: sub; }
.calc-body sup { line-height: 0; font-size: 0.72em; vertical-align: super; }
.input-error { border-color: #ef4444 !important; background-color: #fef2f2 !important; }
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.mathjax-formula-container {
  text-align: center;
  margin: 0.75rem 0;
  overflow-x: auto;
  font-size: 1.05em;
}

/* Result highlights — chiuso & stima */
#result5.result-final,
#result6.result-final,
#result9.result-final,
#resultVa.result-final,
#res_VA.result-final {
  border: 2px solid var(--primary) !important;
  background: var(--primary-lighter) !important;
  color: var(--primary-darker) !important;
  font-weight: 700;
  font-size: 1.1em;
}
#result5.result-issue,
#result6.result-issue,
#result9.result-issue,
#resultVa.result-issue,
#res_VA.result-issue {
  border: 2px solid #ef4444 !important;
  background: #fef2f2 !important;
  color: #b91c1c !important;
  font-weight: 700;
  font-size: 1.1em;
}
.verification-positive { color: var(--primary); font-weight: 600; }
.verification-error { color: #ef4444; font-weight: 600; }

/* Result highlights — aperto */
#result7.result-final {
  border: 2px solid var(--primary) !important;
  background: var(--primary-lighter) !important;
  color: var(--primary-darker) !important;
  font-weight: 700;
  font-size: 1.1em;
}
#result7.result-issue {
  border: 2px solid #ef4444 !important;
  background: #fef2f2 !important;
  color: #b91c1c !important;
  font-weight: 700;
  font-size: 1.1em;
}

/* Result highlights — scambiatore */
.result-highlight input {
  border: 2px solid var(--primary) !important;
  background: var(--primary-lighter) !important;
  font-weight: 700;
  color: var(--primary-darker) !important;
  font-size: 1.1rem;
}
.result-highlight span { font-weight: 700; color: var(--text-secondary); }
#result4.result-error {
  border: 2px solid #fca5a5 !important;
  color: #dc2626 !important;
  font-weight: 700;
  background: #fef2f2 !important;
}

/* Utility */
.hidden-inputs { display: none; }
.text-justify { text-align: justify; }

/* Responsive images */
.calc-schema-img { max-width: 100%; height: auto; border-radius: var(--radius-sm); }
@media (min-width: 640px) { .calc-schema-img { max-width: 50%; } }
