/* Admin panel — extends public design tokens (style.css loaded first) */

body.login-body {
  background: radial-gradient(1200px 700px at 80% 10%, #24513c 0%, var(--forest) 45%, var(--forest-deep) 100%);
  min-height: 100vh; display: flex; align-items: center; justify-content: center; margin:0;
}
.login-card {
  background: var(--white); width: min(380px, 90vw); padding: 40px 30px; border-radius: var(--radius);
  box-shadow: var(--shadow-lift); text-align: center;
}
.login-card .brand { color: var(--forest); font-size: 1.3rem; }
.login-sub { color: var(--ink-soft); font-size: .9rem; margin-bottom: 22px; }
.login-error { background: #f4d9d9; color: #7a2e2e; padding: 10px 14px; border-radius: 8px; font-size: .85rem; margin-bottom: 16px; }
.login-card .field { text-align: left; }
.login-back { display: inline-block; margin-top: 18px; font-size: .85rem; color: var(--ink-soft); }

/* ---- Admin shell ---- */
body.admin-body { margin: 0; background: var(--sand); font-family: var(--font-body); color: var(--ink); overflow-x: hidden; }
.admin-shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.admin-shell > * { min-width: 0; }

.admin-sidebar { background: var(--forest-deep); color: var(--sand); padding: 26px 20px; position: sticky; top:0; height: 100vh; }
.admin-sidebar .brand { color: var(--sand); font-size: 1.15rem; margin-bottom: 32px; }
.admin-sidebar nav a {
  display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 10px;
  color: rgba(247,245,239,.75); font-size: .92rem; margin-bottom: 4px; transition: all .25s;
}
.admin-sidebar nav a:hover, .admin-sidebar nav a.active { background: rgba(64,145,108,.25); color: var(--sand); }
.admin-sidebar .logout-link { margin-top: 30px; display:block; color: rgba(247,245,239,.55); font-size: .85rem; }

.admin-main { padding: 34px 40px; }
.admin-topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.admin-topbar h1 { font-size: 1.5rem; margin: 0; }
.admin-topbar .who { font-size: .85rem; color: var(--ink-soft); }

.admin-card { background: var(--white); border-radius: var(--radius-sm); padding: 26px; box-shadow: var(--shadow-soft); margin-bottom: 24px; min-width: 0; }
.admin-card form { min-width: 0; }
.field { min-width: 0; }
.field input[type="file"] { width: 100%; max-width: 100%; }
.admin-grid-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 20px; margin-bottom: 28px; }
.stat-tile { background: var(--white); border-radius: var(--radius-sm); padding: 22px; box-shadow: var(--shadow-soft); border-left: 4px solid var(--moss); }
.stat-tile b { font-family: var(--font-mono); font-size: 1.7rem; color: var(--forest); display:block; }
.stat-tile span { color: var(--ink-soft); font-size: .85rem; }

table.admin-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.admin-table th { text-align: left; color: var(--ink-soft); font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; padding: 10px 12px; border-bottom: 2px solid var(--sage); }
table.admin-table td { padding: 12px; border-bottom: 1px solid #EFEDE4; vertical-align: middle; }
table.admin-table img.thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; }
table.admin-table img.thumb-wide { width: 84px; height: 56px; object-fit: cover; border-radius: 8px; }
.no-photo-tag { font-size: .72rem; color: var(--ink-soft); font-style: italic; }
table.admin-table tr:hover { background: #FBFAF6; }
.table-responsive { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive table.admin-table { min-width: 620px; }

.btn-sm { padding: .5em 1em; font-size: .82rem; border-radius: 8px; }
.btn-danger { background: #B84A4A; color: white; }
.btn-danger:hover { background: #973b3b; }
.btn-secondary { background: var(--sage); color: var(--forest); }
.btn-secondary:hover { background: #c7e0d3; }
.pill { padding: .25em .8em; border-radius: 999px; font-size: .75rem; font-family: var(--font-mono); }
.pill-cleaning { background: #E4EEFB; color: #2255A4; }
.pill-planting { background: var(--sage); color: var(--forest); }
.pill-ecosphere { background: #FBEED9; color: var(--soil); }
.pill-active { background: #DDF1E4; color: #1B6B3A; }
.pill-inactive { background: #F0EEE6; color: #8A867A; }

.form-actions { display: flex; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.alert-success { background: #DDF1E4; color: #1B6B3A; padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; font-size: .9rem; }
.alert-error { background: #f4d9d9; color: #7a2e2e; padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; font-size: .9rem; }
.img-preview { width: 100px; height: 100px; object-fit: cover; border-radius: 10px; margin-bottom: 10px; display: block; }
.page-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--ink-soft); }

/* ---- Mobile sidebar drawer (base rules — must apply at ALL widths so
       these elements never interfere with the desktop grid layout) ---- */
.admin-mobile-bar { display: none; height: 60px; }
.admin-sidebar-overlay {
  position: fixed; inset: 0; z-index: 150;
  background: rgba(16,40,28,.6); backdrop-filter: blur(2px);
  opacity: 0; visibility: hidden;
  transition: opacity .4s var(--ease), visibility 0s linear .4s;
}
.admin-sidebar-overlay.open { opacity: 1; visibility: visible; transition: opacity .4s var(--ease); }

@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .admin-grid-stats { grid-template-columns: 1fr 1fr; }
  .admin-main { padding: 22px 18px; }
  .admin-card { padding: 20px 18px; }
  .admin-topbar { flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
  .admin-topbar h1 { font-size: 1.3rem; }

  .admin-mobile-bar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--forest-deep); color: var(--sand);
    padding: 0 20px;
    position: sticky; top: 0; z-index: 170;
  }
  .admin-mobile-bar .brand { color: var(--sand); font-size: 1.05rem; margin: 0; }

  .admin-nav-toggle {
    display: block; background: none; border: none; cursor: pointer;
    position: relative; width: 26px; height: 20px; padding: 0; z-index: 180;
  }
  .admin-nav-toggle .bar {
    display: block; position: absolute; left: 0; width: 100%; height: 2px;
    background: var(--sand); border-radius: 2px;
    transition: transform .35s var(--ease), opacity .25s var(--ease);
  }
  .admin-nav-toggle .bar:nth-child(1) { top: 0; }
  .admin-nav-toggle .bar:nth-child(2) { top: 9px; }
  .admin-nav-toggle .bar:nth-child(3) { top: 18px; }
  .admin-nav-toggle.open .bar:nth-child(1) { transform: translateY(9px) rotate(45deg); }
  .admin-nav-toggle.open .bar:nth-child(2) { opacity: 0; }
  .admin-nav-toggle.open .bar:nth-child(3) { transform: translateY(-9px) rotate(-45deg); }

  .admin-sidebar {
    position: fixed; top: 60px; left: 0; height: calc(100vh - 60px); width: min(78%, 300px);
    z-index: 160;
    transform: translateX(-100%);
    transition: transform .45s var(--ease);
    box-shadow: 20px 0 60px rgba(0,0,0,.35);
    padding-top: 20px;
  }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-sidebar .brand { display: none; }
}

@media (max-width: 520px) {
  .admin-grid-stats { grid-template-columns: 1fr; }
  .login-card { padding: 32px 22px; }
  .form-row { grid-template-columns: 1fr; }
  .btn { font-size: .88rem; padding: .85em 1.4em; }
}