/* ============================================================
   NACIONAL FERTILIZANTES - Sistema Interno
   Design System Principal
   ============================================================ */

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

/* ---- CSS Variables ---- */
:root {
  /* Cores Institucionais */
  --green-900: #0d3318;
  --green-800: #1a5c2a;
  --green-700: #1e6b30;
  --green-600: #2d8a3e;
  --green-500: #3aaa50;
  --green-400: #5cb85c;
  --green-300: #85cc85;
  --green-200: #b3e0b3;
  --green-100: #e0f4e0;
  --green-50:  #f2fbf2;

  /* Neutros */
  --gray-900: #111827;
  --gray-800: #1f2937;
  --gray-700: #374151;
  --gray-600: #4b5563;
  --gray-500: #6b7280;
  --gray-400: #9ca3af;
  --gray-300: #d1d5db;
  --gray-200: #e5e7eb;
  --gray-100: #f3f4f6;
  --gray-50:  #f9fafb;

  /* Status */
  --blue-600:   #2563eb;
  --blue-100:   #dbeafe;
  --yellow-600: #d97706;
  --yellow-100: #fef3c7;
  --red-600:    #dc2626;
  --red-100:    #fee2e2;

  /* Layout */
  --sidebar-w:  240px;
  --header-h:   64px;
  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:  0 4px 12px rgba(0,0,0,.10), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg:  0 10px 30px rgba(0,0,0,.12);

  /* Typography */
  --font: 'Inter', sans-serif;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font);
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: var(--font); font-size: inherit; }

/* ============================================================
   TELA DE LOGIN
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: stretch;
}
.login-visual {
  flex: 0 0 45%;
  background: linear-gradient(160deg, var(--green-900) 0%, var(--green-800) 50%, var(--green-700) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 2.5rem;
  position: relative;
  overflow: hidden;
}
.login-visual::before {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  border: 60px solid rgba(255,255,255,.04);
  top: -100px; right: -100px;
}
.login-visual::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  border: 40px solid rgba(255,255,255,.04);
  bottom: -80px; left: -60px;
}
.login-visual img { width: 220px; margin-bottom: 2rem; position: relative; z-index: 1; }
.login-visual p {
  color: rgba(255,255,255,.7);
  font-size: .9rem;
  text-align: center;
  position: relative;
  z-index: 1;
  max-width: 260px;
  line-height: 1.7;
}
.login-form-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 2rem;
}
.login-box { width: 100%; max-width: 380px; }
.login-box h1 { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); margin-bottom: .4rem; }
.login-box .subtitle { color: var(--gray-500); font-size: .9rem; margin-bottom: 2rem; }

/* ============================================================
   LAYOUT PRINCIPAL (sidebar + conteúdo)
   ============================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--green-900);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .3s ease;
}
.sidebar-logo {
  padding: 1.25rem 1.2rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  background: transparent;
}
.sidebar-logo img { width: 150px; display: block; background: transparent; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem 0; }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .65rem 1.2rem;
  color: rgba(255,255,255,.65);
  font-size: .875rem;
  font-weight: 500;
  transition: all .2s;
  position: relative;
}
.sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,.06); }
.sidebar-nav a.active {
  color: #fff;
  background: rgba(255,255,255,.1);
}
.sidebar-nav a.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--green-400);
  border-radius: 0 3px 3px 0;
}
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-section {
  padding: .3rem 1.2rem .1rem;
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: rgba(255,255,255,.3);
  margin-top: .5rem;
}
.sidebar-footer {
  padding: 1rem 1.2rem;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin-bottom: .6rem;
}
.sidebar-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--green-600);
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-user-name { font-size: .8rem; font-weight: 600; color: #fff; line-height: 1.2; }
.sidebar-user-role { font-size: .7rem; color: rgba(255,255,255,.45); }
.btn-logout {
  display: flex; align-items: center; gap: .5rem;
  width: 100%; padding: .5rem .8rem;
  background: rgba(255,255,255,.06);
  border: none; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.6);
  font-size: .8rem; cursor: pointer;
  transition: all .2s;
}
.btn-logout:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ---- Main content ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.topbar {
  height: var(--header-h);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1rem; font-weight: 600; color: var(--gray-900); flex: 1; }
.topbar-badge {
  font-size: .75rem; padding: .2rem .7rem;
  background: var(--green-100); color: var(--green-800);
  border-radius: 20px; font-weight: 600;
}
.page-body { padding: 1.5rem; flex: 1; }

/* ============================================================
   COMPONENTES
   ============================================================ */

/* ---- Cards ---- */
.card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; gap: .75rem;
}
.card-title { font-size: .95rem; font-weight: 600; color: var(--gray-900); }
.card-body { padding: 1.25rem; }
.card-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ---- Stats Cards (Dashboard) ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.stat-card {
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: .75rem;
}
.stat-icon.green { background: var(--green-100); color: var(--green-700); }
.stat-icon.blue  { background: var(--blue-100); color: var(--blue-600); }
.stat-icon.yellow{ background: var(--yellow-100); color: var(--yellow-600); }
.stat-icon.red   { background: var(--red-100); color: var(--red-600); }
.stat-value { font-size: 1.7rem; font-weight: 700; color: var(--gray-900); line-height: 1; }
.stat-label { font-size: .78rem; color: var(--gray-500); margin-top: .25rem; font-weight: 500; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius-sm);
  border: none; cursor: pointer;
  font-size: .875rem; font-weight: 500;
  transition: all .2s; line-height: 1;
  white-space: nowrap;
}
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--green-700); color: #fff; }
.btn-primary:hover { background: var(--green-800); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-danger { background: var(--red-100); color: var(--red-600); }
.btn-danger:hover { background: #fecaca; }
.btn-outline { background: transparent; color: var(--green-700); border: 1.5px solid var(--green-400); }
.btn-outline:hover { background: var(--green-50); }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: .95rem; }
.btn-icon { padding: .4rem; border-radius: var(--radius-sm); background: var(--gray-50); border: 1px solid var(--gray-200); color: var(--gray-500); cursor: pointer; transition: all .2s; display:inline-flex; align-items:center; justify-content:center; }
.btn-icon:hover { background: var(--gray-100); color: var(--gray-900); border-color: var(--gray-300); }
.btn-icon svg { width: 16px; height: 16px; display:block; flex-shrink:0; }

/* ---- Forms ---- */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: .8rem; font-weight: 600;
  color: var(--gray-700);
  margin-bottom: .35rem;
  text-transform: uppercase; letter-spacing: .04em;
}
.form-label .required { color: var(--red-600); margin-left: 2px; }
.form-control {
  width: 100%;
  padding: .6rem .85rem;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  color: var(--gray-800);
  font-size: .9rem;
  transition: border-color .2s, box-shadow .2s;
  outline: none;
}
.form-control:focus {
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(58, 170, 80, .12);
}
.form-control:disabled { background: var(--gray-50); color: var(--gray-500); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-hint { font-size: .75rem; color: var(--gray-400); margin-top: .25rem; }
.form-error { font-size: .75rem; color: var(--red-600); margin-top: .25rem; }
.form-row { display: grid; gap: 1rem; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ---- Section divider ---- */
.form-section { margin-bottom: 1.5rem; }
.form-section-title {
  font-size: .75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--green-700);
  padding-bottom: .5rem;
  border-bottom: 2px solid var(--green-100);
  margin-bottom: 1rem;
  display: flex; align-items: center; gap: .5rem;
}
.form-section-title svg { width: 16px; height: 16px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-lg); border: 1px solid var(--gray-200); }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
thead th {
  background: var(--gray-50);
  padding: .7rem 1rem;
  text-align: left;
  font-size: .75rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
tbody td { padding: .75rem 1rem; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: .2rem .65rem;
  border-radius: 20px;
  font-size: .72rem; font-weight: 600;
  white-space: nowrap;
}
.badge-green   { background: var(--green-100); color: var(--green-800); }
.badge-blue    { background: var(--blue-100); color: var(--blue-600); }
.badge-yellow  { background: var(--yellow-100); color: var(--yellow-600); }
.badge-red     { background: var(--red-100); color: var(--red-600); }
.badge-gray    { background: var(--gray-100); color: var(--gray-600); }

/* ---- Alerts ---- */
.alert {
  padding: .8rem 1rem;
  border-radius: var(--radius-md);
  font-size: .875rem;
  margin-bottom: 1rem;
  display: flex; align-items: flex-start; gap: .6rem;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: .05rem; }
.alert-success { background: var(--green-100); color: var(--green-800); border: 1px solid var(--green-200); }
.alert-danger  { background: var(--red-100); color: var(--red-600); border: 1px solid #fecaca; }
.alert-info    { background: var(--blue-100); color: var(--blue-600); border: 1px solid #bfdbfe; }
.alert-warning { background: var(--yellow-100); color: var(--yellow-600); border: 1px solid #fde68a; }

/* ---- Breadcrumb ---- */
.breadcrumb {
  display: flex; align-items: center; gap: .4rem;
  font-size: .8rem; color: var(--gray-400);
  margin-bottom: 1.2rem;
}
.breadcrumb a { color: var(--green-600); }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { color: var(--gray-700); font-weight: 500; }

/* ---- Empty state ---- */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--gray-400);
}
.empty-state svg { width: 48px; height: 48px; margin: 0 auto 1rem; color: var(--gray-300); }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--gray-600); margin-bottom: .35rem; }
.empty-state p  { font-size: .875rem; }

/* ---- Page header ---- */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; gap: 1rem;
  flex-wrap: wrap;
}
.page-header-left h2 { font-size: 1.2rem; font-weight: 700; color: var(--gray-900); }
.page-header-left p  { font-size: .85rem; color: var(--gray-500); margin-top: .15rem; }

/* ---- Filters bar ---- */
.filters-bar {
  display: flex; align-items: center; gap: .75rem;
  flex-wrap: wrap; margin-bottom: 1.25rem;
}
.filters-bar .form-control { max-width: 200px; padding: .45rem .75rem; }
.search-input { max-width: 280px !important; }

/* ---- Proposal items table ---- */
.items-table { border: 1.5px solid var(--gray-200); border-radius: var(--radius-md); overflow: hidden; }
.items-table thead th { background: var(--green-900); color: rgba(255,255,255,.85); border: none; }
.items-table tbody tr:hover { background: var(--green-50); }
.items-table input { border: 1px solid var(--gray-200); border-radius: var(--radius-sm); padding: .3rem .5rem; width: 100%; font-size: .8rem; }
.items-table input:focus { outline: none; border-color: var(--green-500); }

/* ---- Totals box ---- */
.totals-box {
  background: var(--green-900);
  color: #fff;
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex; justify-content: flex-end;
  gap: 2rem;
  margin-top: .5rem;
}
.totals-box .total-item { text-align: right; }
.totals-box .total-label { font-size: .75rem; color: rgba(255,255,255,.6); }
.totals-box .total-value { font-size: 1.1rem; font-weight: 700; }
.totals-box .total-value.main { font-size: 1.4rem; color: var(--green-300); }

/* ---- Modal ---- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto;
  transform: scale(.96); transition: transform .2s;
}
.modal-overlay.active .modal { transform: scale(1); }
.modal-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: .75rem 1.25rem; border-top: 1px solid var(--gray-100); display: flex; justify-content: flex-end; gap: .5rem; }

/* ---- Status colors ---- */
.status-rascunho  { background: var(--gray-100); color: var(--gray-600); }
.status-emitida   { background: var(--blue-100); color: var(--blue-600); }
.status-aprovada  { background: var(--green-100); color: var(--green-800); }
.status-cancelada { background: var(--red-100); color: var(--red-600); }

/* ---- Utilities ---- */
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-muted   { color: var(--gray-500); }
.text-small   { font-size: .8rem; }
.text-green   { color: var(--green-700); }
.fw-600       { font-weight: 600; }
.fw-700       { font-weight: 700; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
  .login-visual { display: none; }
  .form-row.cols-2, .form-row.cols-3, .form-row.cols-4 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-body { padding: 1rem; }
}

/* Logo transparente (PNG/SVG com fundo transparente) */
.sidebar-logo.transparent-logo {
  background: transparent;
}
.sidebar-logo.transparent-logo img {
  filter: brightness(0) invert(1); /* torna qualquer logo branca */
}
