@import url('./style.css');

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at top, rgba(59, 130, 246, 0.15), transparent 60%), var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
}

.login-brand { text-align: center; margin-bottom: 1.5rem; }
.login-brand h1 { font-size: 1.5rem; }
.login-brand p { color: var(--muted); font-size: 0.9rem; }
.login-hint { font-size: 0.75rem; margin-top: 0.75rem; line-height: 1.4; }
.login-hint code { font-size: 0.7rem; }

.login-card label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0.75rem 0 0.35rem;
}

.login-card input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.login-card button[type="submit"] {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.75rem;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

.login-card button[type="submit"]:hover { background: var(--accent-hover); }

.error-box {
  margin-top: 1rem;
  padding: 0.65rem;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  font-size: 0.9rem;
}

.hidden { display: none !important; }

/* App shell — menu in alto */
.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow: hidden;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.top-nav-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.top-nav-brand strong { font-size: 1rem; white-space: nowrap; }

.user-badge {
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.top-nav-menu {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  flex-wrap: wrap;
  min-width: 0;
}

.top-nav-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.nav-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}

.nav-item:hover { background: rgba(59, 130, 246, 0.12); }

.nav-item.active {
  background: rgba(59, 130, 246, 0.22);
  color: var(--accent);
  font-weight: 600;
}

.nav-icon { font-size: 1rem; }

.btn-toolbar {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}

.btn-toolbar:hover { border-color: var(--accent); color: var(--accent); }

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

.btn-toolbar.btn-primary:hover { background: var(--accent-hover); }

.btn-logout { color: var(--muted); }

/* Pannello debug */
.debug-panel {
  flex-shrink: 0;
  max-height: 42vh;
  overflow: auto;
  background: #0a0e12;
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1rem;
}

.debug-panel-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.debug-panel-head h2 {
  font-size: 0.95rem;
  margin-right: auto;
}

.debug-status {
  font-size: 0.8rem;
  font-family: ui-monospace, monospace;
  color: var(--muted);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.debug-status .ok { color: var(--success); }
.debug-status .bad { color: #f87171; }

.debug-logs {
  font-size: 0.72rem;
  line-height: 1.45;
  color: #a8b8d0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.module-head {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(26, 35, 50, 0.6);
  flex-shrink: 0;
}

.module-head h1 { font-size: 1rem; }
.module-head .muted { font-size: 0.8rem; color: var(--muted); }

.module-frame-wrap {
  flex: 1;
  position: relative;
  background: #0a0e12;
  min-height: 0;
}

.module-frame {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.module-frame-wrap .module-frame {
  position: absolute;
  inset: 0;
}

.module-loading,
.module-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  color: var(--muted);
}

.module-error {
  flex-direction: column;
  color: #f87171;
}

.module-error p { margin-top: 0.5rem; color: var(--muted); max-width: 520px; }

.welcome-panel {
  padding: 2rem;
  color: var(--muted);
}

.welcome-panel h2 { color: var(--text); margin-bottom: 0.5rem; }

.error-text { color: #f87171; }

@media (max-width: 768px) {
  .top-nav {
    padding: 0.45rem 0.5rem;
    gap: 0.35rem;
    flex-wrap: nowrap;
  }
  .top-nav-brand strong { font-size: 0.9rem; }
  .user-badge { display: none; }
  .top-nav-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--bg); color: var(--text); font-size: 1.25rem; cursor: pointer; flex-shrink: 0;
  }
  .top-nav-menu {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(280px, 86vw);
    flex-direction: column; align-items: stretch; gap: 0.35rem;
    padding: 3.5rem 0.75rem 1rem;
    background: var(--surface); border-right: 1px solid var(--border);
    box-shadow: 8px 0 32px rgba(0,0,0,0.35);
    z-index: 2000; transform: translateX(-110%); transition: transform 0.2s ease;
    overflow-y: auto; flex-wrap: nowrap;
  }
  .top-nav-menu.open { transform: translateX(0); }
  .nav-item {
    width: 100%; justify-content: flex-start;
    padding: 0.75rem 1rem; font-size: 1rem;
  }
  .nav-item span:not(.nav-icon) { display: inline !important; }
  .nav-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1999;
  }
  .nav-overlay.hidden { display: none !important; }
  .top-nav-actions .btn-toolbar:not(.btn-logout):not(.btn-scan-mobile) { display: none; }
  .btn-scan-mobile {
    display: inline-flex !important; align-items: center; gap: 0.25rem;
    text-decoration: none; white-space: nowrap; font-size: 0.8rem;
  }
  .module-head { display: none; }
  .main-area { min-height: 0; }
}

@media (min-width: 769px) {
  .top-nav-toggle { display: none; }
  .btn-scan-mobile { display: none !important; }
}
