/* ============================================================
   Gestão de Estoque - Construtora & Terraplanagem
   Paleta: Azul Escuro #0f2444 | Azul Médio #1a3a6e | Cinza #6b7280
           Branco #ffffff | Fundo #f1f5f9
   ============================================================ */

/* ── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue-dark  : #0f2444;
  --blue-mid   : #1a3a6e;
  --blue-light : #2563eb;
  --blue-bg    : #e8f0fe;
  --gray-600   : #6b7280;
  --gray-300   : #d1d5db;
  --gray-100   : #f3f4f6;
  --white      : #ffffff;
  --bg         : #f1f5f9;
  --danger     : #dc2626;
  --danger-bg  : #fef2f2;
  --warning    : #d97706;
  --warning-bg : #fffbeb;
  --success    : #16a34a;
  --success-bg : #f0fdf4;
  --radius     : 12px;
  --shadow     : 0 2px 12px rgba(15,36,68,.10);
  --shadow-lg  : 0 8px 32px rgba(15,36,68,.15);
  --transition : .18s ease;
  --font       : 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html  { font-size: 16px; scroll-behavior: smooth; }
body  {
  font-family   : var(--font);
  background    : var(--bg);
  color         : #1e293b;
  min-height    : 100vh;
  display       : flex;
  flex-direction: column;
}

/* ── Sidebar / Topbar layout ──────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

/* Sidebar desktop */
.sidebar {
  width            : 240px;
  background       : var(--blue-dark);
  display          : flex;
  flex-direction   : column;
  position         : fixed;
  top              : 0; left: 0;
  height           : 100vh;
  z-index          : 200;
  transition       : transform var(--transition);
}
.sidebar-logo {
  padding     : 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.10);
}
.sidebar-logo .logo-icon {
  width       : 44px; height: 44px;
  background  : var(--blue-light);
  border-radius: 10px;
  display     : flex; align-items: center; justify-content: center;
  font-size   : 22px;
  margin-bottom: 10px;
}
.sidebar-logo h1 {
  color      : var(--white);
  font-size  : 14px;
  font-weight: 700;
  line-height: 1.3;
}
.sidebar-logo span {
  color    : rgba(255,255,255,.55);
  font-size: 11px;
  display  : block;
  margin-top: 2px;
}

.sidebar-nav { padding: 12px 0; flex: 1; overflow-y: auto; }
.sidebar-nav a {
  display        : flex;
  align-items    : center;
  gap            : 12px;
  padding        : 13px 20px;
  color          : rgba(255,255,255,.70);
  text-decoration: none;
  font-size      : 14px;
  font-weight    : 500;
  transition     : background var(--transition), color var(--transition);
  border-left    : 3px solid transparent;
}
.sidebar-nav a .nav-icon { font-size: 18px; min-width: 20px; text-align: center; }
.sidebar-nav a:hover  { background: rgba(255,255,255,.07); color: var(--white); }
.sidebar-nav a.active {
  background  : rgba(37,99,235,.25);
  color       : var(--white);
  border-left : 3px solid var(--blue-light);
}

/* Main content area */
.main-content {
  margin-left: 240px;
  flex       : 1;
  display    : flex;
  flex-direction: column;
  min-height : 100vh;
}

/* Top header bar */
.topbar {
  background  : var(--white);
  padding     : 16px 28px;
  display     : flex;
  align-items : center;
  justify-content: space-between;
  box-shadow  : 0 1px 4px rgba(15,36,68,.08);
  position    : sticky; top: 0; z-index: 100;
}
.topbar h2 { font-size: 20px; font-weight: 700; color: var(--blue-dark); }
.topbar .topbar-right { display: flex; align-items: center; gap: 12px; }
.btn-menu-mobile {
  display   : none;
  background: none; border: none; cursor: pointer;
  font-size : 22px; color: var(--blue-dark);
  padding   : 4px;
}

/* Page body */
.page-body { padding: 28px; flex: 1; }

/* ── Cards ────────────────────────────────────────────────── */
.cards-grid {
  display              : grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap                  : 18px;
  margin-bottom        : 28px;
}
.card {
  background   : var(--white);
  border-radius: var(--radius);
  padding      : 22px 20px;
  box-shadow   : var(--shadow);
  display      : flex;
  flex-direction: column;
  gap          : 6px;
}
.card-icon {
  width        : 46px; height: 46px;
  border-radius: 10px;
  display      : flex; align-items: center; justify-content: center;
  font-size    : 22px;
  margin-bottom: 6px;
}
.card-icon.blue    { background: var(--blue-bg); }
.card-icon.green   { background: var(--success-bg); }
.card-icon.orange  { background: var(--warning-bg); }
.card-icon.red     { background: var(--danger-bg); }

.card-label { font-size: 12px; color: var(--gray-600); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.card-value { font-size: 30px; font-weight: 700; color: var(--blue-dark); line-height: 1.1; }

/* ── Alert section ────────────────────────────────────────── */
.alert-section {
  background   : var(--danger-bg);
  border       : 1.5px solid #fca5a5;
  border-radius: var(--radius);
  padding      : 20px 24px;
  margin-bottom: 28px;
}
.alert-section.hidden { display: none; }
.alert-section h3 {
  color       : var(--danger);
  font-size   : 15px;
  font-weight : 700;
  margin-bottom: 14px;
  display     : flex; align-items: center; gap: 8px;
}
.alert-table-wrap { overflow-x: auto; }

/* ── Sections ─────────────────────────────────────────────── */
.section {
  background   : var(--white);
  border-radius: var(--radius);
  box-shadow   : var(--shadow);
  margin-bottom: 28px;
  overflow     : hidden;
}
.section-header {
  padding        : 18px 24px;
  border-bottom  : 1px solid var(--gray-300);
  display        : flex;
  align-items    : center;
  justify-content: space-between;
  flex-wrap      : wrap;
  gap            : 10px;
}
.section-header h3 { font-size: 15px; font-weight: 700; color: var(--blue-dark); }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width          : 100%;
  border-collapse: collapse;
  font-size      : 13.5px;
}
thead tr { background: var(--gray-100); }
th {
  padding    : 11px 14px;
  text-align : left;
  font-weight: 600;
  color      : var(--blue-dark);
  white-space: nowrap;
  font-size  : 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
td {
  padding    : 12px 14px;
  border-top : 1px solid var(--gray-300);
  vertical-align: middle;
}
tr:hover td { background: #f8faff; }
.table-empty {
  text-align : center;
  color      : var(--gray-600);
  padding    : 40px 14px;
  font-size  : 14px;
}

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display      : inline-flex;
  align-items  : center;
  padding      : 3px 10px;
  border-radius: 99px;
  font-size    : 11.5px;
  font-weight  : 600;
  white-space  : nowrap;
}
.badge-entrada { background: var(--success-bg); color: var(--success); }
.badge-saida   { background: var(--danger-bg);  color: var(--danger); }
.badge-ok      { background: var(--success-bg); color: var(--success); }
.badge-alerta  { background: var(--danger-bg);  color: var(--danger); }
.badge-cat     { background: var(--blue-bg);    color: var(--blue-mid); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display        : inline-flex;
  align-items    : center;
  justify-content: center;
  gap            : 6px;
  padding        : 10px 18px;
  border-radius  : 8px;
  border         : none;
  cursor         : pointer;
  font-size      : 14px;
  font-weight    : 600;
  font-family    : var(--font);
  transition     : filter var(--transition), transform var(--transition);
  white-space    : nowrap;
  text-decoration: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--blue-light); color: var(--white); }
.btn-primary:hover { filter: brightness(1.10); }
.btn-success { background: var(--success);    color: var(--white); }
.btn-success:hover { filter: brightness(1.10); }
.btn-danger  { background: var(--danger);     color: var(--white); }
.btn-danger:hover  { filter: brightness(1.10); }
.btn-outline {
  background: transparent;
  border    : 1.5px solid var(--gray-300);
  color     : #374151;
}
.btn-outline:hover { background: var(--gray-100); }
.btn-icon {
  padding: 7px 10px;
  font-size: 15px;
}
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ── Forms ────────────────────────────────────────────────── */
.form-grid {
  display              : grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap                  : 16px;
  padding              : 24px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
label { font-size: 12.5px; font-weight: 600; color: #374151; }
input, select, textarea {
  width        : 100%;
  padding      : 11px 14px;
  border       : 1.5px solid var(--gray-300);
  border-radius: 8px;
  font-size    : 14px;
  font-family  : var(--font);
  background   : var(--white);
  color        : #1e293b;
  transition   : border-color var(--transition), box-shadow var(--transition);
  -webkit-appearance: none;
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline     : none;
  border-color: var(--blue-light);
  box-shadow  : 0 0 0 3px rgba(37,99,235,.12);
}
textarea { resize: vertical; min-height: 80px; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7280' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }
.form-actions { padding: 0 24px 24px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Toolbar / Filter bar ─────────────────────────────────── */
.toolbar {
  padding    : 16px 24px;
  display    : flex;
  flex-wrap  : wrap;
  gap        : 10px;
  align-items: center;
  border-bottom: 1px solid var(--gray-300);
}
.toolbar input, .toolbar select { max-width: 200px; margin: 0; }
.toolbar-spacer { flex: 1; }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position  : fixed; inset: 0;
  background: rgba(15,36,68,.45);
  z-index   : 500;
  display   : flex; align-items: center; justify-content: center;
  padding   : 16px;
  opacity   : 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background   : var(--white);
  border-radius: var(--radius);
  width        : 100%; max-width: 540px;
  max-height   : 90vh;
  overflow-y   : auto;
  box-shadow   : var(--shadow-lg);
  transform    : translateY(-16px);
  transition   : transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding        : 20px 24px;
  border-bottom  : 1px solid var(--gray-300);
  display        : flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--blue-dark); }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--gray-600); padding: 2px 6px; border-radius: 6px; }
.modal-close:hover { background: var(--gray-100); }
.modal-body { padding: 0; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--gray-300); display: flex; gap: 10px; justify-content: flex-end; }

/* ── Toast ────────────────────────────────────────────────── */
#toast-container {
  position  : fixed;
  bottom    : 24px; right: 24px;
  z-index   : 900;
  display   : flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast {
  background   : #1e293b;
  color        : var(--white);
  padding      : 13px 20px;
  border-radius: 10px;
  font-size    : 13.5px;
  font-weight  : 500;
  box-shadow   : var(--shadow-lg);
  display      : flex; align-items: center; gap: 10px;
  animation    : slideUp .22s ease forwards;
  max-width    : 320px;
  pointer-events: all;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error   { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Loading spinner ──────────────────────────────────────── */
.spinner {
  width : 28px; height: 28px;
  border: 3px solid var(--gray-300);
  border-top-color: var(--blue-light);
  border-radius   : 50%;
  animation: spin .7s linear infinite;
  margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-wrap { text-align: center; padding: 40px; color: var(--gray-600); font-size: 14px; }

/* ── Saldo indicator ──────────────────────────────────────── */
.saldo-ok     { color: var(--success); font-weight: 700; }
.saldo-alerta { color: var(--danger);  font-weight: 700; }

/* ── Overlay sidebar mobile ───────────────────────────────── */
.sidebar-backdrop {
  display : none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.4);
  z-index : 190;
}

/* ============================================================
   RESPONSIVO
   ============================================================ */
@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar-backdrop { display: block; }
  .main-content { margin-left: 0; }
  .btn-menu-mobile { display: flex; }
  .page-body { padding: 16px; }
  .topbar { padding: 14px 16px; }
  .topbar h2 { font-size: 16px; }
  .form-grid { grid-template-columns: 1fr; padding: 16px; }
  .form-actions { padding: 0 16px 16px; }
  .section-header { padding: 14px 16px; }
  .toolbar { padding: 12px 16px; }
  th, td { padding: 10px 10px; }
  .cards-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card { padding: 16px 14px; }
  .card-value { font-size: 24px; }
  .btn { padding: 11px 14px; font-size: 13.5px; }
  #toast-container { bottom: 16px; right: 16px; left: 16px; }
  .toast { max-width: 100%; }
  .modal { max-height: 95vh; }
}
@media (max-width: 480px) {
  .cards-grid { grid-template-columns: 1fr 1fr; }
  .toolbar input, .toolbar select { max-width: 100%; width: 100%; }
}

.nav-btn-link {
    -webkit-tap-highlight-color: transparent; /* Remove o brilho azul ao tocar */
    -webkit-touch-callout: none;              /* Bloqueia o menu de "copiar/colar" ao segurar */
    user-select: none;                        /* Impede seleção de texto */
    outline: none;
}