/*
  Admin Dashboard styles.
  Reads all color from /assets/css/variables.css — no hardcoded hex here.
  Motion is intentionally restrained (Section A6): fade/slide on panel load only.
*/

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}

h1, h2, h3, .font-display { font-family: var(--font-display); font-weight: 700; }

a { color: inherit; }

button { font-family: inherit; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease, border-color 150ms ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--gold); color: #fff; }
.btn-primary:hover:not(:disabled) { box-shadow: var(--shadow-soft); }

.btn-secondary { background: transparent; border-color: var(--border-color); color: var(--ink); }
.btn-secondary:hover:not(:disabled) { border-color: var(--gold); }

.btn-danger { background: transparent; border-color: var(--status-danger); color: var(--status-danger); }
.btn-danger:hover:not(:disabled) { background: var(--status-danger); color: #fff; }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }

/* ---------- Layout shell ---------- */
.admin-shell { display: flex; min-height: 100vh; }

.admin-sidebar {
  width: 250px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: var(--space-4) var(--space-3);
  position: sticky;
  top: 0;
  height: 100vh;
}

.admin-sidebar-brand { display: flex; align-items: baseline; gap: var(--space-2); margin-bottom: var(--space-4); }
.admin-sidebar-brand-mark { font-family: var(--font-display); font-size: 22px; font-weight: 700; color: var(--gold); }
.admin-sidebar-brand-sub { font-size: 12px; color: var(--sandal); text-transform: uppercase; letter-spacing: 0.06em; }

/* Close button hidden on desktop; shown via @media(max-width:900px) below */
.admin-sidebar-close-btn { display: none; }

/* Simplified "Timeline View" for admin — a slim top progress bar, not the full dot rail (Section A3/A6) */
.admin-sidebar-progress {
  height: 3px;
  background: var(--border-color);
  border-radius: 2px;
  margin-bottom: var(--space-4);
  overflow: hidden;
}
.admin-sidebar-progress-fill {
  height: 100%;
  width: 12%;
  background: var(--gold);
  transition: width 300ms ease;
}

.admin-nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; flex: 1; }

.admin-nav-link {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 10px var(--space-3);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--sandal);
  font-weight: 600;
  font-size: 14px;
  transition: background-color 150ms ease, color 150ms ease;
}
.admin-nav-link:hover { background: var(--surface-2); color: var(--ink); }
.admin-nav-link.is-active { background: var(--surface-2); color: var(--maroon); }
.admin-nav-link.is-active svg { stroke: var(--maroon); }
.admin-nav-link svg { flex-shrink: 0; }

.admin-nav-logout { margin-top: var(--space-3); border-top: 1px solid var(--border-color); padding-top: var(--space-3); }

.admin-sidebar-toggle { display: none; }

/* ---------- Main column ---------- */
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.admin-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border-color);
  background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.admin-topbar-left { display: flex; align-items: center; gap: var(--space-3); }
.admin-page-title { font-size: 20px; margin: 0; }
.admin-topbar-right { display: flex; align-items: center; gap: var(--space-3); }

.theme-toggle-btn, .admin-quick-whatsapp, .admin-sidebar-toggle {
  background: transparent; border: 1px solid var(--border-color);
  border-radius: var(--radius-sm); padding: 8px; cursor: pointer;
  display: flex; align-items: center; gap: 6px; color: var(--ink);
}
.theme-toggle-btn:hover, .admin-sidebar-toggle:hover { border-color: var(--gold); }
.admin-quick-whatsapp { color: #25D366; border-color: rgba(37,211,102,0.4); text-decoration: none; font-weight: 700; font-size: 13px; }
.admin-quick-whatsapp:hover { background: rgba(37,211,102,0.08); }
.admin-quick-whatsapp-label { display: none; }
@media (min-width: 640px) { .admin-quick-whatsapp-label { display: inline; } }

.admin-user-chip { display: flex; align-items: center; gap: var(--space-2); }
.admin-user-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--gold); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px;
}
.admin-user-name { font-weight: 600; font-size: 14px; display: none; }
@media (min-width: 640px) { .admin-user-name { display: inline; } }

.admin-content { padding: var(--space-5); max-width: 1400px; width: 100%; margin: 0 auto; }

/* Subtle panel entrance — the ONLY motion admin uses (Section A6) */
.admin-panel {
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
  animation: panelFadeIn 320ms ease both;
}
.admin-panel:nth-of-type(2) { animation-delay: 40ms; }
.admin-panel:nth-of-type(3) { animation-delay: 80ms; }
.admin-panel:nth-of-type(4) { animation-delay: 120ms; }

@keyframes panelFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .admin-panel { animation: none; }
}

.admin-panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); gap: var(--space-3); flex-wrap: wrap; }
.admin-panel-title { font-size: 16px; margin: 0; }
.admin-panel-sub { color: var(--sandal); font-size: 13px; margin: 2px 0 0; }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-4); }
.stat-card {
  background: var(--surface); border: 1px solid var(--border-color); border-radius: var(--radius-md);
  padding: var(--space-4); box-shadow: var(--shadow-soft);
  animation: panelFadeIn 320ms ease both;
}
.stat-card-label { color: var(--sandal); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card-value { font-family: var(--font-display); font-size: 32px; font-weight: 700; margin: var(--space-1) 0; }
.stat-card-delta { font-size: 13px; font-weight: 600; }
.stat-card-delta.up { color: var(--status-confirmed); }
.stat-card-delta.down { color: var(--status-danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { text-align: left; padding: 12px var(--space-3); border-bottom: 1px solid var(--border-color); }
.admin-table th { color: var(--sandal); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; font-weight: 700; }
.admin-table tbody tr { transition: background-color 150ms ease; }
.admin-table tbody tr:hover { background: var(--surface-2); }

.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 700; text-transform: capitalize;
}
.badge-pending { background: rgba(184,134,59,0.15); color: var(--status-pending); }
.badge-confirmed { background: rgba(46,125,50,0.15); color: var(--status-confirmed); }
.badge-completed { background: rgba(59,90,154,0.15); color: var(--status-completed); }
.badge-approved { background: rgba(46,125,50,0.15); color: var(--status-confirmed); }
.badge-rejected { background: rgba(179,38,30,0.15); color: var(--status-danger); }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-3); }
.field-label { font-size: 13px; font-weight: 700; color: var(--ink); }
.field-hint { font-size: 12px; color: var(--sandal); }

input[type="text"], input[type="password"], input[type="email"], input[type="tel"],
input[type="number"], input[type="date"], input[type="search"], select, textarea {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--bg);
  color: var(--ink);
  width: 100%;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
input:hover, select:hover, textarea:hover { border-color: var(--sandal); }
input:focus-visible, select:focus-visible, textarea:focus-visible, input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(184,134,59,0.18);
}
input:disabled, select:disabled, textarea:disabled { opacity: 0.55; cursor: not-allowed; }

.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-3); }
.form-actions { display: flex; gap: var(--space-2); justify-content: flex-end; margin-top: var(--space-3); }

.checkbox-field { display: flex; align-items: center; gap: var(--space-2); }
.checkbox-field input { width: auto; }

/* ---------- Alerts / toasts ---------- */
.alert { padding: var(--space-3); border-radius: var(--radius-sm); font-size: 14px; margin-bottom: var(--space-3); }
.alert-danger { background: rgba(179,38,30,0.1); color: var(--status-danger); border: 1px solid rgba(179,38,30,0.25); }
.alert-success { background: rgba(46,125,50,0.1); color: var(--status-confirmed); border: 1px solid rgba(46,125,50,0.25); }

.toast-stack { position: fixed; bottom: var(--space-4); right: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); z-index: 100; }
.toast {
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-elevated); font-size: 14px; font-weight: 600;
  animation: toastIn 200ms ease both;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px);} to { opacity:1; transform: translateY(0);} }
.toast.toast-error { background: var(--status-danger); color: #fff; }

/* ---------- Modal / confirm dialog ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 200;
  padding: var(--space-3);
}
.modal-card {
  background: var(--surface); border-radius: var(--radius-md); box-shadow: var(--shadow-elevated);
  padding: var(--space-4); max-width: 420px; width: 100%;
  animation: panelFadeIn 200ms ease both;
}
.modal-title { margin: 0 0 var(--space-2); font-size: 17px; }
.modal-body { color: var(--sandal); font-size: 14px; margin-bottom: var(--space-4); }
.modal-actions { display: flex; gap: var(--space-2); justify-content: flex-end; }

/* ---------- Gallery manager grid ---------- */
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: var(--space-3); }
.gallery-tile {
  position: relative; border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border-color);
  aspect-ratio: 4/5; cursor: grab; background: var(--surface-2);
}
.gallery-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gallery-tile.dragging { opacity: 0.4; }
.gallery-tile.drag-over { outline: 2px dashed var(--gold); outline-offset: -2px; }
.gallery-tile-actions {
  position: absolute; inset: auto 0 0 0; display: flex; gap: 4px; padding: 6px;
  background: linear-gradient(0deg, rgba(0,0,0,0.6), transparent);
}
.gallery-tile-actions button {
  flex: 1; background: rgba(255,255,255,0.15); border: none; color: #fff; border-radius: 4px;
  padding: 4px; font-size: 11px; cursor: pointer;
}
.gallery-tile-caption { position: absolute; top: 6px; left: 6px; right: 6px; font-size: 11px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.6); }
.category-tabs { display: flex; gap: var(--space-2); margin-bottom: var(--space-3); flex-wrap: wrap; }
.category-tab {
  border: 1px solid var(--border-color); background: transparent; padding: 6px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 600; cursor: pointer; color: var(--sandal);
}
.category-tab.is-active { background: var(--gold); color: #fff; border-color: var(--gold); }
.dropzone {
  border: 2px dashed var(--border-color); border-radius: var(--radius-md); padding: var(--space-5);
  text-align: center; color: var(--sandal); margin-bottom: var(--space-3); cursor: pointer;
}
.dropzone.drag-active { border-color: var(--gold); color: var(--gold); background: rgba(184,134,59,0.05); }

/* ---------- Minimized floating cluster for admin (Section A5) ---------- */
.fab-cluster { position: fixed; right: var(--space-4); bottom: var(--space-4); display: flex; flex-direction: column-reverse; align-items: center; gap: var(--space-2); z-index: 90; }
.fab-primary, .fab-secondary {
  width: 48px; height: 48px; border-radius: 50%; border: none; display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-elevated); cursor: pointer; color: #fff; text-decoration: none;
}
.fab-primary { background: #25D366; animation: fabPulse 3s ease-in-out infinite; }
.fab-cluster:hover .fab-primary, .fab-cluster.is-open .fab-primary { animation-play-state: paused; }
.fab-secondary { background: var(--maroon); opacity: 0; transform: scale(0.6) translateY(8px); pointer-events: none; transition: all 200ms ease; }
.fab-cluster.is-open .fab-secondary { opacity: 1; transform: scale(1) translateY(0); pointer-events: auto; }
@keyframes fabPulse { 0%,100% { box-shadow: var(--shadow-elevated), 0 0 0 0 rgba(37,211,102,0.5);} 50% { box-shadow: var(--shadow-elevated), 0 0 0 10px rgba(37,211,102,0);} }
@media (prefers-reduced-motion: reduce) { .fab-primary { animation: none; } }

/* ---------- Login screen ---------- */
.admin-login-body {
  margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--bg); font-family: var(--font-body); padding: var(--space-3);
}
.login-card {
  background: var(--surface); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-elevated); padding: var(--space-6) var(--space-5); max-width: 380px; width: 100%;
  animation: panelFadeIn 400ms ease both;
}
.login-brand { display: flex; align-items: baseline; gap: var(--space-2); margin-bottom: var(--space-5); }
.login-brand-mark { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--gold); }
.login-brand-sub { font-size: 12px; color: var(--sandal); text-transform: uppercase; letter-spacing: 0.05em; }
.login-title { margin: 0 0 var(--space-1); font-size: 24px; }
.login-subtitle { color: var(--sandal); font-size: 14px; margin: 0 0 var(--space-4); }
.login-form { display: flex; flex-direction: column; }
.login-footnote { color: var(--sandal); font-size: 12px; text-align: center; margin-top: var(--space-4); }
.login-footnote code { background: var(--surface-2); padding: 2px 6px; border-radius: 4px; }

/* ---------- Charts (vanilla canvas) ---------- */
.chart-card { padding: var(--space-3); }
canvas.admin-chart { width: 100%; height: 220px; display: block; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .admin-sidebar {
    position: fixed; left: -280px; top: 0; height: 100vh; z-index: 950;
    transition: left 260ms cubic-bezier(0.25, 1, 0.5, 1);
    box-shadow: var(--shadow-elevated);
    width: 260px;
  }
  .admin-sidebar.is-open { left: 0; }
  .admin-sidebar-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 14px;
    right: 14px;
    width: 34px;
    height: 34px;
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: 50%;
    color: var(--ink);
    cursor: pointer;
    transition: background 150ms ease, color 150ms ease, transform 300ms ease;
    padding: 0;
  }
  .admin-sidebar-close-btn:hover {
    background: var(--gold);
    color: var(--bg);
    transform: rotate(90deg);
  }
  .admin-sidebar-toggle {
    display: flex; flex-direction: column; gap: 3px;
    width: 34px; height: 34px; justify-content: center; align-items: center;
  }
  .admin-sidebar-toggle span { width: 16px; height: 2px; background: var(--ink); display: block; }
  .admin-content { padding: var(--space-3); }
  .admin-topbar { padding: var(--space-2) var(--space-3); }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: 1fr; }
  .admin-panel { padding: var(--space-3); }
  .admin-content { padding: var(--space-2); }
  .admin-panel-header { flex-direction: column; align-items: flex-start; }

  /* Responsive table — convert to card layout on small screens */
  .table-responsive-cards thead { display: none; }
  .table-responsive-cards tbody tr {
    display: block;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: var(--space-2);
    padding: var(--space-2) var(--space-3);
  }
  .table-responsive-cards tbody td {
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding: 8px 0; font-size: 13px;
  }
  .table-responsive-cards tbody td:last-child { border-bottom: none; }
  .table-responsive-cards tbody td::before {
    content: attr(data-label);
    font-weight: 700; font-size: 11px;
    color: var(--sandal); text-transform: uppercase;
    letter-spacing: 0.04em; margin-right: var(--space-2);
    flex-shrink: 0;
  }

  /* Calendar — smaller cells on mobile */
  .cal-cell { min-height: 52px; font-size: 10px; padding: 4px; }
  .cal-head  { font-size: 9px; }
  .cal-dot   { font-size: 9px; padding: 1px 3px; }
  .cal-day-num { font-size: 11px; margin-bottom: 2px; }
  .cal-nav { flex-wrap: wrap; gap: var(--space-1); }
  .cal-nav .btn { font-size: 11px; padding: 5px 10px; }

  /* Charts: make canvas containers fill width */
  canvas.admin-chart { height: 180px !important; }
  .chart-card { padding: var(--space-2); overflow-x: auto; }

  /* Form actions stack */
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; }

  /* Gallery grid: 2 columns */
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
  .gallery-tile-actions button { font-size: 10px; padding: 3px 2px; }

  /* Stat cards */
  .stat-card-value { font-size: 24px; }
  .stat-card-label { font-size: 12px; }
}

@media (max-width: 360px) {
  .fab-cluster { right: var(--space-2); bottom: var(--space-2); }
  .fab-primary, .fab-secondary { width: 44px; height: 44px; }
  .admin-topbar-right .admin-user-chip { display: none; }
  .gallery-grid { grid-template-columns: 1fr; }
}

