/* ── Agrotech Tools – CSS global ─────────────────────────────────── */

/* Variáveis de marca */
:root {
  --at-orange:      #BF4000;
  --at-orange-light:#E86020;
  --at-orange-pale: #FFF0E0;
  --at-dark:        #1a1a1a;
  --at-dark-soft:   #2c2c2c;
  --at-gray:        #f4f6f9;

  /* Override Bootstrap primary → laranja Agrotech */
  --bs-primary:             #BF4000;
  --bs-primary-rgb:         191, 64, 0;
  --bs-link-color:          #BF4000;
  --bs-link-hover-color:    #8C2D00;
}

/* ── Geral ──────────────────────────────────────────────────────── */
html {
  scroll-behavior: smooth;
}

body {
  background-color: #f4f6f9;
  font-size: 0.93rem;
}

/* Scrollbar customizada */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(191,64,0,.35) transparent;
}
*::-webkit-scrollbar { width: 7px; height: 7px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(191,64,0,.30);
  border-radius: 10px;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(191,64,0,.50); }

/* Force Bootstrap primary overrides */
.bg-primary           { background-color: var(--at-orange)  !important; }
.text-primary         { color: var(--at-orange)             !important; }
.border-primary       { border-color: var(--at-orange)      !important; }
.btn-primary          { background-color: var(--at-orange); border-color: var(--at-orange); }
.btn-primary:hover    { background-color: #8C2D00; border-color: #8C2D00; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(191,64,0,.30); }
.btn-primary:focus,
.btn-primary:active   { background-color: #8C2D00; border-color: #8C2D00; box-shadow: 0 0 0 0.2rem rgba(191,64,0,.35); }
.btn-outline-primary  { color: var(--at-orange); border-color: var(--at-orange); }
.btn-outline-primary:hover { background-color: var(--at-orange); border-color: var(--at-orange); color:#fff; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(191,64,0,.25); }
.bg-primary-subtle    { background-color: var(--at-orange-pale) !important; }

/* Transição suave global para botões */
.btn {
  transition: all 0.2s ease;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--at-orange);
  box-shadow: 0 0 0 0.18rem rgba(230,81,0,.18);
}

/* Foco acessível para elementos interativos */
a:focus-visible,
button:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible {
  outline: 2px solid var(--at-orange);
  outline-offset: 2px;
}

/* ── Animações utilitárias ───────────────────────────────────────── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
@keyframes slideInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.animate-fade-in-up {
  animation: fadeInUp 0.4s ease-out both;
}
.animate-fade-in {
  animation: fadeIn 0.3s ease-out both;
}

/* ── Navbar (base.html) ─────────────────────────────────────────── */
.navbar-brand {
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}
nav.navbar.bg-primary {
  background: linear-gradient(135deg, var(--at-dark) 0%, var(--at-dark-soft) 100%) !important;
  border-bottom: 3px solid var(--at-orange);
}

/* ── Cards de ferramenta (index) ─────────────────────────────────  */
.card-ferramenta {
  border-radius: 12px !important;
  transition: transform 0.22s ease, box-shadow 0.22s ease, border-color 0.22s ease;
  border-top: 3px solid transparent !important;
  overflow: hidden;
}
.card-ativa {
  cursor: pointer;
}
.card-ativa:hover {
  transform: translateY(-6px);
  box-shadow: 0 12px 32px rgba(0,0,0,.12) !important;
  border-top-color: var(--at-orange) !important;
}
.card-breve {
  opacity: 0.60;
  filter: grayscale(0.15);
}
.card-breve:hover {
  opacity: 0.78;
  filter: grayscale(0);
}
.icone-ferramenta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 16px;
  margin: 0 auto;
  transition: transform 0.2s ease;
}
.card-ativa:hover .icone-ferramenta {
  transform: scale(1.08);
}

/* ── Formulário ─────────────────────────────────────────────────── */
.card {
  border-radius: 10px !important;
  box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
}
.card-header {
  border-radius: 10px 10px 0 0 !important;
  font-size: 0.88rem;
  letter-spacing: 0.03em;
}

label.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #495057;
  margin-bottom: 4px;
}
label.required::after {
  content: " *";
  color: #dc3545;
}

/* ── Testemunha card ────────────────────────────────────────────── */
.witness-card {
  background-color: #fafbfc;
  border-color: #dee2e6 !important;
  transition: box-shadow 0.15s;
}
.witness-card:hover {
  box-shadow: 0 2px 10px rgba(0,0,0,.07);
}
.witness-card input[data-field="role"] {
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px dashed #adb5bd;
  background-color: transparent;
  color: var(--at-orange);
}
.witness-card input[data-field="role"]:focus {
  border-style: solid;
  background-color: #fff;
}
.witness-card .form-label.small {
  color: #6c757d;
  font-size: 0.76rem;
}

/* ── Botão gerar ────────────────────────────────────────────────── */
.btn-primary.btn-lg {
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* ── Footer ─────────────────────────────────────────────────────── */
footer {
  font-size: 0.78rem;
}

/* ── Login ──────────────────────────────────────────────────────── */
.login-bg {
  min-height: 100vh;
  background: #f4f6f9;
}
.login-card {
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: rgba(255,255,255,.85) !important;
  border: 1px solid rgba(255,255,255,.6) !important;
  animation: slideInUp 0.5s ease-out both;
}
.login-card .card-body {
  position: relative;
}
.login-logo {
  transition: transform 0.3s ease;
}
.login-logo:hover {
  transform: scale(1.05);
}
.password-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #6c757d;
  cursor: pointer;
  z-index: 5;
  padding: 4px;
  font-size: 1rem;
  transition: color 0.15s;
}
.password-toggle:hover {
  color: var(--at-orange);
}

/* ══════════════════════════════════════════════════════════════════
   SHELL – Sistema de Abas
══════════════════════════════════════════════════════════════════ */

/* O html/body da shell ocupa a tela inteira */
html:has(.shell-body),
.shell-body {
  height: 100%;
  overflow: hidden;
  margin: 0;
  padding: 0;
}
.shell-body {
  display: flex;
  flex-direction: column;
  background: #f4f6f9;
}

/* ── Barra superior ─────────────────────────────────────────────── */
.shell-topbar {
  display: flex;
  align-items: stretch;
  height: 48px;
  min-height: 48px;
  background: var(--at-dark);
  border-bottom: 3px solid var(--at-orange);
  box-shadow: 0 2px 8px rgba(0,0,0,.30);
  z-index: 1030;
  flex-shrink: 0;
  /* overflow: visible permite que o dropdown apareça abaixo da barra */
  overflow: visible;
  position: relative;
}

/* ── Marca / logo ───────────────────────────────────────────────── */
.shell-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: none;
  border: none;
  border-right: 1px solid rgba(255,255,255,.12);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
  white-space: nowrap;
}
.shell-brand:hover { background: rgba(255,255,255,.08); }

.shell-brand .brand-logo-wrap {
  display: flex;
  align-items: center;
  background: #fff;
  border-radius: 6px;
  padding: 4px 8px;
  flex-shrink: 0;
}
.shell-brand .brand-logo {
  width: auto;
  height: 40px;
  object-fit: contain;
  display: block;
}
.shell-brand .brand-name {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.shell-brand .brand-name span:first-child {
  font-size: .82rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: .04em;
}
.shell-brand .brand-name span:last-child {
  font-size: .62rem;
  color: var(--at-orange-light);
  font-weight: 400;
  letter-spacing: .02em;
}

/* ── Aba fixa (Menu) ────────────────────────────────────────────── */
#fixedTabArea {
  display: flex;
  align-items: flex-end;
  flex-shrink: 0;
  padding: 0 2px;
}

/* ── Área de abas rolantes (flex: 1 absorve o espaço disponível) ── */
.shell-tabs-area {
  flex: 1 1 0;        /* cresce para preencher; pode encolher */
  min-width: 0;       /* permite encolher abaixo do conteúdo  */
  display: flex;
  align-items: stretch;
  overflow: hidden;   /* abas não saem desta área             */
}

/* ── Botões de scroll < > ───────────────────────────────────────── */
.shell-scroll-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  min-width: 26px;
  background: none;
  border: none;
  color: rgba(255,255,255,.65);
  font-size: 0.85rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.shell-scroll-btn:hover {
  color: var(--at-orange-light);
  background: rgba(255,255,255,.1);
}

/* ── Faixa de abas (dentro da área de scroll) ───────────────────── */
.shell-tab-strip {
  display: flex;
  align-items: flex-end;
  flex: 1 1 0;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  padding: 0 2px;
  gap: 2px;
}
.shell-tab-strip::-webkit-scrollbar { display: none; }

/* ── Aba individual ─────────────────────────────────────────────── */
.shell-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 8px 0 10px;
  height: 38px;
  margin-top: auto;
  min-width: 100px;
  max-width: 180px;
  background: rgba(255,255,255,.10);
  color: rgba(255,255,255,.75);
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 0.78rem;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
  position: relative;
}
.shell-tab:hover {
  background: rgba(255,255,255,.18);
  color: #fff;
}
.shell-tab.active {
  background: #f4f6f9;
  color: var(--at-orange);
  font-weight: 600;
  box-shadow: inset 0 -3px 0 var(--at-orange);
}
/* Aba fixada (Menu) */
.shell-tab.pinned {
  min-width: 80px;
  max-width: 110px;
}
.shell-tab.pinned.active {
  border-left: 2px solid var(--at-orange);
}

.tab-icon { font-size: 0.82rem; flex-shrink: 0; }
.tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.tab-close-btn {
  background: none;
  border: none;
  color: inherit;
  padding: 1px 2px;
  font-size: 1rem;
  line-height: 1;
  border-radius: 4px;
  flex-shrink: 0;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.1s, background 0.1s;
}
.tab-close-btn:hover { opacity: 1; background: rgba(0,0,0,.12); }
.shell-tab.active .tab-close-btn:hover { background: rgba(230,81,0,.15); }

/* ── Controles (tema + usuário) — ficam sempre no lado direito ──── */
.shell-controls {
  display: flex;
  align-items: center;
  flex-shrink: 0;       /* nunca encolhe nem sai da tela */
  padding: 0 14px 0 4px;
  border-left: 1px solid rgba(255,255,255,.12);
  gap: 0;
}

/* ── Conteúdo (iframes) ─────────────────────────────────────────── */
.shell-content {
  flex: 1;
  position: relative;
  overflow: hidden;
}
.shell-iframe {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border: 0;
  display: none;
}

/* ══════════════════════════════════════════════════════════════════
   SHELL – Responsividade mobile
══════════════════════════════════════════════════════════════════ */

/* Tablet (≤768px): esconde texto do brand, mantém logo */
@media (max-width: 768px) {
  .shell-brand .brand-name { display: none; }
  .shell-brand { padding: 0 8px; gap: 0; border-right: 1px solid rgba(255,255,255,.10); }
  .shell-tab { min-width: 72px; max-width: 130px; font-size: 0.74rem; }
  .shell-controls { padding: 0 8px 0 4px; }
}

/* Mobile pequeno (≤576px): comprime bastante */
@media (max-width: 576px) {
  .shell-topbar { height: 48px; min-height: 48px; }
  .shell-brand .brand-logo { height: 28px; }
  .shell-brand { padding: 0 6px; }
  /* Abas só mostram ícone no mobile – label some */
  .shell-tab .tab-label { display: none; }
  .shell-tab { min-width: 38px; max-width: 44px; padding: 0 6px; gap: 0; }
  .shell-tab.pinned { min-width: 44px; max-width: 52px; padding: 0 8px; }
  .shell-tab.pinned .tab-label { display: inline; font-size: 0.70rem; }
  .tab-close-btn { font-size: 0.85rem; padding: 1px 1px; }
  /* Esconde o toggle de tema no mobile */
  .shell-controls .form-check { display: none !important; }
  /* Esconde nome do usuário – só ícone */
  .shell-controls .d-none.d-md-inline { display: none !important; }
  /* Reduz padding dos controles */
  .shell-controls { padding: 0 6px 0 4px; gap: 0; }
}

/* Mobile muito pequeno (≤400px) */
@media (max-width: 400px) {
  .shell-brand .brand-logo { height: 24px; }
  .shell-brand { padding: 0 4px; }
  .shell-tab { min-width: 32px; max-width: 40px; padding: 0 5px; }
  .shell-tab.pinned { min-width: 38px; max-width: 46px; }
}

/* ── Cards de ferramenta – responsivo mobile ────────────────────── */
/* 2 colunas em telas pequenas */
@media (max-width: 575px) {
  .card-ferramenta .card-body { padding: 0.75rem !important; }
  .icone-ferramenta { width: 54px; height: 54px; border-radius: 12px; }
  .icone-ferramenta .fs-1 { font-size: 1.6rem !important; }
  .card-ferramenta .card-title { font-size: 0.82rem; }
  .card-ferramenta .card-text { font-size: 0.72rem; }
}

/* ── Container de conteúdo dentro de iframe – mobile ────────────── */
@media (max-width: 575px) {
  body.in-iframe .container,
  body.in-iframe .container-fluid {
    padding-left: 0.6rem !important;
    padding-right: 0.6rem !important;
  }
  body.in-iframe .container.py-4 {
    padding-top: 0.75rem !important;
    padding-bottom: 0.75rem !important;
  }
}

/* ══════════════════════════════════════════════════════════════════
   MODO IFRAME – Oculta navbar e footer dentro das abas
══════════════════════════════════════════════════════════════════ */

body.in-iframe > nav.navbar,
body.in-iframe > footer {
  display: none !important;
}

body.in-iframe .container.py-4 {
  padding-top: 1.25rem !important;
  padding-bottom: 1.25rem !important;
}

/* ── LL% color badge (dinâmico por config) ─────────────────────── */
.ll-badge-excellent { background: #0d6efd !important; color: #fff !important; }
.ll-badge-good      { background: #198754 !important; color: #fff !important; }
.ll-badge-regular   { background: #ffc107 !important; color: #000 !important; }
.ll-badge-critical  { background: #dc3545 !important; color: #fff !important; }
