/* ============================================================
   mamuro40+ Admin Panel Stylesheet
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;600;700&display=swap');

:root {
  --sidebar-w: 260px;
  --topbar-h: 60px;
  --bg: #f5f5f7;
  --dark: #2d2d2d;
  --white: #fff;
  --primary: #8B6F5C;
  --primary-dark: #6B5444;
  --primary-light: rgba(139,111,92,0.08);
  --border: #e2e2e2;
  --text: #333;
  --text-light: #777;
  --radius: 8px;
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --transition: 0.25s ease;
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body.admin-body {
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}
a { text-decoration: none; color: inherit; }
img { max-width: 100%; height: auto; }
ul, ol { list-style: none; }

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

/* ============================================================
   Sidebar
   ============================================================ */
.admin-sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--dark);
  color: #fff;
  z-index: 100;
  overflow-y: auto;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo { display: block; }

.sidebar-logo .logo-text {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  display: block;
}

.sidebar-logo .logo-sub {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.4);
  display: block;
  margin-top: 2px;
}

.sidebar-nav { padding: 16px 0; }

.sidebar-nav .nav-list { padding: 0 12px; }

.sidebar-nav .nav-item { margin-bottom: 2px; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.65);
  border-radius: 6px;
  transition: all var(--transition);
}

.sidebar-nav .nav-link:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.sidebar-nav .nav-link.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}

.sidebar-nav .nav-icon {
  width: 20px;
  text-align: center;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.sidebar-nav .nav-label { font-size: 0.85rem; }

.nav-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 12px 0;
}

.nav-link--logout { color: rgba(255,100,100,0.7) !important; }
.nav-link--logout:hover { color: #ff6b6b !important; }

/* ============================================================
   Top Bar
   ============================================================ */
.admin-topbar {
  position: fixed;
  top: 0;
  left: var(--sidebar-w);
  right: 0;
  height: var(--topbar-h);
  background: var(--white);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  padding: 0 28px;
  z-index: 99;
  transition: left var(--transition);
}

.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
  margin-right: 16px;
}

.topbar-spacer { flex: 1; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
}

.topbar-username { font-weight: 600; color: var(--text); }

.topbar-logout {
  color: var(--text-light);
  font-size: 0.8rem;
  transition: color var(--transition);
}
.topbar-logout:hover { color: var(--primary); }

/* ============================================================
   Main Content Area
   ============================================================ */
.admin-main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

.admin-page-content {
  padding: 30px;
  padding-top: calc(var(--topbar-h) + 30px);
}

/* ============================================================
   Flash Messages
   ============================================================ */
.flash-message {
  padding: 14px 20px;
  border-radius: 6px;
  font-size: 0.85rem;
  margin: 0 30px;
  margin-top: calc(var(--topbar-h) + 16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.flash-success {
  background: #f0fdf4;
  color: #16a34a;
  border: 1px solid #bbf7d0;
}

.flash-error {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fecaca;
}

.flash-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  line-height: 1;
}
.flash-close:hover { opacity: 1; }

/* When flash is present, reduce page-content top padding */
.flash-message + .admin-page-content {
  padding-top: 16px;
}

/* ============================================================
   Page Header
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.page-header .btn,
.page-header .admin-btn {
  flex-shrink: 0;
}

/* ============================================================
   Dashboard Stat Cards
   ============================================================ */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.stat-icon--consultation { background: #eff6ff; color: #3b82f6; }
.stat-icon--pv { background: #f0fdf4; color: #22c55e; }
.stat-icon--content { background: #fefce8; color: #ca8a04; }
.stat-icon--issues { background: #fef2f2; color: #ef4444; }

.stat-info { display: flex; flex-direction: column; }

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-top: 2px;
}

/* ============================================================
   Dashboard Grid
   ============================================================ */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.dashboard-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.dashboard-card .card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.dashboard-card .card-title {
  font-size: 1rem;
  font-weight: 700;
}

.dashboard-card .card-link {
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 500;
}
.dashboard-card .card-link:hover { text-decoration: underline; }

.dashboard-card .card-body { padding: 20px 24px; }

.empty-message {
  color: var(--text-light);
  font-size: 0.85rem;
  padding: 16px 0;
  text-align: center;
}

/* Issue list */
.issue-list { display: flex; flex-direction: column; gap: 10px; }

.issue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.issue-item:last-child { border-bottom: none; }

.issue-title { flex: 1; color: var(--text); }
.issue-date { color: var(--text-light); font-size: 0.75rem; white-space: nowrap; }

/* Quick links */
.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-link-btn {
  display: inline-flex;
  align-items: center;
  padding: 10px 18px;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  transition: all var(--transition);
}
.quick-link-btn:hover {
  background: var(--primary);
  color: #fff;
}

/* ============================================================
   Tables
   ============================================================ */
.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 12px 16px;
  text-align: left;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  font-weight: 700;
  color: var(--text);
  background: #fafafa;
  white-space: nowrap;
}

.admin-table tbody tr:nth-child(even) { background: #fafafa; }
.admin-table tbody tr:hover { background: #f0ede9; }

.admin-table--compact th,
.admin-table--compact td {
  padding: 10px 14px;
  font-size: 0.82rem;
}

.admin-table a { color: var(--primary); }
.admin-table a:hover { text-decoration: underline; }

.admin-table .thumbnail-cell img {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
}

.admin-table .actions {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.admin-table .actions a,
.admin-table .actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  transition: opacity var(--transition);
}

.admin-table .actions a:hover,
.admin-table .actions button:hover { opacity: 0.8; }

.btn-edit, .admin-table .btn-edit { background: #f0f0f0; color: var(--text); }
.btn-delete, .admin-table .btn-delete { background: #fef2f2; color: #ef4444; }
.btn-view, .admin-table .btn-view { background: #f0f7ff; color: #3b82f6; }
.btn-resolve { background: #f0fdf4; color: #22c55e; }
.btn-ignore { background: #f5f5f5; color: var(--text-light); }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 12px;
  letter-spacing: 0.03em;
  line-height: 1.5;
}

/* Status badges */
.badge--new { background: #eff6ff; color: #3b82f6; }
.badge--contacted, .badge--in_progress { background: #fff7ed; color: #f97316; }
.badge--completed { background: #f0fdf4; color: #22c55e; }
.badge--cancelled { background: #fef2f2; color: #ef4444; }
.badge--published { background: #f0fdf4; color: #22c55e; }
.badge--draft { background: #f5f5f5; color: #777; }
.badge--active { background: #f0fdf4; color: #22c55e; }
.badge--inactive { background: #f5f5f5; color: #777; }
.badge--featured { background: #fefce8; color: #ca8a04; }

/* Severity badges */
.badge--severity-info { background: #eff6ff; color: #3b82f6; }
.badge--severity-warning { background: #fefce8; color: #ca8a04; }
.badge--severity-critical { background: #fef2f2; color: #ef4444; }
.badge--severity-low { background: #f5f5f5; color: #777; }

/* ============================================================
   Buttons
   ============================================================ */
.admin-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1.4;
}

.admin-btn-primary, .btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.admin-btn-primary:hover, .btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.admin-btn-secondary, .btn-secondary {
  background: #f0f0f0;
  color: var(--text);
  border-color: var(--border);
}
.admin-btn-secondary:hover, .btn-secondary:hover { background: #e5e5e5; }

.admin-btn-danger, .btn-danger {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}
.admin-btn-danger:hover, .btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

.admin-btn-sm, .btn-sm { padding: 6px 14px; font-size: 0.78rem; }

/* ============================================================
   Forms
   ============================================================ */
.admin-form .form-group { margin-bottom: 20px; }

.admin-form .form-label,
.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.form-label .required { color: #ef4444; }

.admin-form .form-control,
.form-control {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color var(--transition);
  font-family: inherit;
  line-height: 1.6;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139,111,92,0.1);
}

textarea.form-control { min-height: 100px; resize: vertical; }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23777' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

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

.form-hint {
  font-size: 0.75rem;
  color: var(--text-light);
  margin-top: 4px;
}

.form-error {
  font-size: 0.75rem;
  color: #ef4444;
  margin-top: 4px;
}

.form-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

/* ============================================================
   Unified Form Styles (form-input, form-select, form-textarea, etc.)
   All admin forms use these classes consistently.
   ============================================================ */

/* --- Base input styles (shared by form-input, form-select, form-textarea, form-input-file) --- */
.form-input,
.form-select,
.form-textarea,
.form-input-file {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
  line-height: 1.6;
  background: var(--white);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139,111,92,0.1);
}

.form-input.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.08);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: #aaa;
}

/* --- Select dropdown arrow --- */
.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23777' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
  cursor: pointer;
}

/* --- Textarea --- */
.form-textarea {
  min-height: 100px;
  resize: vertical;
}

/* --- File upload --- */
.form-input-file {
  padding: 8px 14px;
  background: #fafafa;
  cursor: pointer;
  border-style: dashed;
}
.form-input-file:hover {
  border-color: var(--primary);
  background: rgba(139,111,92,0.03);
}

/* --- Form group spacing --- */
.form-group {
  margin-bottom: 20px;
}

.form-group--inline {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}

/* --- Form grid layouts --- */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 4px;
}

.form-grid--3col {
  grid-template-columns: 1fr 1fr 1fr;
}

/* --- Form actions bar (submit/cancel buttons) --- */
.form-actions {
  display: flex;
  gap: 10px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
}

/* --- Card body padding --- */
.card-body {
  padding: 24px;
}

/* --- Image preview / current thumbnail --- */
.current-thumbnail {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.preview-image {
  max-width: 200px;
  max-height: 160px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
}

.current-label {
  font-size: 0.78rem;
  color: var(--text-light);
}

/* --- Option rows (selfcheck repeatable fields) --- */
.option-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.option-row .form-input.option-input {
  flex: 1;
}

.option-row .form-input.option-score {
  width: 100px;
  flex: none;
}

.option-row .option-remove {
  flex-shrink: 0;
}

/* --- Generic btn class (base for all buttons) --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1.4;
  text-decoration: none;
}

.btn:hover {
  opacity: 0.9;
}

.btn.btn-primary,
.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.btn.btn-primary:hover,
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn.btn-secondary,
.btn-secondary {
  background: #f0f0f0;
  color: var(--text);
  border-color: var(--border);
}
.btn.btn-secondary:hover,
.btn-secondary:hover {
  background: #e5e5e5;
}

.btn.btn-danger,
.btn-danger {
  background: #ef4444;
  color: #fff;
  border-color: #ef4444;
}
.btn.btn-danger:hover,
.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

.btn.btn-sm,
.btn-sm {
  padding: 6px 14px;
  font-size: 0.78rem;
}

/* --- Quill WYSIWYG Editor overrides --- */
.quill-editor-wrap {
  margin-bottom: 0;
}

.quill-editor-wrap .ql-toolbar.ql-snow {
  border: 1px solid var(--border);
  border-radius: 6px 6px 0 0;
  background: #fafafa;
  font-family: inherit;
}

.quill-editor-wrap .ql-container.ql-snow {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.9rem;
  min-height: 200px;
}

.quill-editor-wrap .ql-editor {
  min-height: 200px;
  line-height: 1.8;
  color: var(--text);
}

.quill-editor-wrap .ql-editor.ql-blank::before {
  color: #aaa;
  font-style: normal;
}

.quill-editor-wrap .ql-snow .ql-picker-label {
  font-size: 0.82rem;
}

.quill-editor-wrap .ql-toolbar button:hover,
.quill-editor-wrap .ql-toolbar .ql-active {
  color: var(--primary) !important;
}

.quill-editor-wrap .ql-toolbar button:hover .ql-stroke,
.quill-editor-wrap .ql-toolbar .ql-active .ql-stroke {
  stroke: var(--primary) !important;
}

.quill-editor-wrap .ql-toolbar button:hover .ql-fill,
.quill-editor-wrap .ql-toolbar .ql-active .ql-fill {
  fill: var(--primary) !important;
}

/* --- Details/summary toggle (for expandable sections) --- */
details > summary {
  list-style: none;
}
details > summary::-webkit-details-marker {
  display: none;
}
details > summary::before {
  content: '';
}

/* --- Responsive form --- */
@media (max-width: 768px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-grid--3col {
    grid-template-columns: 1fr;
  }
  .form-group--inline {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .option-row {
    flex-wrap: wrap;
  }
  .option-row .form-input.option-score {
    width: 80px;
  }
}

/* File upload */
.file-upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.file-upload-area:hover {
  border-color: var(--primary);
  background: rgba(139,111,92,0.03);
}

.image-preview {
  margin-top: 12px;
  position: relative;
  display: inline-block;
}

.image-preview img {
  max-width: 200px;
  max-height: 160px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* ============================================================
   Tabs / Filters
   ============================================================ */
.filter-tabs, .admin-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
  gap: 0;
  flex-wrap: wrap;
}

.filter-tab, .admin-tab {
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.filter-tab:hover, .admin-tab:hover { color: var(--text); }

.filter-tab.active, .admin-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* ============================================================
   Admin Card / Panel (generic)
   ============================================================ */
.admin-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.admin-card-header,
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.admin-card-header h3,
.card-header h2,
.card-title { font-size: 1rem; font-weight: 700; margin: 0; }

.admin-card-body { padding: 24px; }

.admin-card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* --- Detail list (consultation detail, etc.) --- */
.detail-list {
  margin: 0;
  padding: 0;
}

.detail-row {
  display: flex;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
}
.detail-row:last-child { border-bottom: none; }

.detail-row dt {
  width: 140px;
  flex-shrink: 0;
  font-weight: 700;
  color: var(--text-light);
  font-size: 0.8rem;
}

.detail-row dd {
  flex: 1;
  margin: 0;
  color: var(--text);
}

.detail-message {
  line-height: 1.7;
  white-space: pre-wrap;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 768px) {
  .detail-grid { grid-template-columns: 1fr; }
  .detail-row { flex-direction: column; gap: 4px; }
  .detail-row dt { width: auto; }
}

/* ============================================================
   Pagination
   ============================================================ */
.pagination, .admin-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 20px 0;
}

.pagination a, .pagination span,
.admin-pagination a, .admin-pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 10px;
  font-size: 0.82rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text-light);
  transition: all var(--transition);
}

.pagination a:hover, .admin-pagination a:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.pagination .active, .admin-pagination .active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.pagination .disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ============================================================
   Stats Filter
   ============================================================ */
.stats-summary {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.stats-summary .stat-item {
  padding: 8px 16px;
  background: var(--white);
  border-radius: 6px;
  font-size: 0.82rem;
  box-shadow: var(--shadow);
}

.stats-summary .stat-item strong {
  font-size: 1.1rem;
  margin-right: 4px;
}

/* ============================================================
   Consultation Detail
   ============================================================ */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.detail-item { margin-bottom: 16px; }

.detail-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.detail-value {
  font-size: 0.9rem;
  color: var(--text);
}

/* ============================================================
   Options repeater (selfcheck form)
   ============================================================ */
.options-container { margin-bottom: 16px; }

.option-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
}

.option-row input { flex: 1; }

.option-row .btn-remove-option {
  background: #fef2f2;
  color: #ef4444;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

.btn-add-option {
  background: none;
  border: 1px dashed var(--border);
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--primary);
  transition: all var(--transition);
}
.btn-add-option:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

/* ============================================================
   Settings Page
   ============================================================ */
.settings-table { margin-bottom: 24px; }

.settings-table .form-control {
  padding: 8px 12px;
  font-size: 0.82rem;
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius);
  width: 100%;
  max-width: 440px;
  box-shadow: 0 16px 48px rgba(0,0,0,0.2);
  padding: 32px;
}

.modal h3 { font-size: 1.1rem; font-weight: 700; margin-bottom: 12px; }
.modal p { font-size: 0.9rem; color: var(--text-light); margin-bottom: 24px; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ============================================================
   Sidebar Overlay (Mobile)
   ============================================================ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.open {
  display: block;
  opacity: 1;
}

body.sidebar-open { overflow: hidden; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  /* Sidebar: slide-in from left */
  .admin-sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }
  .admin-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
  }

  .admin-topbar { left: 0; }
  .admin-main { margin-left: 0; }
  .sidebar-toggle { display: block; }

  /* Compact stats: 2 columns with smaller padding */
  .stats-row {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .stat-card { padding: 16px 14px; gap: 10px; }
  .stat-icon { width: 38px; height: 38px; font-size: 1rem; border-radius: 10px; }
  .stat-value { font-size: 1.3rem; }
  .stat-label { font-size: 0.72rem; }

  /* Dashboard cards compact */
  .dashboard-card .card-header { padding: 14px 16px; }
  .dashboard-card .card-body { padding: 14px 16px; }
  .dashboard-card .card-title { font-size: 0.9rem; }

  .form-row { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .page-title { font-size: 1.2rem; }
  .detail-grid { grid-template-columns: 1fr; }

  /* Quick links compact */
  .quick-links { gap: 8px; }
  .quick-link-btn { padding: 8px 14px; font-size: 0.78rem; }

  /* Tables scroll */
  .admin-table { font-size: 0.8rem; }
  .admin-table th, .admin-table td { padding: 10px 12px; }
}

@media (max-width: 480px) {
  .admin-page-content {
    padding: 16px 12px;
    padding-top: calc(var(--topbar-h) + 16px);
  }
  .admin-topbar { padding: 0 12px; }

  /* Even more compact stats */
  .stats-row { gap: 8px; }
  .stat-card { padding: 12px 10px; gap: 8px; }
  .stat-icon { width: 32px; height: 32px; font-size: 0.85rem; border-radius: 8px; }
  .stat-value { font-size: 1.15rem; }
  .stat-label { font-size: 0.68rem; }

  /* Page header */
  .page-header { margin-bottom: 16px; }
  .page-title { font-size: 1.1rem; }

  /* Filter tabs scroll */
  .filter-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    gap: 0;
    padding-bottom: 0;
  }
  .filter-tab {
    white-space: nowrap;
    padding: 8px 14px;
    font-size: 0.78rem;
  }

  /* Dashboard grid compact */
  .dashboard-grid { gap: 12px; }
  .dashboard-card .card-header { padding: 12px 14px; }
  .dashboard-card .card-body { padding: 12px 14px; }

  /* Table compact */
  .admin-table th, .admin-table td { padding: 8px 10px; font-size: 0.75rem; }

  /* Flash */
  .flash-message {
    margin: 0 12px;
    margin-top: calc(var(--topbar-h) + 10px);
    padding: 10px 14px;
    font-size: 0.8rem;
  }

  /* Issue list compact */
  .issue-item { font-size: 0.78rem; gap: 6px; }
  .issue-item .badge { font-size: 0.6rem; padding: 2px 6px; }
}

/* ============================================================
   Empty State
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.empty-state-icon {
  font-size: 3.5rem;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.empty-state-text {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 24px;
  max-width: 400px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.7;
}

/* ============================================================
   Gallery Admin Grid
   ============================================================ */
.gallery-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
}

.gallery-admin-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}

.gallery-admin-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

.gallery-admin-thumb {
  position: relative;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: #f0ede9;
}

.gallery-admin-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.gallery-admin-card:hover .gallery-admin-thumb img {
  transform: scale(1.05);
}

.gallery-admin-no-image {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-light);
  font-size: 2rem;
}

.gallery-admin-no-image small {
  font-size: 0.75rem;
  margin-top: 4px;
}

.gallery-admin-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.gallery-admin-card:hover .gallery-admin-overlay { opacity: 1; }

.gallery-overlay-btn {
  padding: 8px 16px;
  background: var(--white);
  color: var(--text);
  border: none;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.gallery-overlay-btn:hover { background: #f0f0f0; }

.gallery-overlay-btn--danger { color: #ef4444; }
.gallery-overlay-btn--danger:hover { background: #fef2f2; }

.gallery-admin-info { padding: 14px 16px; }

.gallery-admin-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  display: block;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-admin-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* Gallery category badges */
.badge--facility { background: #eff6ff; color: #3b82f6; }
.badge--equipment { background: #fefce8; color: #ca8a04; }
.badge--interior { background: #f0fdf4; color: #22c55e; }
.badge--exterior { background: #fdf4ff; color: #a855f7; }
.badge--group { background: #f5f5f5; color: #555; }

/* ============================================================
   Settings Sections
   ============================================================ */
.settings-section {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

.settings-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}

.settings-section-icon {
  font-size: 1.1rem;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border-radius: 8px;
  color: var(--primary);
}

.settings-section-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  flex: 1;
}

.settings-section-count {
  font-size: 0.75rem;
  color: var(--text-light);
  background: #f0f0f0;
  padding: 2px 10px;
  border-radius: 10px;
}

.settings-section-body { padding: 0; }

.settings-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.settings-row:last-child { border-bottom: none; }
.settings-row:hover { background: #fafafa; }

.settings-row-key {
  width: 220px;
  flex-shrink: 0;
}

.settings-row-key code {
  font-size: 0.78rem;
  color: var(--primary-dark);
  background: var(--primary-light);
  padding: 4px 10px;
  border-radius: 4px;
  font-family: 'Menlo', 'Consolas', monospace;
}

.settings-row-value { flex: 1; }

.settings-row-value .form-control {
  padding: 8px 12px;
  font-size: 0.82rem;
}

.settings-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.admin-btn-sm {
  padding: 6px 14px;
  font-size: 0.75rem;
}

/* Add New Setting */
.settings-add-section {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-top: 24px;
  border: 2px dashed var(--border);
}

.settings-add-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 20px;
}

.settings-add-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 16px;
  align-items: end;
}

@media (max-width: 768px) {
  .settings-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .settings-row-key { width: auto; }
  .settings-add-grid { grid-template-columns: 1fr; }
  .gallery-admin-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
}

/* ============================================================
   Inline form helpers
   ============================================================ */
.inline-form { display: inline; }
.actions-cell { white-space: nowrap; }
.table-thumbnail { width: 48px; height: 48px; border-radius: 6px; object-fit: cover; }

/* ============================================================
   Desktop / Mobile visibility toggles
   ============================================================ */
.mobile-only { display: none; }
.desktop-only { display: block; }

@media (max-width: 768px) {
  .mobile-only { display: block; }
  .desktop-only { display: none !important; }
}

/* ============================================================
   Mobile Card Layout (.m-card)
   ============================================================ */
.m-card {
  background: #fff;
  border: 1px solid var(--admin-border, #e2e8f0);
  border-radius: 10px;
  margin-bottom: 12px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.m-card-body {
  padding: 14px 16px 10px;
}

.m-card-thumb {
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  border-radius: 6px;
  margin-bottom: 10px;
}

.m-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--admin-text, #1a202c);
  margin-bottom: 6px;
  line-height: 1.4;
}

.m-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.m-card-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.m-card-detail {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  padding: 3px 0;
  border-bottom: 1px solid #f1f5f9;
}

.m-card-detail:last-child {
  border-bottom: none;
}

.m-label {
  color: #64748b;
  font-weight: 500;
  flex-shrink: 0;
  margin-right: 8px;
}

.m-card-actions {
  display: flex;
  border-top: 1px solid var(--admin-border, #e2e8f0);
}

.m-card-actions .inline-form {
  display: flex;
  flex: 1;
}

.m-card-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
  background: none;
  transition: background .15s;
}

.m-card-btn + .m-card-btn,
.m-card-btn + .inline-form,
.inline-form + .m-card-btn,
.inline-form + .inline-form {
  border-left: 1px solid var(--admin-border, #e2e8f0);
}

.m-card-btn--edit {
  color: #2563eb;
}
.m-card-btn--edit:hover {
  background: #eff6ff;
}

.m-card-btn--delete {
  color: #dc2626;
  width: 100%;
}
.m-card-btn--delete:hover {
  background: #fef2f2;
}
