/* ============================================================
   J.S. Agro Admin Panel
   ============================================================ */

:root {
  --red:    #c8102e;
  --red-d:  #a10c25;
  --ink:    #1a1a1a;
  --bg:     #f4f5f7;
  --card:   #ffffff;
  --line:   #e3e6ea;
  --muted:  #6b7280;
  --yellow: #ffc107;
  --green:  #16a34a;
  --amber:  #d97706;
  --gray:   #9ca3af;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
}

a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); font-size: 13px; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 14px; } .mt-3 { margin-top: 20px; } .mt-4 { margin-top: 28px; }

/* ---------- Login ---------- */
.login-body {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #c8102e 0%, #7a091d 100%);
  padding: 20px;
}
.login-card {
  background: #fff; padding: 40px 34px; border-radius: 16px; width: 100%;
  max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.3); text-align: center;
}
.login-logo img { width: 96px; height: 78px; object-fit: contain; }
.login-card h1 { margin: 16px 0 4px; font-size: 24px; }
.login-card form { text-align: left; margin-top: 20px; }
.login-card label { display: block; font-weight: 600; margin: 12px 0 6px; font-size: 13px; }
.login-card input {
  width: 100%; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 8px;
  font-size: 14px; transition: .15s;
}
.login-card input:focus { outline: none; border-color: var(--red); }
.pin-form label { text-align: center; font-size: 15px; }
.login-card .pin-input {
  max-width: 210px; margin: 0 auto; display: block; padding: 14px 16px;
  text-align: center; font-size: 30px; font-weight: 800; letter-spacing: .55em;
  text-indent: .55em; border-width: 2px;
}
.pin-help { margin: 7px 0 0; text-align: center; color: var(--muted); font-size: 12px; }
.btn-primary {
  width: 100%; margin-top: 20px; padding: 12px; background: var(--red); color: #fff;
  border: none; border-radius: 8px; font-weight: 700; font-size: 15px; cursor: pointer;
  transition: .15s;
}
.btn-primary:hover { background: var(--red-d); }
.back-link { display: inline-block; margin-top: 18px; color: var(--muted); font-size: 13px; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-success { background: #dcfce7; color: #14532d; border: 1px solid #bbf7d0; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ---------- Admin Layout ---------- */
.admin-topbar {
  background: #fff; padding: 12px 24px; display: flex;
  justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50;
}
.admin-brand { display: flex; align-items: center; gap: 12px; }
.admin-brand img { width: 48px; height: 42px; object-fit: contain; }
.admin-brand-name { font-weight: 700; font-size: 16px; }
.admin-brand-sub { font-size: 12px; color: var(--muted); }
.admin-topbar-right { display: flex; gap: 8px; }

.btn-ghost {
  padding: 8px 14px; background: var(--bg); border: 1px solid var(--line);
  border-radius: 7px; color: var(--ink); font-size: 13px; font-weight: 600;
  cursor: pointer; text-decoration: none; display: inline-block;
}
.btn-ghost:hover { background: #eef0f3; text-decoration: none; }

.admin-shell {
  display: grid; grid-template-columns: 240px 1fr; min-height: calc(100vh - 66px);
}
.admin-sidebar {
  background: #fff; padding: 16px 12px; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 3px;
}
.admin-sidebar a {
  padding: 10px 14px; border-radius: 7px; color: var(--ink);
  font-weight: 600; font-size: 14px; transition: .15s;
}
.admin-sidebar a:hover { background: var(--bg); text-decoration: none; }
.admin-sidebar a.active { background: var(--red); color: #fff; }

.admin-main { padding: 26px 32px; overflow-x: auto; }

.page-h1 { margin: 0 0 4px; font-size: 26px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 20px; box-shadow: 0 1px 2px rgba(0,0,0,.02);
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
}
.card-header h2 { margin: 0; font-size: 17px; }

/* ---------- Stat grid ---------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px; margin-top: 20px;
}
.stat-card {
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 20px; text-decoration: none; color: var(--ink);
  transition: .15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,.08); text-decoration: none; }
.stat-alert { border-color: var(--amber); background: #fffbeb; }
.stat-num { font-size: 32px; font-weight: 800; color: var(--red); line-height: 1; }
.stat-label { color: var(--muted); font-size: 13px; margin-top: 6px; font-weight: 600; }

/* ---------- Tables ---------- */
.data-table {
  width: 100%; border-collapse: collapse; background: #fff;
}
.data-table th, .data-table td {
  padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.data-table th {
  background: var(--bg); font-size: 12px; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted);
}
.data-table tr:hover { background: #fafbfc; }
.data-table img.thumb { width: 60px; height: 46px; object-fit: cover; border-radius: 4px; }

/* ---------- Status pills ---------- */
.status {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
}
.status-approved { background: #dcfce7; color: #14532d; }
.status-pending  { background: #fef3c7; color: #78350f; }
.status-rejected { background: #fee2e2; color: #991b1b; }
.status-active   { background: #dbeafe; color: #1e40af; }
.status-inactive { background: #e5e7eb; color: #4b5563; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-block; padding: 8px 14px; border: none; border-radius: 6px;
  font-weight: 600; font-size: 13px; cursor: pointer; text-decoration: none;
  transition: .15s;
}
.btn-add     { background: var(--red);   color: #fff; padding: 10px 18px; font-size: 14px; }
.btn-add:hover     { background: var(--red-d); text-decoration: none; }
.btn-edit    { background: #dbeafe; color: #1e40af; }
.btn-edit:hover    { background: #bfdbfe; text-decoration: none; }
.btn-del     { background: #fee2e2; color: #991b1b; }
.btn-del:hover     { background: #fecaca; text-decoration: none; }
.btn-approve { background: #dcfce7; color: #14532d; }
.btn-approve:hover { background: #bbf7d0; text-decoration: none; }
.btn-reject  { background: #fef3c7; color: #78350f; }
.btn-reject:hover  { background: #fde68a; text-decoration: none; }
.btn-save    { background: var(--red); color: #fff; padding: 11px 22px; font-size: 15px; }
.btn-save:hover    { background: var(--red-d); text-decoration: none; }
.btn-cancel  { background: var(--bg); color: var(--ink); padding: 11px 22px; font-size: 15px; }
.btn-cancel:hover  { background: #e5e7eb; text-decoration: none; }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.toolbar-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-pill { padding: 7px 14px; border: 1px solid var(--line); background: #fff; border-radius: 999px; font-size: 13px; color: var(--muted); font-weight: 600; }
.filter-pill.active { background: var(--red); color: #fff; border-color: var(--red); }

/* ---------- Forms ---------- */
.form-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 26px; max-width: 780px; }
.form-row { margin-bottom: 16px; }
.form-row label {
  display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px;
}
.form-row input[type=text], .form-row input[type=number], .form-row input[type=password],
.form-row textarea, .form-row select {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 7px;
  font-size: 14px; font-family: inherit;
}
.form-row textarea { min-height: 100px; resize: vertical; }
.form-row input:focus, .form-row textarea:focus, .form-row select:focus {
  outline: none; border-color: var(--red);
}
.form-row .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-actions { display: flex; gap: 10px; margin-top: 24px; }
.preview-img { max-width: 200px; margin-top: 8px; border: 1px solid var(--line); border-radius: 6px; }
.preview-video { max-width: 240px; }

/* ---------- Grid gallery preview ---------- */
.gallery-manage {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.gm-item {
  background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  position: relative;
}
.gm-item img, .gm-item iframe { width: 100%; height: 150px; object-fit: cover; display: block; border: 0; }
.gm-body { padding: 10px 12px; }
.gm-cap { font-size: 13px; color: var(--muted); margin-bottom: 8px; min-height: 32px; }
.gm-type-pill {
  position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,.65); color: #fff; padding: 3px 8px; border-radius: 4px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
}

@media (max-width: 800px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-sidebar { flex-direction: row; overflow-x: auto; padding: 10px; }
  .admin-sidebar a { white-space: nowrap; }
  .admin-main { padding: 18px; }
  .form-row-2 { grid-template-columns: 1fr; }
}
