/* =====================================================
   EstoqueAgro — app.css  (mobile-first, Android ok)
   ===================================================== */

/* ── Reset & Base ───────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --green:      #15803d;
  --green-d:    #166534;
  --green-l:    #dcfce7;
  --amber:      #d97706;
  --amber-l:    #fef3c7;
  --red:        #dc2626;
  --red-l:      #fee2e2;
  --blue:       #2563eb;
  --blue-l:     #dbeafe;
  --gray-50:    #f8fafc;
  --gray-100:   #f1f5f9;
  --gray-200:   #e2e8f0;
  --gray-400:   #94a3b8;
  --gray-600:   #475569;
  --gray-800:   #1e293b;
  --white:      #ffffff;
  --radius:     10px;
  --shadow:     0 1px 6px rgba(0,0,0,.1);
  --shadow-md:  0 4px 16px rgba(0,0,0,.12);
  --font:       'Segoe UI', system-ui, -apple-system, sans-serif;
  --nav-h:      54px;
}
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body { font-family: var(--font); background: var(--gray-50); color: var(--gray-800);
       min-height: 100vh; display: flex; flex-direction: column; }
a    { color: var(--green); text-decoration: none; }
img  { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
input, select, textarea {
  border: 1.5px solid var(--gray-200); border-radius: 8px;
  padding: 9px 12px; width: 100%; outline: none; background: var(--white);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--green); box-shadow: 0 0 0 3px rgba(21,128,61,.12);
}
textarea { resize: vertical; min-height: 80px; }

/* ── Navbar ─────────────────────────────────────────── */
.navbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--nav-h); background: var(--green); color: var(--white);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.navbar-brand { display: flex; align-items: center; gap: 8px;
  color: var(--white); font-weight: 700; font-size: 16px; }
.navbar-menu { display: none; gap: 4px; }
.nav-link { color: rgba(255,255,255,.85); padding: 6px 12px; border-radius: 6px;
  font-size: 14px; transition: background .15s; }
.nav-link:hover { background: rgba(255,255,255,.15); color: var(--white); }
.nav-cta { background: rgba(255,255,255,.2); color: var(--white); font-weight: 600; }
.nav-cta:hover { background: rgba(255,255,255,.3); }
.hamburger { background: none; border: none; cursor: pointer;
  display: flex; flex-direction: column; gap: 5px; padding: 6px; }
.hamburger span { display: block; width: 22px; height: 2px; background: var(--white);
  border-radius: 2px; transition: .2s; }

.nav-mobile { display: none; background: var(--green-d);
  flex-direction: column; padding: 8px 0; }
.nav-mobile a { color: var(--white); padding: 12px 20px; font-size: 15px;
  display: block; transition: background .15s; }
.nav-mobile a:hover { background: rgba(255,255,255,.1); }
.nav-mobile.open { display: flex; }

/* ── Main ───────────────────────────────────────────── */
.main-content { flex: 1; padding: 16px; max-width: 1200px;
  margin: 0 auto; width: 100%; }

/* ── Footer ─────────────────────────────────────────── */
.footer { background: var(--gray-800); color: var(--gray-400);
  text-align: center; padding: 12px 16px; font-size: 12px;
  display: flex; align-items: center; justify-content: center; gap: 12px; }
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray-400); }
.sync-dot.ok   { background: #4ade80; }
.sync-dot.erro { background: var(--red); }

/* ── Alerts / Flash ──────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between; font-size: 14px; }
.alert button { background: none; border: none; cursor: pointer; font-size: 16px; opacity: .6; }
.alert-success { background: var(--green-l); color: var(--green-d); border: 1px solid #bbf7d0; }
.alert-error   { background: var(--red-l);   color: #991b1b; border: 1px solid #fecaca; }

/* ── Page Header ─────────────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between;
  flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--gray-800); }
.back-link { display: block; font-size: 13px; color: var(--gray-600); margin-bottom: 4px; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── Buttons ─────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px; border: none; cursor: pointer;
  font-size: 14px; font-weight: 500; transition: all .15s; text-decoration: none; }
.btn-primary  { background: var(--green);  color: var(--white); }
.btn-primary:hover { background: var(--green-d); }
.btn-outline  { background: var(--white); color: var(--green);
  border: 1.5px solid var(--green); }
.btn-outline:hover { background: var(--green-l); }
.btn-danger   { background: var(--red);  color: var(--white); }
.btn-danger:hover { background: #b91c1c; }
.btn-camera   { background: #0ea5e9; color: var(--white); }
.btn-galeria  { background: #7c3aed; color: var(--white); }
.btn-lg { padding: 12px 28px; font-size: 15px; }

/* ── Stats Grid ─────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--white); border-radius: var(--radius);
  padding: 16px; display: flex; align-items: center; gap: 14px;
  box-shadow: var(--shadow); }
.stat-icon { font-size: 28px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--gray-800); display: block; }
.stat-label { font-size: 12px; color: var(--gray-600); }

.stats-grid-5 { grid-template-columns: repeat(2, 1fr); }
.stat-mini { background: var(--white); border-radius: var(--radius);
  padding: 10px 14px; font-size: 13px; color: var(--gray-600);
  display: flex; justify-content: space-between; align-items: center;
  box-shadow: var(--shadow); }
.stat-mini strong { color: var(--gray-800); font-weight: 600; }

/* ── Section header ──────────────────────────────────── */
.section-header { display: flex; justify-content: space-between;
  align-items: center; margin: 24px 0 12px; }
.section-header h2 { font-size: 17px; font-weight: 600; }
.link-ver-todos { font-size: 13px; color: var(--green); }

/* ── Cards grid ─────────────────────────────────────── */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px; }
.machine-card { background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); cursor: pointer; overflow: hidden;
  transition: transform .15s, box-shadow .15s; }
.machine-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.card-photo { height: 180px; background: var(--gray-100) center/cover no-repeat;
  position: relative; display: flex; align-items: flex-end; }
.card-cat-icon { position: absolute; top: 8px; left: 8px; font-size: 20px;
  background: rgba(0,0,0,.4); border-radius: 6px; padding: 3px 6px; }
.card-badge { position: absolute; top: 8px; right: 8px; font-size: 11px;
  font-weight: 600; padding: 3px 8px; border-radius: 20px; }
.card-photos-count { position: absolute; bottom: 8px; right: 8px; font-size: 11px;
  background: rgba(0,0,0,.55); color: var(--white); padding: 2px 7px; border-radius: 12px; }
.card-body { padding: 12px 14px 14px; }
.card-title { font-size: 15px; font-weight: 600; color: var(--gray-800);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub { font-size: 12px; color: var(--gray-600); margin-top: 2px; }
.card-code { font-size: 11px; color: var(--gray-400); margin-top: 4px; font-family: monospace; }
.card-loc { font-size: 12px; color: var(--gray-600); margin-top: 4px; }

/* ── Badges ─────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; }
.badge-ok, .badge-disponivel { background: var(--green-l); color: var(--green-d); }
.badge-uso, .badge-em_uso    { background: var(--blue-l);  color: #1e40af; }
.badge-warn,.badge-manutencao{ background: var(--amber-l); color: #92400e; }
.badge-off, .badge-inativo   { background: var(--gray-100);color: var(--gray-600); }

/* ── Filtros ─────────────────────────────────────────── */
.filtros-bar { background: var(--white); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); margin-bottom: 18px; }
.filtros-inner { display: flex; flex-wrap: wrap; gap: 8px; }
.filtro-input  { flex: 1; min-width: 180px; }
.filtro-select { width: 160px; }
.filtros-total { font-size: 12px; color: var(--gray-600); margin-top: 8px; }

/* ── Paginação ───────────────────────────────────────── */
.paginacao { display: flex; gap: 6px; justify-content: center;
  flex-wrap: wrap; margin-top: 24px; }
.pag-btn { padding: 7px 12px; border-radius: 6px; border: 1.5px solid var(--gray-200);
  background: var(--white); color: var(--gray-800); font-size: 13px; }
.pag-btn.ativo { background: var(--green); color: var(--white); border-color: var(--green); }

/* ── Empty state ─────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 16px; color: var(--gray-600); }
.empty-state.full-width { grid-column: 1/-1; }
.empty-state p { margin-bottom: 16px; }

/* ── Galeria / Ver máquina ───────────────────────────── */
.galeria-section { background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: 20px; }
.galeria-main { height: 300px; background: var(--gray-100);
  display: flex; align-items: center; justify-content: center; overflow: hidden; }
.galeria-main img { width: 100%; height: 100%; object-fit: contain; }
.sem-foto-grande { text-align: center; color: var(--gray-400); }
.sem-foto-grande span { font-size: 48px; display: block; margin-bottom: 8px; }
.galeria-thumbs { display: flex; gap: 8px; padding: 10px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.thumb-item { flex-shrink: 0; width: 80px; position: relative; cursor: pointer; }
.thumb-item img { width: 80px; height: 60px; object-fit: cover; border-radius: 6px; }
.thumb-principal img { outline: 3px solid var(--green); }
.thumb-actions { display: flex; gap: 3px; margin-top: 4px; }
.thumb-btn { flex: 1; padding: 3px; border: none; border-radius: 4px;
  background: var(--gray-100); cursor: pointer; font-size: 13px; }
.thumb-del { background: var(--red-l); }

.upload-rapido { padding: 12px 14px; border-top: 1px solid var(--gray-100); }
.upload-rapido h3 { font-size: 13px; font-weight: 600; color: var(--gray-600);
  margin-bottom: 10px; text-transform: uppercase; letter-spacing: .5px; }
.upload-btns { display: flex; gap: 8px; }
.upload-progress { margin-top: 10px; }
.progress-bar { background: var(--gray-200); border-radius: 10px; height: 6px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--green); border-radius: 10px;
  width: 0%; transition: width .3s; }

/* ── Dados da máquina ───────────────────────────────── */
.dados-section { background: var(--white); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); }
.dados-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
.dados-grupo h3 { font-size: 13px; font-weight: 700; color: var(--green-d);
  text-transform: uppercase; letter-spacing: .5px; margin-bottom: 8px;
  padding-bottom: 4px; border-bottom: 2px solid var(--green-l); }
.dados-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.dados-table th { text-align: left; color: var(--gray-600); font-weight: 500;
  padding: 6px 0; width: 42%; font-size: 13px; }
.dados-table td { color: var(--gray-800); padding: 6px 0 6px 8px; }
.dados-table tr { border-bottom: 1px solid var(--gray-100); }
.dados-obs { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--gray-100); }
.dados-obs h3 { font-size: 13px; font-weight: 700; color: var(--green-d);
  text-transform: uppercase; margin-bottom: 8px; }
.dados-obs p { font-size: 14px; color: var(--gray-600); line-height: 1.6; }

/* ── Formulário ─────────────────────────────────────── */
.form-card { background: var(--white); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; }
.form-tabs { display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch;
  background: var(--gray-50); border-bottom: 2px solid var(--gray-200); }
.tab-btn { padding: 12px 16px; border: none; background: none; cursor: pointer;
  font-size: 14px; color: var(--gray-600); white-space: nowrap; font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; }
.tab-btn.ativo { color: var(--green); border-bottom-color: var(--green); }

.tab-panel { display: none; padding: 20px 16px; }
.tab-panel.ativo { display: block; }

.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--gray-600);
  text-transform: uppercase; letter-spacing: .4px; }
.span2 { grid-column: span 1; }

.form-footer { display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 16px; border-top: 1px solid var(--gray-100); background: var(--gray-50); }

/* ── Upload área grande ───────────────────────────────── */
.upload-area { margin-top: 16px; }
.upload-area h3 { font-size: 14px; font-weight: 600; color: var(--gray-700);
  margin-bottom: 12px; }
.upload-btns-big { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.upload-btn-big { display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; padding: 20px 12px; border-radius: var(--radius);
  cursor: pointer; transition: opacity .15s; text-align: center; color: var(--white); }
.upload-btn-big:hover { opacity: .9; }
.upload-btn-big .upload-icon { font-size: 32px; }
.upload-btn-big span:nth-child(2) { font-size: 14px; font-weight: 600; }
.upload-btn-big small { font-size: 11px; opacity: .8; }
.upload-camera  { background: #0ea5e9; }
.upload-galeria { background: #7c3aed; }

.preview-area { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.preview-item { position: relative; width: 90px; height: 90px; border-radius: 8px;
  overflow: hidden; border: 2px solid var(--gray-200); }
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-item .remove-preview { position: absolute; top: 2px; right: 2px;
  background: rgba(0,0,0,.6); color: var(--white); border: none; border-radius: 50%;
  width: 20px; height: 20px; font-size: 11px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; }

/* ── Fotos gerenciar (edit) ──────────────────────────── */
.fotos-gerenciar { margin-bottom: 20px; }
.fotos-gerenciar h3 { font-size: 14px; font-weight: 600; margin-bottom: 10px; }
.fotos-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.foto-item { position: relative; width: 100px; }
.foto-item img { width: 100px; height: 80px; object-fit: cover;
  border-radius: 8px; border: 2px solid var(--gray-200); }
.foto-principal-tag { display: block; font-size: 10px; color: var(--amber);
  text-align: center; margin-top: 2px; }
.foto-acoes { display: flex; gap: 4px; margin-top: 4px; }
.foto-btn { flex: 1; border: none; border-radius: 4px; padding: 3px;
  cursor: pointer; font-size: 13px; background: var(--gray-100); }
.foto-del { background: var(--red-l); }

/* ── Modal ──────────────────────────────────────────── */
.modal-overlay { display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.5); z-index: 200;
  align-items: center; justify-content: center; padding: 16px; }
.modal-overlay.open { display: flex; }
.modal { background: var(--white); border-radius: 12px; padding: 24px;
  max-width: 380px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h3 { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.modal p  { font-size: 14px; color: var(--gray-600); margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Responsive ─────────────────────────────────────── */
@media (min-width: 600px) {
  .navbar-menu { display: flex; }
  .hamburger   { display: none; }
  .stats-grid  { grid-template-columns: repeat(4, 1fr); }
  .stats-grid-5{ grid-template-columns: repeat(5, 1fr); }
  .form-grid   { grid-template-columns: repeat(2, 1fr); }
  .span2       { grid-column: span 2; }
  .dados-grid  { grid-template-columns: repeat(2, 1fr); }
  .galeria-main{ height: 380px; }
}
@media (min-width: 900px) {
  .main-content { padding: 24px; }
  .dados-grid   { grid-template-columns: repeat(4, 1fr); }
  .form-grid    { grid-template-columns: repeat(3, 1fr); }
}
