/* assets/css/app.css */
:root{
  --primary-500:#00c65e;
  --primary-600:#009e4a;
  --primary-400:#7ee2aa;

  --bg:#f8f8f8;
  --surface:#ffffff;
  --border:#e5e7eb;
  --text:#111827;
  --muted:#6b7280;
  --table-head:#f0f0f0;
  --table-head-color:#4b5563;

  --shadow: 0 12px 30px rgba(0,0,0,.08);
  --radius: 14px;
}

/* ===== DARK MODE ===== */
[data-theme="dark"]{
  --bg:#0f1117;
  --surface:#1a1d27;
  --border:#2d3148;
  --text:#e8eaf0;
  --muted:#8b93b0;
  --table-head:#1f2235;
  --table-head-color:#8b93b0;
  --shadow: 0 12px 30px rgba(0,0,0,.35);
}

/* ===== THEME TOGGLE BUTTON ===== */
.theme-toggle{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  transition: background .2s, border-color .2s;
}
.theme-toggle:hover{
  background: var(--border);
}
.theme-toggle__icon{ font-size: 15px; }

*{box-sizing:border-box}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Helvetica Neue";
  color:var(--text);
  background:var(--bg);
  transition: background .25s, color .25s;
}

a{color:inherit; text-decoration:none}
a:hover{text-decoration:none}

.app{
  display:grid;
  grid-template-columns: 280px 1fr;
  min-height:100vh;
}

/* ===== SIDEBAR ===== */
.sidebar{
  background: #0b2b2b;
  color:#fff;
  padding:18px;
  display:flex;
  flex-direction:column;
  gap:18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand{
  display:flex; align-items:center; gap:12px;
  padding:10px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.06);
}
.brand__logo{
  width:40px; height:40px; border-radius:12px;
  display:grid; place-items:center;
  font-weight:800;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-400));
  color:#003b20;
  flex-shrink: 0;
}
.brand__name{font-weight:800; letter-spacing:.2px}
.brand__sub{font-size:12px; opacity:.75}

.nav{display:flex; flex-direction:column; gap:6px}
.nav__item{
  padding:10px 12px;
  border-radius: 12px;
  color: rgba(255,255,255,.9);
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(255,255,255,.06);
  transition: background .15s, border-color .15s;
}
.nav__item:hover{
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.12);
}

.sidebar__footer{
  margin-top:auto;
  padding-top:14px;
  border-top: 1px solid rgba(255,255,255,.12);
  display:flex; flex-direction:column; gap:12px;
}

.userchip{
  display:flex; align-items:center; gap:10px;
  padding:10px;
  border-radius: 12px;
  background: rgba(255,255,255,.06);
}
.userchip__avatar{
  width:36px; height:36px; border-radius: 12px;
  display:grid; place-items:center;
  font-weight:800;
  background: rgba(0,198,94,.18);
  border: 1px solid rgba(0,198,94,.35);
  flex-shrink: 0;
}
.userchip__name{
  font-weight:700;
  font-size:14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}
.userchip__meta{font-size:12px; opacity:.7}

/* ===== TOPBAR HAMBURGER (mobile) ===== */
.topbar-mobile{
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #0b2b2b;
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 200;
}
.topbar-mobile__brand{
  display: flex; align-items: center; gap: 10px;
  font-weight: 800;
}
.topbar-mobile__logo{
  width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 800; font-size: 13px;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-400));
  color: #003b20;
}
.hamburger{
  background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; gap: 5px; padding: 4px;
}
.hamburger span{
  display: block; width: 22px; height: 2px;
  background: #fff; border-radius: 2px;
  transition: all .25s;
}

.sidebar-overlay{
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 150;
}
.sidebar-overlay.active{ display: block; }

/* Main */
.main{padding:22px; min-width:0;}
.topbar{
  display:flex; justify-content:space-between; align-items:flex-start;
  gap:16px;
  padding:18px 18px 0 18px;
  flex-wrap: wrap;
}
.topbar__title{
  font-size:22px;
  font-weight:900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.topbar__subtitle{color:var(--muted); margin-top:4px}

.pill{
  display:inline-flex; align-items:center; gap:8px;
  padding:8px 10px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size:12px;
}
.pill--ok{
  color:#0f5132;
  background: rgba(0,198,94,.10);
  border-color: rgba(0,198,94,.22);
}

.content{padding:18px}

/* ===== CARDS / GRID ===== */
.grid{
  display:grid;
  grid-template-columns: repeat(12, 1fr);
  gap:14px;
}
.card{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding:16px;
  transition: transform 0.2s, background .25s, border-color .25s;
  min-width: 0;
}
.card:hover{ transform: translateY(-3px); }
.card--stat{grid-column: span 3}
.card--wide{grid-column: span 12}
.card__label{color:var(--muted); font-size:12px}
.card__value{font-size:22px; font-weight:900; margin-top:6px}
.card__hint{color:var(--muted); font-size:12px; margin-top:10px}
.card-value{
  font-size:1.8rem; font-weight:bold;
  color:var(--primary-500); margin:10px 0;
}

/* ===== BUTTONS ===== */
.btn{
  display:inline-flex; align-items:center; justify-content:center;
  gap:8px;
  padding:10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor:pointer;
  font-weight:700;
  white-space: nowrap;
  color: var(--text);
  transition: background .2s, border-color .2s;
}
.btn--primary{
  background: var(--primary-500);
  border-color: var(--primary-500);
  color:#fff;
}
.btn--primary:hover{background: var(--primary-600); border-color: var(--primary-600);}
.btn--ghost{
  background: transparent;
  border-color: rgba(255,255,255,.18);
  color:#fff;
}
.btn--danger{
  background:#e53e3e;
  border-color:#e53e3e;
  color:#fff;
}
.btn--danger:hover{filter:brightness(.95);}

/* ===== FORMS ===== */
.field{display:flex; flex-direction:column; gap:6px; margin:10px 0;}
.input, select.input{
  width: 420px;
  max-width: 100%;
  padding:10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline:none;
  font-size: 14px;
  transition: background .25s, border-color .25s, color .25s;
}
.input:focus{
  border-color: rgba(0,198,94,.45);
  box-shadow: 0 0 0 4px rgba(0,198,94,.18);
}
.input-money{
  font-variant-numeric: tabular-nums;
  letter-spacing: .2px;
}

/* ===== TABLE ===== */
.table-wrap{
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.table{
  width:100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  min-width: 500px;
}
.table th, .table td{
  padding:12px;
  border-bottom:1px solid var(--border);
  text-align:left;
  font-size:14px;
  white-space: nowrap;
}
.table th{
  background: var(--table-head);
  font-size:12px;
  text-transform: uppercase;
  letter-spacing:.06em;
  color: var(--table-head-color);
}
.table tr:last-child td{border-bottom:0}
.table .actions a{margin-right:10px; color: var(--primary-600); font-weight:700;}
.table .actions a:hover{filter:brightness(.9);}

/* ===== ALERTS ===== */
.alert{
  padding:12px;
  border-radius: 12px;
  border:1px solid var(--border);
  background: var(--surface);
  margin: 10px 0 14px;
}
.alert--error{
  background: #fee2e2;
  border-color: #fecaca;
  color:#991b1b;
}
.alert--ok{
  background: rgba(0,198,94,.10);
  border-color: rgba(0,198,94,.22);
  color:#0f5132;
}

/* ===== LOGIN PAGE ===== */
body.login-page{
  min-height: 100vh;
  background: url('/smartfarm/assets/img/colheita.jpg') no-repeat center center fixed;
  background-size: cover;
}
body.login-page::before{
  content:"";
  position: fixed;
  inset: 0;
  background: linear-gradient(120deg, rgba(0,0,0,.55), rgba(0,0,0,.30));
  pointer-events: none;
  z-index: 0;
}
.login-shell{
  min-height: 100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 28px 16px;
  position: relative;
  z-index: 1;
}
.login-card{
  width: 460px;
  max-width: 100%;
  padding: 24px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 18px;
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow: 0 22px 70px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.35);
  color: rgba(255,255,255,.92);
}
.login-title{ font-size:26px; font-weight:900; margin:8px 0 0; color:rgba(255,255,255,.95); }
.login-sub{ color:rgba(255,255,255,.78); margin-top:4px; font-size:13px; }
.login-brand{ display:flex; align-items:center; gap:10px; margin-bottom:6px; }
.login-brand__logo{
  width:40px; height:40px; border-radius:14px;
  display:grid; place-items:center;
  font-weight:900;
  background: linear-gradient(135deg, var(--primary-500), var(--primary-400));
  color:#003b20;
}
.login-brand__name{ font-weight:900; color:rgba(255,255,255,.95); }
body.login-page .field label{ color:rgba(255,255,255,.85); }
body.login-page .input{
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.22);
  color: rgba(255,255,255,.95);
}
body.login-page .input::placeholder{ color:rgba(255,255,255,.65); }
body.login-page .input:focus{
  border-color: rgba(0,198,94,.55);
  box-shadow: 0 0 0 4px rgba(0,198,94,.25);
}
body.login-page .btn--primary{
  border: 1px solid rgba(255,255,255,.20);
  box-shadow: 0 14px 30px rgba(0,0,0,.22);
}
body.login-page .alert--error{
  background: rgba(239,68,68,.18);
  border-color: rgba(239,68,68,.35);
  color: rgba(255,255,255,.92);
}
body.login-page a{ color:rgba(126,226,170,.95); }
body.login-page a:hover{ filter:brightness(1.1); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1100px){
  .app{ grid-template-columns: 240px 1fr; }
  .card--stat{ grid-column: span 4; }
}

@media (max-width: 860px){
  .app{ grid-template-columns: 1fr; }
  .sidebar{
    position: fixed;
    left: -280px;
    top: 0; bottom: 0;
    width: 280px;
    z-index: 180;
    transition: left .25s ease;
    height: 100vh;
    height: 100dvh;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 32px;
  }
  .sidebar.open{ left: 0; }
  .topbar-mobile{ display: flex; }
  .main{ padding: 14px; }
  .topbar{ padding: 14px 14px 0; }
  .topbar__title{ font-size: 18px; }
  .content{ padding: 14px; }
  .card--stat{ grid-column: span 6; }
  .card--wide{ grid-column: span 12; }
  .input, select.input{ width: 100%; }
  .grid{ grid-template-columns: repeat(12, 1fr); gap: 10px; }
}

@media (max-width: 560px){
  .card--stat{ grid-column: span 12; }
  .topbar{ flex-direction: column; align-items: flex-start; gap: 10px; }
  .btn{ width: 100%; justify-content: center; }
  .btn + .btn, .btn + a.btn, a.btn + .btn{ margin-left: 0 !important; margin-top: 8px; }
  .table th, .table td{ font-size: 12px; padding: 8px; }
  .card{ padding: 12px; }
  .card__value{ font-size: 18px; }
  .input, select.input{ width: 100%; font-size: 16px; }
  .grid{ gap: 8px; }
  .grid > .card[style*="span 6"]{ grid-column: span 12 !important; }
}

/* ===== FORM SHARED STYLES ===== */
.field label { font-weight: 600; font-size: 14px; }
.field-hint  { color: var(--muted); font-size: 12px; }
.field-error { color: #dc2626; font-size: 12px; margin-top: 2px; }
.input--error{
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 4px rgba(239,68,68,.12) !important;
}
.input--valid{
  border-color: rgba(0,198,94,.55) !important;
  box-shadow: 0 0 0 4px rgba(0,198,94,.12) !important;
}
.form-row{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}
@media (max-width: 560px){
  .form-row{ grid-template-columns: 1fr; }
}
.nav__item--active{
  background: rgba(0,198,94,.15) !important;
  border-color: rgba(0,198,94,.30) !important;
  color: var(--primary-400) !important;
  font-weight: 700;
}
/* ===== DARK MODE INPUTS ===== */
[data-theme="dark"] .input,
[data-theme="dark"] select.input {
  background: #1f2235;
  border-color: #2d3148;
  color: #e8eaf0;
}

[data-theme="dark"] .input::placeholder {
  color: #4a5080;
}

[data-theme="dark"] .input:focus {
  border-color: rgba(0,198,94,.5);
  box-shadow: 0 0 0 4px rgba(0,198,94,.12);
  background: #252840;
}

[data-theme="dark"] .field label {
  color: #c8cde0;
}

[data-theme="dark"] small {
  color: #5a6080 !important;
}

[data-theme="dark"] .card {
  background: #1a1d27;
  border-color: #2d3148;
}

[data-theme="dark"] .btn {
  background: #1f2235;
  border-color: #2d3148;
  color: #e8eaf0;
}

[data-theme="dark"] .btn:hover {
  background: #252840;
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 8px 30px rgba(0,0,0,.2);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  pointer-events: all;
  animation: toastIn .3s ease;
  min-width: 260px;
  max-width: 380px;
}
.toast--success {
  border-left: 4px solid #22c55e;
  background: var(--surface);
}
.toast--error {
  border-left: 4px solid #ef4444;
  background: var(--surface);
}
.toast--info {
  border-left: 4px solid #3b82f6;
  background: var(--surface);
}
.toast__icon { font-size: 18px; flex-shrink: 0; }
.toast__msg  { flex: 1; }
.toast__close {
  background: none; border: none; cursor: pointer;
  color: var(--muted); font-size: 16px; padding: 0;
  line-height: 1; flex-shrink: 0;
}
.toast__close:hover { color: var(--text); }
.toast__progress {
  position: absolute;
  bottom: 0; left: 0;
  height: 3px;
  background: #22c55e;
  border-radius: 0 0 0 12px;
  animation: toastProgress 3s linear forwards;
}
.toast--error .toast__progress   { background: #ef4444; }
.toast--info  .toast__progress   { background: #3b82f6; }

@keyframes toastIn {
  from { opacity:0; transform: translateX(40px); }
  to   { opacity:1; transform: translateX(0); }
}
@keyframes toastOut {
  from { opacity:1; transform: translateX(0); }
  to   { opacity:0; transform: translateX(40px); }
}
@keyframes toastProgress {
  from { width: 100%; }
  to   { width: 0%; }
}

/* ===== BUTTON LOADING ===== */
.btn--loading {
  opacity: .7;
  pointer-events: none;
  position: relative;
}
.btn--loading::after {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
  margin-left: 8px;
  vertical-align: middle;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 560px) {
  .toast-wrap { bottom: 16px; right: 16px; left: 16px; }
  .toast { min-width: unset; }
}

/* ===== BREADCRUMB ===== */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}
.breadcrumb__link {
  font-size: 12px;
  color: var(--muted);
  text-decoration: none;
  transition: color .15s;
}
.breadcrumb__link:hover { color: var(--primary-500); }
.breadcrumb__sep {
  font-size: 12px;
  color: var(--muted);
  opacity: .5;
}
.breadcrumb__current {
  font-size: 12px;
  color: var(--primary-500);
  font-weight: 700;
}

/* ===== NAV ITEM ACTIVE ===== */
.nav__item--active {
  background: rgba(0,198,94,.15) !important;
  border-color: rgba(0,198,94,.30) !important;
  color: var(--primary-400) !important;
  font-weight: 700;
}
/* Separador "ou" na tela de login */
.login-card .login-divider {
  display: flex !important;
  align-items: center;
  margin: 16px 0;
  color: var(--muted);
  font-size: 13px;
}
.login-card .login-divider::before,
.login-card .login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}
.login-card .login-divider span {
  padding: 0 12px;
  white-space: nowrap;
}

/* Botão "Entrar com Google" */
.login-card .btn--google {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 4px;
  background: #fff;
  color: #3c4043;
  border: 1px solid var(--border);
  font-weight: 700;
  text-decoration: none;
}
.login-card .btn--google:hover {
  background: #f7f8fa;
}
.login-card .btn--google svg {
  flex-shrink: 0;
}

/* ===== CARDS DE LARGURA FIXA RESPONSIVOS (substitui grid-column inline) ===== */
.card--half{ grid-column: span 6; }
.kpi-card--wide4{ grid-column: span 4; }
.destaques-grid{ display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

@media (max-width: 860px) {
  .kpi-card--wide4{ grid-column: span 6; }
}
@media (max-width: 560px) {
  .card--half{ grid-column: span 12; }
  .kpi-card--wide4{ grid-column: span 12; }
  .destaques-grid{ grid-template-columns: 1fr; }
}