/* admin/admin.css - LODEV admin panel styles. */

:root {
  --adm-bg:        #F4EFE6;
  --adm-surface:   #FBF8F2;
  --adm-ink:       #131211;
  --adm-muted:     #6B6660;
  --adm-hairline:  #D4CFC4;
  --adm-accent:    #C2410C;
  --adm-night:     #131211;
  --adm-night-muted: #8A8580;
  --adm-danger:    #B91C1C;
  --adm-ok:        #15803D;

  --adm-radius-pill: 9999px;
  --adm-radius-card: 12px;
  --adm-radius-block: 8px;

  --adm-font-sans: 'Inter Tight', ui-sans-serif, system-ui, sans-serif;
  --adm-font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--adm-bg);
  color: var(--adm-ink);
  font-family: var(--adm-font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font: inherit; }

/* ===== Login ===== */
.login-body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 20% 10%, rgba(194, 65, 12, 0.06), transparent 50%),
    radial-gradient(circle at 80% 90%, rgba(19, 18, 17, 0.06), transparent 50%),
    var(--adm-bg);
}

.login-shell {
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: var(--adm-surface);
  border: 1px solid var(--adm-hairline);
  border-radius: var(--adm-radius-card);
  padding: 32px;
}

.login-brand {
  font-family: var(--adm-font-sans);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  margin-bottom: 24px;
  color: var(--adm-ink);
}

.login-brand-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 2px 8px;
  border: 1px solid var(--adm-hairline);
  border-radius: var(--adm-radius-pill);
  font-family: var(--adm-font-mono);
  font-size: 11px;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--adm-muted);
}

.login-card h1 {
  font-family: var(--adm-font-sans);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 8px;
}

.login-sub {
  color: var(--adm-muted);
  font-size: 14px;
  margin: 0 0 24px;
}

.login-form {
  display: grid;
  gap: 16px;
}

.login-hint {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--adm-hairline);
  font-family: var(--adm-font-mono);
  font-size: 11px;
  color: var(--adm-muted);
  line-height: 1.6;
}

.login-hint code {
  background: var(--adm-bg);
  padding: 1px 6px;
  border-radius: 4px;
}

/* ===== Forms ===== */
.form-row {
  display: grid;
  gap: 6px;
}

.form-row > span {
  font-family: var(--adm-font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--adm-muted);
}

.form-row input,
.form-row textarea,
.form-row select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--adm-hairline);
  border-radius: var(--adm-radius-block);
  background: var(--adm-bg);
  font-family: var(--adm-font-sans);
  font-size: 14px;
  color: var(--adm-ink);
  transition: border-color 120ms ease-out;
}

.form-row input:focus,
.form-row textarea:focus,
.form-row select:focus {
  outline: none;
  border-color: var(--adm-ink);
}

.form-row textarea {
  min-height: 80px;
  resize: vertical;
  font-family: var(--adm-font-sans);
}

.form-row-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.form-row-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.form-error {
  padding: 10px 14px;
  background: rgba(185, 28, 28, 0.08);
  border: 1px solid rgba(185, 28, 28, 0.3);
  border-radius: var(--adm-radius-block);
  color: var(--adm-danger);
  font-size: 13px;
  margin-bottom: 16px;
}

.form-success {
  padding: 10px 14px;
  background: rgba(21, 128, 61, 0.08);
  border: 1px solid rgba(21, 128, 61, 0.3);
  border-radius: var(--adm-radius-block);
  color: var(--adm-ok);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ===== Buttons ===== */
.btn-admin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border: 1px solid transparent;
  border-radius: var(--adm-radius-pill);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 120ms ease-out, color 120ms ease-out, border-color 120ms ease-out, transform 120ms ease-out;
}

.btn-admin:active { transform: translateY(1px); }

.btn-admin-primary {
  background: var(--adm-ink);
  color: var(--adm-bg);
}

.btn-admin-primary:hover { background: var(--adm-accent); }

.btn-admin-ghost {
  background: transparent;
  border-color: var(--adm-ink);
  color: var(--adm-ink);
}

.btn-admin-ghost:hover {
  background: var(--adm-ink);
  color: var(--adm-bg);
}

.btn-admin-danger {
  background: transparent;
  border-color: var(--adm-danger);
  color: var(--adm-danger);
  padding: 6px 12px;
  font-size: 12px;
}

.btn-admin-danger:hover {
  background: var(--adm-danger);
  color: var(--adm-bg);
}

.btn-admin-link {
  background: transparent;
  padding: 4px 0;
  border-bottom: 1px solid currentColor;
  border-radius: 0;
  color: var(--adm-ink);
}

.btn-admin-link:hover { color: var(--adm-accent); }

.btn-admin-sm {
  padding: 6px 12px;
  font-size: 12px;
}

/* ===== Sidebar base styles ===== */
.adm-sidebar {
  background: var(--adm-night);
  color: var(--adm-bg);
  padding: 24px 20px;
  border-right: 1px solid var(--adm-night);
  position: sticky;
  top: 0;
  align-self: start;
  height: 100dvh;
  overflow-y: auto;
}

/* ===== App shell (sidebar + content) ===== */
.adm-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  min-height: 100dvh;
}

@media (max-width: 768px) {
  .adm-shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .adm-sidebar {
    /* Hidden by default on mobile — the drawer animation below flips it back on when is-open. */
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 60;
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform var(--dur-base) var(--ease-out), visibility 0s linear var(--dur-base);
  }
  .adm-sidebar.is-open {
    transform: translateX(0);
    visibility: visible;
    transition: transform var(--dur-base) var(--ease-out), visibility 0s linear 0s;
  }
}

/* ===== Mobile bottom nav ===== */
.adm-bottombar {
  display: none;
}

@media (max-width: 768px) {
  .adm-sidebar-close { display: inline-flex; }
}

@media (max-width: 768px) {
  .adm-bottombar {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: stretch;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100vw;
    z-index: 55;
    background: var(--adm-night);
    color: var(--adm-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: env(safe-area-inset-bottom, 0);
    box-shadow: 0 -8px 24px rgba(19, 18, 17, 0.08);
  }

  .adm-bottombar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-width: 0;
    min-height: 56px;
    padding: 8px 2px 6px;
    background: transparent;
    border: 0;
    border-radius: 0;
    color: var(--adm-night-muted);
    font-family: var(--adm-font-mono);
    font-size: 10px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    overflow: hidden;
    transition: color 120ms ease-out, background-color 120ms ease-out;
    -webkit-tap-highlight-color: transparent;
  }

  .adm-bottombar-item span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .adm-bottombar-item:active {
    background: rgba(255, 255, 255, 0.04);
  }

  .adm-bottombar-icon {
    display: block;
    flex-shrink: 0;
  }

  .adm-bottombar-item span {
    line-height: 1;
  }

  .adm-bottombar-item.is-active {
    color: var(--adm-bg);
  }

  .adm-bottombar-item.is-active .adm-bottombar-icon {
    color: var(--adm-accent);
  }

  /* Push content above the fixed bottom bar on mobile so submit buttons never get hidden. */
  .adm-content {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
  }

  /* When the mobile top bar is showing, factor in its height for padding-top. */
  body { padding-bottom: 0; }
}

/* ===== Header (responsive) ===== */
@media (max-width: 768px) {
  .adm-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .adm-header h1 { font-size: 24px; }
  .adm-actions { width: 100%; }
  .adm-actions a { flex: 1; }
}

/* ===== Cards ===== */
.adm-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

@media (max-width: 480px) {
  .adm-stat-value { font-size: 24px !important; }
}

/* ===== Tables (responsive with horizontal scroll) ===== */
.adm-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 16px;
  border-radius: var(--adm-radius-card);
  border: 1px solid var(--adm-hairline);
}

.adm-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--adm-surface);
}

/* When not wrapped, the table itself scrolls on overflow */
.adm-table:not(.adm-table-wrap *) {
  display: block;
}

@media (max-width: 768px) {
  .adm-table-wrap .adm-table { min-width: 640px; }
}

/* ===== Mobile card view for tables (heroeslides, projects, testimonials) =====
   On screens <= 640px, the table collapses into a 2-column card grid. Each <td>
   shows a small label pulled from its data-label attribute, so the same markup
   serves both desktop (rows) and mobile (stacked cells). */
@media (max-width: 640px) {
  .adm-table-wrap.is-cardlist .adm-table {
    min-width: 0;
    background: transparent;
    border: 0;
    border-radius: 0;
    display: block;
  }

  .adm-table-wrap.is-cardlist thead {
    display: none;
  }

  .adm-table-wrap.is-cardlist tbody {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .adm-table-wrap.is-cardlist tr {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px;
    background: var(--adm-surface);
    border: 1px solid var(--adm-hairline);
    border-radius: var(--adm-radius-card);
    white-space: normal;
  }

  .adm-table-wrap.is-cardlist tr:last-child {
    margin-bottom: 0;
  }

  .adm-table-wrap.is-cardlist td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 0;
    border-bottom: 1px solid var(--adm-hairline);
    white-space: normal;
    font-size: 13px;
  }

  .adm-table-wrap.is-cardlist td:last-child {
    border-bottom: 0;
  }

  .adm-table-wrap.is-cardlist td::before {
    content: attr(data-label);
    flex-shrink: 0;
    width: 38%;
    font-family: var(--adm-font-mono);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--adm-muted);
  }

  /* Hide empty spacer cells (those without a data-label) on mobile. */
  .adm-table-wrap.is-cardlist td:not([data-label]) {
    display: none;
  }

  .adm-table-wrap.is-cardlist td .actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 6px;
  }

  .adm-table-wrap.is-cardlist td .actions form {
    margin: 0;
    width: 100%;
  }

  .adm-table-wrap.is-cardlist td .actions .btn-admin,
  .adm-table-wrap.is-cardlist td .actions button {
    width: 100%;
  }

  .adm-table-wrap.is-cardlist td .meta {
    margin-top: 0;
  }

  /* Single-column card view already — stacked vertically, full-width cards. */
}

.adm-table th,
.adm-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--adm-hairline);
  vertical-align: top;
  white-space: nowrap;
}

.adm-table th:first-child,
.adm-table td:first-child {
  white-space: normal;
}

.adm-table th {
  font-family: var(--adm-font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--adm-muted);
  background: var(--adm-bg);
  font-weight: 500;
}

.adm-table tr:last-child td { border-bottom: 0; }

.adm-table td .meta {
  font-family: var(--adm-font-mono);
  font-size: 11px;
  color: var(--adm-muted);
  margin-top: 4px;
}

.adm-table .actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .adm-table th,
  .adm-table td {
    padding: 10px 12px;
    font-size: 13px;
  }
  .adm-table .actions { flex-direction: column; }
  .adm-table .actions .btn-admin,
  .adm-table .actions button { width: 100%; }
}

/* ===== Forms (responsive) ===== */
.adm-form {
  display: grid;
  gap: 16px;
}

.adm-form-2col {
  display: grid;
  gap: 16px;
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 640px) {
  .adm-form-2col { grid-template-columns: 1fr; }
  .adm-form-2col > .form-row { min-width: 0; }
}

/* ===== Card padding responsive ===== */
.adm-card {
  background: var(--adm-surface);
  border: 1px solid var(--adm-hairline);
  border-radius: var(--adm-radius-card);
  padding: 24px;
  margin-bottom: 16px;
}

@media (max-width: 640px) {
  .adm-card { padding: 16px; }
  .adm-content { padding: 20px 16px; }
}

/* ===== File input mobile ===== */
@media (max-width: 640px) {
  .form-row input[type="file"] {
    font-size: 13px;
    padding: 8px;
  }
}

/* ===== Status pills on small screens ===== */
.adm-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: var(--adm-radius-pill);
  font-family: var(--adm-font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid var(--adm-hairline);
  color: var(--adm-muted);
  background: transparent;
  white-space: nowrap;
}

@media (max-width: 480px) {
  .adm-pill { font-size: 9px; padding: 2px 8px; }
}

/* ===== Meta text responsive ===== */
.adm-help {
  font-size: 12px;
  color: var(--adm-muted);
  margin-top: -8px;
  line-height: 1.5;
}

.adm-help code {
  background: var(--adm-bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--adm-font-mono);
  font-size: 11px;
  word-break: break-all;
}

/* ===== Back link ===== */
.adm-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--adm-font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--adm-muted);
  margin-bottom: 16px;
}

.adm-back:hover { color: var(--adm-ink); }

/* ===== Mobile top bar (when sidebar is hidden) ===== */
.adm-mobilebar {
  display: none;
  padding: 14px 20px;
  background: var(--adm-night);
  color: var(--adm-bg);
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-weight: 600;
}

@media (max-width: 768px) {
  .adm-mobilebar { display: flex; }
  .adm-mobilebar a { color: var(--adm-bg); font-size: 12px; text-decoration: underline; }
}

/* ===== Mobile sidebar burger ===== */
.adm-burger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: var(--adm-bg);
  cursor: pointer;
}

.adm-burger span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
}

/* Sidebar close (X) inside the drawer */
.adm-sidebar-close {
  display: none;
  position: absolute;
  top: 18px;
  right: 16px;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.10);
  color: var(--adm-bg);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

/* Backdrop behind the drawer */
.adm-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(19, 18, 17, 0.5);
  z-index: 49;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}

.adm-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ===== Empty state ===== */
.adm-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--adm-muted);
  background: var(--adm-surface);
  border: 1px dashed var(--adm-hairline);
  border-radius: var(--adm-radius-card);
}

@media (max-width: 480px) {
  .adm-empty { padding: 32px 16px; }
}

/* ===== Form errors responsive ===== */
@media (max-width: 480px) {
  .form-error, .form-success {
    font-size: 12px;
    padding: 8px 12px;
  }
}

/* ===== Reduce button size on small screens ===== */
@media (max-width: 480px) {
  .btn-admin { font-size: 12px; padding: 8px 14px; }
  .btn-admin-sm { font-size: 11px; padding: 6px 10px; }
  .btn-admin-danger { padding: 5px 10px; font-size: 11px; }
}

.adm-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
  margin-bottom: 32px;
}

.adm-brand-tag {
  font-family: var(--adm-font-mono);
  font-size: 10px;
  font-weight: 400;
  padding: 2px 8px;
  border: 1px solid var(--adm-night-muted);
  border-radius: var(--adm-radius-pill);
  color: var(--adm-night-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.adm-nav {
  display: grid;
  gap: 2px;
}

.adm-nav-section {
  font-family: var(--adm-font-mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--adm-night-muted);
  margin: 16px 8px 6px;
}

.adm-nav a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--adm-radius-block);
  color: var(--adm-bg);
  font-size: 13px;
  transition: background-color 120ms ease-out;
}

.adm-nav a:hover {
  background: rgba(255, 255, 255, 0.06);
}

.adm-nav a.is-active {
  background: var(--adm-accent);
  color: var(--adm-bg);
}

.adm-user {
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid var(--adm-night-muted);
  font-family: var(--adm-font-mono);
  font-size: 11px;
  color: var(--adm-night-muted);
}

.adm-user a {
  color: var(--adm-bg);
  text-decoration: underline;
  margin-top: 8px;
  display: inline-block;
}

@media (max-width: 768px) {
  .adm-content { padding: 24px 20px; }
}

.adm-header h1 {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}

.adm-header p {
  color: var(--adm-muted);
  margin: 8px 0 0;
  font-size: 14px;
  max-width: 60ch;
}

.adm-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ===== Cards ===== */

.adm-card h3 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
}

.adm-stat {
  background: var(--adm-surface);
  border: 1px solid var(--adm-hairline);
  border-radius: var(--adm-radius-card);
  padding: 20px;
}

.adm-stat-label {
  font-family: var(--adm-font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--adm-muted);
  margin-bottom: 6px;
}

.adm-stat-value {
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.adm-stat-detail {
  font-size: 12px;
  color: var(--adm-muted);
  margin-top: 6px;
}

/* ===== Tables ===== */

.adm-table th,
.adm-table td {
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--adm-hairline);
  vertical-align: top;
}

.adm-table th {
  font-family: var(--adm-font-mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--adm-muted);
  background: var(--adm-bg);
  font-weight: 500;
}

.adm-table tr:last-child td { border-bottom: 0; }

.adm-table td .meta {
  font-family: var(--adm-font-mono);
  font-size: 11px;
  color: var(--adm-muted);
  margin-top: 4px;
}

.adm-table .actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ===== Status pills ===== */

.adm-pill-deposit_paid  { color: #92400E; border-color: #FCD34D; background: #FEF3C7; }
.adm-pill-building      { color: #1E40AF; border-color: #93C5FD; background: #DBEAFE; }
.adm-pill-feedback      { color: #6B21A8; border-color: #D8B4FE; background: #F3E8FF; }
.adm-pill-delivered     { color: #166534; border-color: #86EFAC; background: #DCFCE7; }
.adm-pill-final_paid    { color: var(--adm-bg); background: var(--adm-night); border-color: var(--adm-night); }

.adm-paid-flag {
  display: inline-block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  text-align: center;
  font-size: 10px;
  line-height: 14px;
  color: var(--adm-bg);
}

.adm-paid-flag.yes { background: var(--adm-ok); }
.adm-paid-flag.no  { background: var(--adm-hairline); color: var(--adm-muted); }

/* ===== Empty state ===== */

/* ===== Form grid ===== */

@media (max-width: 640px) {
  .adm-form-2col { grid-template-columns: 1fr; }
}

/* ===== Inline help ===== */

.adm-help code {
  background: var(--adm-bg);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--adm-font-mono);
}

/* ===== Back link ===== */

.adm-back:hover { color: var(--adm-ink); }

/* ===== Mobile top bar (when sidebar is hidden) ===== */

@media (max-width: 768px) {
  .adm-mobilebar { display: flex; }
  .adm-mobilebar a { color: var(--adm-bg); font-size: 12px; text-decoration: underline; }
}

/* ===== Mobile sidebar burger ===== */

.adm-burger span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
}
