/* public/css/admin.css
   Admin UI styles. Always loaded alongside main.css on admin pages.
   Adds: admin layout, sidebar nav, stat cards, tables, extraction preview.
*/

/* --- Admin Layout --- */

.admin-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 60px); /* subtract nav height */
}

.admin-sidebar {
  border-right: 1px solid var(--border);
  padding: 32px 0;
  background: var(--bg);
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
}

.admin-sidebar__label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 20px;
  margin-bottom: 8px;
  margin-top: 24px;
}

.admin-sidebar__label:first-child {
  margin-top: 0;
}

.admin-nav {
  list-style: none;
}

.admin-nav__item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all 0.15s;
}

.admin-nav__item a:hover {
  color: var(--text);
  background: rgba(0,0,0,0.03);
  text-decoration: none;
}

.admin-nav__item--active a {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(200,98,42,0.05);
}

.admin-main {
  padding: 40px 48px;
  min-width: 0; /* prevents grid blowout */
}

/* --- Admin Page Header --- */

.admin-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 32px;
  gap: 16px;
  flex-wrap: wrap;
}

.admin-page-header__title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* --- Stat Cards --- */

.stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

.stat-card__label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.stat-card__value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}

.stat-card__value--accent {
  color: var(--accent);
}

/* --- Data Table --- */

.data-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background: rgba(0,0,0,0.015);
}

.data-table__actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.data-table__empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* --- Admin Form Card --- */

.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  max-width: 560px;
  box-shadow: var(--shadow);
}

.form-card__title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* --- Textarea --- */

.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.925rem;
  background: var(--bg-card);
  color: var(--text);
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200,98,42,0.12);
}

/* --- Select --- */

.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-size: 0.975rem;
  background: var(--bg-card);
  color: var(--text);
  -webkit-appearance: none;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200,98,42,0.12);
}

/* --- Extraction Preview Card --- */

.extract-preview {
  background: var(--bg-card);
  border: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 32px;
  margin-top: 28px;
  max-width: 640px;
}

.extract-preview__label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 16px;
}

.extract-preview__title {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.extract-preview__section {
  margin-bottom: 20px;
}

.extract-preview__ingredients {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.7;
}

.extract-preview__instructions {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
  max-height: 200px;
  overflow-y: auto;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.extract-edit {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

/* --- Spinner --- */

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

.spinner--dark {
  border-color: rgba(0,0,0,0.15);
  border-top-color: var(--accent);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Confirm Dialog (inline) --- */

.confirm-row {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #FEF2F2;
  border: 1px solid #FECACA;
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: #991B1B;
}

.confirm-row--visible {
  display: flex;
}

/* --- Responsive --- */

@media (max-width: 900px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
  }

  .admin-nav__item a {
    border-left: none;
    border-bottom: 2px solid transparent;
  }

  .admin-nav {
    display: flex;
    flex-wrap: wrap;
    padding: 0 16px;
    gap: 4px;
  }

  .admin-nav__item--active a {
    border-bottom-color: var(--accent);
  }

  .admin-main {
    padding: 24px 20px;
  }

  .extract-edit {
    grid-template-columns: 1fr;
  }
}

/* --- Modal --- */

#edit-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 100;
}

.modal {
  position: relative;
  z-index: 101;
  background: #fff;
  border-radius: 8px;
  padding: 32px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12);
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal__title {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0;
}

.modal__close {
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: #666;
  padding: 4px;
  line-height: 1;
}

.modal__close:hover {
  color: #222;
}

.modal__footer {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 24px;
}
