/* ============================================================================
   Admin console — light-themed, functional layout
   ============================================================================
   Extends styles.css conventions, matching QSheet+/Q&A v2 admin styling.
   All admin pages carry body.admin + data-admin-page.
   ============================================================================ */

body.admin {
  background: #f3f4f6;
  color: #111827;
  min-height: 100vh;
}

.admin-main {
  max-width: 64rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
}

/* --- Brand bar ------------------------------------------------------------ */

.admin-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.admin-brand img {
  max-height: 40px;
  width: auto;
}
.admin-titles {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  flex: 1;
}
.admin-client {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.01em;
}
.admin-subtitle {
  font-size: 0.8rem;
  color: var(--muted);
}

.admin-tabs {
  display: flex;
  gap: 1rem;
  margin-top: 0.15rem;
}
.admin-tabs a {
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}
.admin-tabs a.active {
  color: var(--primary);
}
.admin-tabs a:hover { color: var(--primary); }

.admin-header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

/* --- Banner (admin pages use banner-error, not banner.error) -------------- */

.banner.banner-error   { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.banner.banner-success { background: #f0fdf4; border-color: #bbf7d0; color: var(--success); }
.banner.banner-info    { background: #f8fafc; border-color: var(--border); color: var(--muted); }

/* --- Buttons -------------------------------------------------------------- */

.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: opacity 0.15s;
  text-align: center;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { opacity: 0.88; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--primary);
  color: var(--accent);
}
.btn-secondary {
  background: #fff;
  color: #374151;
  border: 1px solid var(--border) !important;
}
.btn-secondary:hover:not(:disabled) { background: #f9fafb; }

.btn-ghost {
  background: transparent;
  color: #6b7280;
  border: 1px solid var(--border) !important;
}
.btn-ghost:hover:not(:disabled) { background: #f3f4f6; }

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
}

/* --- Password gate (index.html) -------------------------------------------- */

body.admin-login {
  background: #f0f2f5;
}

.password-wrap {
  max-width: 420px;
  margin: 100px auto;
  padding: 0 20px;
}

.password-card {
  background: #fff;
  border-radius: 16px;
  padding: 44px 40px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
  border: 1px solid #e5e7eb;
  text-align: center;
}

.password-logo {
  margin-bottom: 24px;
}
.password-logo img {
  height: 52px;
}

.password-title {
  font-size: 20px;
  font-weight: 800;
  color: #1a1a2e;
  margin-bottom: 6px;
}

.password-subtitle {
  font-size: 13px;
  color: #6b7280;
  margin-bottom: 28px;
}

.password-field {
  width: 100%;
  padding: 13px 16px;
  border: 1.5px solid #d1d5db;
  border-radius: 10px;
  font-size: 15px;
  text-align: center;
  font-family: inherit;
  transition: border-color 0.15s;
  background: #fafafa;
  color: #1a1a2e;
  margin-bottom: 10px;
}
.password-field:focus {
  outline: none;
  border-color: #7B1C2E;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(123, 28, 46, 0.08);
}

.btn-unlock {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, #7B1C2E, #a02840);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 10px;
  font-family: inherit;
}
.btn-unlock:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(123, 28, 46, 0.3);
}
.btn-unlock:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.password-error {
  color: #991b1b;
  font-size: 13px;
  min-height: 18px;
  margin-top: 4px;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.password-card.shake {
  animation: shake 0.35s;
}

/* --- Section layout (dashboard.html, project.html) ------------------------ */

.admin-section {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
}
.admin-section-header h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

/* --- Tables ----------------------------------------------------------------- */

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.admin-table thead {
  background: #f9fafb;
}
.admin-table th {
  padding: 0.6rem 1rem;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.admin-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover { background: #f9fafb; }
.admin-table code {
  font-size: 0.82rem;
  background: #f3f4f6;
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
}

/* --- Status badges ----------------------------------------------------------- */

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.badge-draft  { background: #f3f4f6; color: #4b5563; }
.badge-active { background: #d1fae5; color: #065f46; }
.badge-closed { background: #fee2e2; color: #991b1b; }

/* Availability status badges (Responses) */
.badge-available  { background: #d1fae5; color: #065f46; }
.badge-tentative  { background: #fef3c7; color: #92400e; }
.badge-unavailable { background: #fee2e2; color: #991b1b; }
.badge-noresponse { background: #f3f4f6; color: #6b7280; }

/* --- Table action links ----------------------------------------------------- */

.action-link {
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  text-decoration: none;
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 10%, #fff);
  border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
  white-space: nowrap;
  transition: opacity 0.12s;
}
.action-link:hover { opacity: 0.75; }
.action-btn { cursor: pointer; font-family: inherit; }

/* --- Empty state -------------------------------------------------------------- */

.admin-empty {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 2.5rem 1rem;
}

/* --- Form layout (new-project) ------------------------------------------------ */

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.form-section {
  padding: 1.5rem 1.75rem;
  border-bottom: 1px solid var(--border);
}
.form-section:last-child { border-bottom: none; }

.form-section h2 {
  margin: 0 0 1.1rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.field-row {
  display: grid;
  grid-template-columns: 12rem 1fr;
  grid-template-areas:
    "label input"
    ".     hint";
  column-gap: 1rem;
  row-gap: 0.3rem;
  align-items: center;
  margin-bottom: 1rem;
}
.field-row:last-child { margin-bottom: 0; }
.field-row label {
  grid-area: label;
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 0.2rem;
  font-weight: 500;
  font-size: 0.9rem;
}
.field-row input,
.field-row select,
.field-row textarea {
  grid-area: input;
}
.field-row small.field-hint {
  grid-area: hint;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 400;
}
.field-row .required { color: var(--danger); margin-left: 0.15rem; }

@media (max-width: 640px) {
  .field-row {
    grid-template-columns: 1fr;
    grid-template-areas:
      "label"
      "input"
      "hint";
  }
}

.section-hint {
  margin: -0.5rem 0 1rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 1.25rem 1.75rem;
  background: #f9fafb;
  border-top: 1px solid var(--border);
}

/* --- Footer ------------------------------------------------------------------- */

.bsp-footer { margin-top: 2rem; }

.admin-footer {
  text-align: center;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--muted);
}

/* --- Responsive ----------------------------------------------------------- */

@media (max-width: 640px) {
  .admin-brand { flex-wrap: wrap; }
  .admin-header-actions { width: 100%; justify-content: flex-end; }
  .form-section { padding: 1.25rem 1rem; }
  .form-actions { padding: 1rem; }
  .admin-table th, .admin-table td { padding: 0.6rem 0.75rem; }
}
