/* ============================================
   TinyFergieCMS - Protected Area & Setup Styles
   ============================================ */

/* Install Page */
.install-page,
.login-page {
  background: linear-gradient(135deg, #4a6fa5 0%, #3a5a8a 100%);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.install-container,
.login-container {
  background: var(--white);
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

.install-header,
.login-container h1 {
  text-align: center;
  margin-bottom: 8px;
}

.install-header h1,
.login-container h1 {
  font-size: 1.8rem;
  color: var(--primary-dark);
}

.install-header p {
  color: var(--text-light);
  margin-bottom: 20px;
  text-align: center;
}

.login-container h2 {
  text-align: center;
  color: var(--text-light);
  font-size: 1rem;
  font-weight: 400;
  margin-bottom: 24px;
}

.install-form hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0 16px;
}

.install-form h3 {
  font-size: 1rem;
  color: var(--text-light);
  margin-bottom: 16px;
}

.input-with-prefix {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
}
.input-with-prefix .input-prefix {
  padding: 8px 2px 8px 12px;
  background: var(--bg-light, #f5f5f5);
  color: var(--text-light);
  font-size: 0.9rem;
  white-space: nowrap;
  border-right: 1px solid var(--border);
  user-select: all;
}
.input-with-prefix input {
  border: none;
  outline: none;
  padding: 8px 12px;
  flex: 1;
  font-size: 1rem;
  min-width: 0;
}

.back-link {
  text-align: center;
  margin-top: 16px;
  font-size: 0.9rem;
}

/* Layout */
/* (Header/nav uses unified bar styling from style.css) */

/* Content Area */
.admin-content {
  padding: 30px 0;
  min-height: 70vh;
}

.admin-content .container {
  max-width: 1200px;
}

.admin-content h2 {
  font-size: 1.5rem;
  margin-bottom: 20px;
}

/* Form Hints */
.form-hint {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 4px;
}

/* Page Header (with action button) */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.page-header h2 {
  margin-bottom: 0;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Search Functionality */
.admin-search {
  position: relative;
  display: flex;
  align-items: center;
}

.admin-search input {
  padding: 8px 12px;
  padding-right: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  width: 220px;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.admin-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.15);
}

.admin-search input::placeholder {
  color: var(--text-light);
}

.admin-search .search-icon {
  position: absolute;
  right: 8px;
  font-size: 0.85rem;
  pointer-events: none;
}

/* Admin Table */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.admin-table th {
  background: #f5f5f5;
  text-align: left;
  padding: 12px 16px;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  border-bottom: 2px solid var(--border);
}

.sort-link {
  color: var(--text-light);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  user-select: none;
}

.sort-link:hover {
  color: var(--primary);
}

.sort-icon {
  font-size: 0.7rem;
  opacity: 0.4;
}

.sort-icon.active {
  opacity: 1;
  color: var(--primary);
}

.admin-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

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

.admin-table tr:hover td {
  background: #fafafa;
}

.admin-table code {
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.85rem;
}

.admin-table .actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Statistics ─────────────────────────────────────────────── */
.stats-summary-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}

.stats-summary-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 6px;
}

.stats-summary-label {
  font-size: 0.85rem;
  color: var(--text-light);
}

.stats-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 180px;
  padding: 12px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
}

.stats-chart-col {
  flex: 1;
  min-width: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.stats-chart-bar {
  width: 100%;
  min-height: 2px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
  margin-top: auto;
  transition: opacity 0.2s;
}

.stats-chart-col:hover .stats-chart-bar {
  opacity: 0.7;
}

.stats-chart-label {
  font-size: 0.7rem;
  color: var(--text-light);
  margin-top: 4px;
  white-space: nowrap;
}

.inline-form {
  display: inline;
}

/* Page Form */
.page-form {
  background: var(--white);
  padding: 30px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.page-form textarea {
  font-family: "Consolas", "Monaco", monospace;
  resize: vertical;
  min-height: 250px;
}

/* Shortcode help box */
.shortcode-help {
  margin: 12px 0 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #f9fafb;
}

.shortcode-help summary {
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 600;
  font-size: 0.88rem;
  color: #555;
  user-select: none;
}

.shortcode-help summary:hover {
  color: var(--primary);
}

.shortcode-help-content {
  padding: 4px 18px 14px;
  font-size: 0.88rem;
  line-height: 1.7;
  color: #444;
}

.shortcode-help-content code {
  display: inline-block;
  background: #eef1f5;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.84rem;
  word-break: break-all;
}

.shortcode-help-content ul {
  margin: 6px 0 10px 18px;
  padding: 0;
}

.shortcode-help-content ul li {
  margin-bottom: 2px;
}

/* ── TFEditor: Custom WYSIWYG Editor ─────────────────────────── */
.tfe-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: #f5f5f5;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}

.tfe-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text);
  transition:
    background 0.15s,
    border-color 0.15s;
}

.tfe-btn:hover {
  background: #e0e0e0;
  border-color: #ccc;
}

.tfe-btn.active {
  background: #d0d0d0;
  border-color: #bbb;
}

.tfe-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.tfe-fontsize-wrap {
  position: relative;
  flex-shrink: 0;
}

.tfe-fontsize-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--white);
  cursor: pointer;
  white-space: nowrap;
}

.tfe-fontsize-btn:hover {
  background: #e8e8e8;
}

.tfe-fontsize-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  min-width: 80px;
  max-height: 250px;
  overflow-y: auto;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  margin-top: 2px;
}

.tfe-fontsize-item {
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

.tfe-fontsize-item:hover {
  background: var(--primary);
  color: var(--white);
}

.tfe-sep {
  display: inline-block;
  width: 1px;
  height: 20px;
  background: #ccc;
  margin: 0 4px;
}

.tfe-editor {
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 16px 20px;
  min-height: 350px;
  background: var(--white);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.7;
  outline: none;
  overflow-y: auto;
}

.tfe-editor:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.12);
}

.tfe-editor p {
  margin-bottom: 0.6em;
}

.tfe-editor img {
  max-width: 100%;
  height: auto;
  cursor: pointer;
  border-radius: 4px;
}

.tfe-editor img:hover {
  outline: 2px solid var(--primary);
}

.tfe-editor ul,
.tfe-editor ol {
  padding-left: 1.5em;
  margin-bottom: 0.6em;
}

.tfe-editor blockquote {
  border-left: 3px solid var(--primary);
  padding: 0.3em 0.8em;
  margin: 0.5em 0;
  color: var(--text-light);
}

.tfe-source {
  width: 100%;
  min-height: 350px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 0 0 var(--radius) var(--radius);
  font-family: "Consolas", "Monaco", monospace;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  background: #1e1e1e;
  color: #d4d4d4;
  tab-size: 2;
}

.tfe-source:focus {
  outline: none;
  border-color: var(--primary);
}

/* Image Toolbar */
.tfe-img-toolbar {
  position: absolute;
  display: none;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: #2c3e50;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  z-index: 1000;
}

.tfe-img-toolbar .tfe-btn {
  color: #fff;
  font-size: 0.9rem;
}

.tfe-img-toolbar .tfe-btn:hover {
  background: rgba(255, 255, 255, 0.15);
}

.tfe-img-toolbar label {
  color: #fff;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.tfe-img-toolbar .tfe-img-width {
  width: 60px;
  padding: 3px 6px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 0.8rem;
  text-align: center;
}

.tfe-img-toolbar .tfe-sep {
  background: rgba(255, 255, 255, 0.3);
}

/* Media Modal */
.tfe-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.tfe-modal {
  background: var(--white);
  border-radius: 10px;
  width: 90%;
  max-width: 750px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.tfe-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.tfe-modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.tfe-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
  padding: 0 4px;
}

.tfe-modal-close:hover {
  color: var(--text);
}

.tfe-modal-body {
  padding: 20px;
  overflow-y: auto;
}

.tfe-modal-upload {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.tfe-modal-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}

.tfe-gallery-item {
  border: 2px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f9f9f9;
  transition:
    border-color 0.15s,
    transform 0.1s;
}

.tfe-gallery-item:hover {
  border-color: var(--primary);
  transform: scale(1.03);
}

.tfe-gallery-item img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.tfe-gallery-file-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px;
  text-align: center;
}

.tfe-file-emoji {
  font-size: 2.5rem;
  line-height: 1;
}

.tfe-file-ext {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
}

.tfe-file-name {
  font-size: 0.65rem;
  color: var(--text-light);
  word-break: break-all;
  max-height: 2.6em;
  overflow: hidden;
}

/* Upload Box (media.php page) */
.upload-box {
  margin-bottom: 30px;
}

.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition:
    border-color 0.2s,
    background 0.2s;
  background: var(--white);
}

.upload-area:hover,
.upload-area.drag-over {
  border-color: var(--primary);
  background: #f0f5ff;
}

.upload-area p {
  margin: 4px 0;
}

.upload-area input[type="file"] {
  display: none;
}

/* Media Grid (media.php page) */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.media-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.media-preview {
  height: 150px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
}

.media-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.media-file-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 4px;
}

.file-icon-emoji {
  font-size: 3rem;
  line-height: 1;
}

.file-icon-ext {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
}

.media-info {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
}

.media-name {
  display: block;
  font-size: 0.8rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-size {
  font-size: 0.75rem;
  color: var(--text-light);
}

.media-actions {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: normal;
  margin-bottom: 8px;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Logo Picker */
.logo-picker-preview {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 200px;
  height: 100px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
}

.logo-picker-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

.logo-picker-none {
  font-size: 0.85rem;
  color: var(--text-light);
  text-align: center;
  padding: 8px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
  font-size: 1.1rem;
  background: var(--white);
  border-radius: var(--radius);
  border: 2px dashed var(--border);
}

/* Menu Management */
.menu-management {
  margin-bottom: 30px;
}

.menu-management h3,
.menu-add-section h3 {
  font-size: 1.1rem;
  margin-bottom: 12px;
  color: var(--text);
}

.menu-table .menu-pos {
  text-align: center;
  font-weight: 600;
  color: var(--text-light);
}

/* Child / sub-item rows */
.menu-child-row td {
  background: #f8f9fc;
  border-top: none !important;
}

.menu-child-pos {
  color: var(--text-light);
  font-size: 1.1rem;
}

.menu-child-label {
  color: var(--text);
  font-size: 0.95rem;
}

/* Add-child trigger row */
.menu-add-child-row td {
  background: #f8f9fc;
  border-top: none !important;
  padding: 6px 10px 10px !important;
}

.menu-add-child-form {
  margin-top: 10px;
  padding: 12px;
  background: var(--white);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.child-add-sub-form + .child-add-sub-form {
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.menu-order-actions {
  display: flex;
  gap: 4px;
  align-items: center;
}

.btn-disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
}

.badge-home {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge-page {
  background: #e3f2fd;
  color: #1565c0;
}

.badge-link {
  background: #fff3e0;
  color: #e65100;
}

.badge-imprint {
  background: #f3e5f5;
  color: #7b1fa2;
}

.text-muted {
  color: var(--text-light);
  font-size: 0.9rem;
}

.menu-add-section {
  background: var(--white);
  padding: 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.menu-add-forms {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.menu-add-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.menu-page-select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  min-width: 250px;
  background: var(--white);
}

.menu-page-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.15);
}

.menu-add-link-form {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 4px;
}

.menu-add-link-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.menu-link-input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--white);
}

.menu-link-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.15);
}

.menu-link-input::placeholder {
  color: var(--text-light);
}

.menu-link-url {
  min-width: 220px;
}

.menu-link-target {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  cursor: pointer;
}

/* Settings Form Layout */
.settings-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0 20px;
}

.settings-section-title {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 12px;
}

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

/* Settings Dashboard Cards */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.settings-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 32px 20px 24px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  transition:
    border-color 0.15s,
    box-shadow 0.15s,
    transform 0.15s;
}

.settings-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
  text-decoration: none;
}

.settings-card-icon {
  font-size: 2.4rem;
  line-height: 1;
  margin-bottom: 12px;
}

.settings-card-title {
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 6px;
}

.settings-card-desc {
  font-size: 0.85rem;
  color: var(--text-light);
  line-height: 1.4;
}

.settings-back-link {
  display: inline-block;
  margin-bottom: 16px;
  font-size: 0.9rem;
  color: var(--text-light);
  text-decoration: none;
}

.settings-back-link:hover {
  color: var(--primary);
}

/* Account / 2FA */
.account-section {
  margin-bottom: 8px;
}

.totp-status {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.5;
}

.totp-active {
  background: #e8f5e9;
  border: 1px solid #a5d6a7;
  color: #2e7d32;
}

.totp-status-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.totp-setup-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 8px;
}

.totp-step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.totp-step-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--white);
  font-weight: 700;
  font-size: 0.95rem;
  margin-top: 2px;
}

.totp-secret-display {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 4px;
  flex-wrap: wrap;
}

.totp-secret-display code {
  font-size: 1.15rem;
  letter-spacing: 0.15em;
  background: #f5f5f5;
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: var(--radius);
  font-family: "Courier New", Courier, monospace;
  user-select: all;
  word-break: break-all;
}

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

.btn-danger {
  background: #e53935;
  color: var(--white);
  border: none;
  cursor: pointer;
}

.btn-danger:hover {
  background: #c62828;
}

/* Responsive Admin */
@media (max-width: 768px) {
  .admin-table {
    font-size: 0.85rem;
  }

  .admin-table th:nth-child(3),
  .admin-table td:nth-child(3) {
    display: none;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .page-header-actions {
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .admin-search input {
    width: 100%;
  }

  .install-container,
  .login-container {
    margin: 20px;
    padding: 24px;
  }

  .menu-add-row {
    flex-direction: column;
    align-items: stretch;
  }

  .menu-page-select {
    min-width: 0;
    width: 100%;
  }

  .menu-add-link-row {
    flex-direction: column;
    align-items: stretch;
  }

  .menu-link-input,
  .menu-link-url {
    min-width: 0;
    width: 100%;
  }

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

/* ============================================
   Audit Log Styles
   ============================================ */

.audit-stats {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.audit-stat {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 24px;
  text-align: center;
  flex: 1;
  min-width: 120px;
}

.audit-stat-number {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--primary);
}

.audit-stat-success .audit-stat-number {
  color: var(--success);
}

.audit-stat-danger .audit-stat-number {
  color: var(--danger);
}

.audit-stat-warning .audit-stat-number {
  color: #e67e22;
}

.audit-stat-info .audit-stat-number {
  color: #3182ce;
}

.audit-stat-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 4px;
}

.audit-failed-ips {
  background: #fff5f5;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 24px;
}

.audit-failed-ips h3 {
  margin: 0 0 12px 0;
  font-size: 0.95rem;
  color: var(--danger);
}

.audit-ip-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.audit-ip-badge {
  background: white;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 0.85rem;
  font-family: monospace;
}

.audit-filter {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.audit-filter span {
  font-weight: 600;
  color: var(--text-light);
}

.audit-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.audit-badge-success {
  background: #d4edda;
  color: #155724;
}

.audit-badge-danger {
  background: #f8d7da;
  color: #721c24;
}

.audit-badge-warning {
  background: #fff3cd;
  color: #856404;
}

.audit-badge-secondary {
  background: #e2e8f0;
  color: #4a5568;
}

.audit-badge-info {
  background: #bee3f8;
  color: #2a4365;
}

.audit-badge-category-auth {
  background: #e9d5ff;
  color: #6b21a8;
}

.audit-badge-category-content {
  background: #dbeafe;
  color: #1e40af;
}

.audit-badge-category-system {
  background: #fef3c7;
  color: #92400e;
}

.audit-badge-category-other {
  background: #e2e8f0;
  color: #4a5568;
}

.audit-table .audit-details {
  font-size: 0.85rem;
  color: var(--text-light);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audit-row-danger {
  background: #fff8f8;
}

.audit-row-warning {
  background: #fffdf5;
}

.audit-table .audit-time {
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--text-light);
}

.audit-table .audit-ua {
  font-size: 0.8rem;
  color: var(--text-light);
  max-width: 250px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.empty-state {
  text-align: center;
  color: var(--text-light);
  padding: 40px;
  font-size: 1.1rem;
}

@media (max-width: 768px) {
  .audit-stats {
    flex-direction: column;
  }

  .audit-table .audit-ua {
    display: none;
  }
}

/* ── Hero Configuration (uses editor-section style) ──────── */

.hero-config {
  margin-top: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
}

.hero-config summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  list-style: none;
  user-select: none;
}

.hero-config summary::-webkit-details-marker {
  display: none;
}

.hero-config summary::after {
  content: "\25B6";
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-light);
  transition: transform 0.2s;
}

.hero-config[open] summary::after {
  transform: rotate(90deg);
}

.hero-config summary::before {
  content: none;
}

.hero-config[open] summary::before {
  content: none;
}

.hero-config summary:hover {
  background: var(--bg);
}

.hero-config-content {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.hero-settings-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.hero-setting-item {
  flex: 1;
  min-width: 120px;
}

.hero-setting-item input,
.hero-setting-item select {
  width: 100%;
}

/* Hero Slides List */

.hero-slides-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.hero-slide-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-items: flex-start;
}

.hero-slide-thumb {
  width: 100px;
  height: 70px;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  background: #ddd;
}

.hero-slide-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-slide-fields {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hero-slide-fields input {
  font-size: 0.9rem;
  padding: 6px 10px;
}

.hero-slide-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.hero-slide-actions .btn {
  min-width: 32px;
  padding: 4px 8px;
  font-size: 0.8rem;
  text-align: center;
}

@media (max-width: 600px) {
  .hero-settings-row {
    flex-direction: column;
  }

  .hero-slide-item {
    flex-direction: column;
  }

  .hero-slide-thumb {
    width: 100%;
    height: 120px;
  }

  .hero-slide-actions {
    flex-direction: row;
  }
}

/* ── Link-in-Bio Admin ───────────────────────────────── */
.linkinbio-admin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.linkinbio-admin-item {
  background: #fafafa;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.linkinbio-admin-item.linkinbio-inactive {
  opacity: 0.6;
}

.linkinbio-admin-item-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  gap: 12px;
}

.linkinbio-admin-item-pos {
  font-weight: 700;
  color: var(--text-light);
  font-size: 1rem;
  min-width: 24px;
  text-align: center;
}

.linkinbio-admin-item-thumb {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}

.linkinbio-admin-item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.linkinbio-admin-item-info {
  flex: 1;
  min-width: 0;
}

.linkinbio-admin-item-info strong {
  display: block;
  font-size: 0.95rem;
  color: var(--text);
}

.linkinbio-admin-item-info small {
  display: block;
  color: var(--text-light);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.linkinbio-badge-inactive {
  display: inline-block;
  background: #f0c040;
  color: #333;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
  margin-top: 2px;
  text-transform: uppercase;
}

.linkinbio-admin-item-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}

.linkinbio-admin-edit {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--white);
}

/* Image Picker */
.linkinbio-image-picker {
  display: flex;
  align-items: center;
  gap: 12px;
}

.linkinbio-image-preview {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  overflow: hidden;
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border);
  flex-shrink: 0;
}

.linkinbio-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.linkinbio-image-preview-small {
  width: 48px;
  height: 48px;
  border-radius: 4px;
}

.linkinbio-image-placeholder {
  font-size: 0.75rem;
  color: var(--text-light);
  text-align: center;
}

.linkinbio-image-actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Media Picker Modal for Link-in-Bio */
.tfe-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tfe-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}

@media (max-width: 600px) {
  .linkinbio-admin-item-header {
    flex-wrap: wrap;
  }

  .linkinbio-admin-item-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .linkinbio-image-picker {
    flex-direction: column;
    align-items: flex-start;
  }

  .linkinbio-image-actions {
    flex-direction: row;
  }
}

/* Theme Preset Cards */
.theme-preset-option {
  cursor: pointer;
}

.theme-preset-option input[type="radio"] {
  display: none;
}

.theme-preset-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border: 2px solid;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  transition:
    box-shadow 0.2s,
    transform 0.15s;
  min-width: 160px;
}

.theme-preset-option input[type="radio"]:checked + .theme-preset-card {
  box-shadow:
    0 0 0 3px var(--primary),
    0 2px 8px rgba(0, 0, 0, 0.1);
  transform: scale(1.03);
}

.theme-preset-card:hover {
  transform: scale(1.02);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

.theme-preset-swatch {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid rgba(0, 0, 0, 0.1);
}

/* ── Editor Two-Column Layout ────────────────────────────── */

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

.editor-main {
  min-width: 0;
}

.editor-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: sticky;
  top: 12px;
}

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

  .editor-sidebar {
    position: static;
  }
}

/* ── Editor Page Sections ────────────────────────────────── */

.editor-section {
  margin-top: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  overflow: hidden;
}

.editor-section-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  list-style: none;
}

.editor-section-header::-webkit-details-marker {
  display: none;
}

.editor-section-header .section-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.editor-section-header .section-arrow {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-light);
  transition: transform 0.2s;
}

details.editor-section[open] > .editor-section-header .section-arrow {
  transform: rotate(90deg);
}

.editor-section-header:hover {
  background: var(--bg);
}

.editor-section-body {
  padding: 16px;
}

.editor-section-body .checkbox-label:last-child {
  margin-bottom: 0;
}

.editor-section-body .form-group:last-child {
  margin-bottom: 0;
}

.editor-section-body .form-group {
  margin-bottom: 12px;
}

/* ============================================
   Utility Classes (for CSP compliance)
   ============================================ */

/* Display Utilities */
.u-hidden {
  display: none !important;
}

.u-visible {
  display: block !important;
}

.u-flex {
  display: flex !important;
}

.u-inline-flex {
  display: inline-flex !important;
}

.u-flex-1 {
  flex: 1 !important;
}

/* Spacing Utilities */
.u-mt-0 {
  margin-top: 0 !important;
}
.u-mt-4 {
  margin-top: 4px !important;
}
.u-mt-8 {
  margin-top: 8px !important;
}
.u-mt-12 {
  margin-top: 12px !important;
}
.u-mt-16 {
  margin-top: 16px !important;
}
.u-mt-20 {
  margin-top: 20px !important;
}
.u-mt-24 {
  margin-top: 24px !important;
}
.u-mt-30 {
  margin-top: 30px !important;
}

.u-mb-0 {
  margin-bottom: 0 !important;
}
.u-mb-4 {
  margin-bottom: 4px !important;
}
.u-mb-8 {
  margin-bottom: 8px !important;
}
.u-mb-12 {
  margin-bottom: 12px !important;
}
.u-mb-16 {
  margin-bottom: 16px !important;
}
.u-mb-20 {
  margin-bottom: 20px !important;
}
.u-mb-24 {
  margin-bottom: 24px !important;
}
.u-mb-30 {
  margin-bottom: 30px !important;
}

.u-ml-8 {
  margin-left: 8px !important;
}

/* Text Utilities */
.u-text-center {
  text-align: center !important;
}

.u-text-left {
  text-align: left !important;
}

.u-text-right {
  text-align: right !important;
}

.u-text-light {
  color: var(--text-light) !important;
}

.u-text-error {
  color: #c00 !important;
}

.u-text-muted {
  color: #666 !important;
}

.u-font-size-sm {
  font-size: 0.9rem !important;
}

.u-font-size-xs {
  font-size: 0.8rem !important;
}

.u-font-size-lg {
  font-size: 1.3rem !important;
}

.u-letter-spacing-wide {
  letter-spacing: 0.3em !important;
}

.u-font-weight-600 {
  font-weight: 600 !important;
}

/* Cursor Utilities */
.u-cursor-pointer {
  cursor: pointer !important;
}

/* Width Utilities */
.u-w-100p {
  width: 100% !important;
}

.u-max-w-100 {
  max-width: 100px !important;
}

.u-max-w-200 {
  max-width: 200px !important;
}

/* Position Utilities */
.u-pos-absolute-off-left {
  position: absolute !important;
  left: -9999px !important;
}

/* Component Specific Utilities */
.input-totp-code {
  max-width: 200px !important;
  margin: 0 auto !important;
  display: block !important;
  font-size: 1.3rem !important;
  letter-spacing: 0.3em !important;
  text-align: center !important;
}

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

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

.modal-content {
  background: var(--bg-color, #fff);
  border-radius: 8px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.2);
}

/* Table Utilities */
.table-full {
  width: 100%;
  border-collapse: collapse;
}

th.th-left {
  text-align: left;
  padding: 8px;
}
th.th-right {
  text-align: right;
  padding: 8px;
}
td.td-pad {
  padding: 8px;
}
td.td-pad-right {
  padding: 8px;
  text-align: right;
}
tr.tr-border {
  border-top: 1px solid var(--border-color, #ddd);
}

.u-opacity-60 {
  opacity: 0.6 !important;
}

/* Design Settings Grid */
.header-layout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
  max-width: 500px;
}

/* Form Actions Flex */
.form-actions-flex {
  display: flex !important;
  gap: 8px;
  justify-content: flex-end;
}

/* Font Select */
.select-font-preview {
  font-size: 15px !important;
}

/* Image preview row */
.image-preview-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
  align-items: center;
}

/* Color settings grid */
.color-settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
  max-width: 540px;
}

.color-settings-grid .form-group {
  margin-bottom: 8px;
}

.color-input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.color-input-swatch {
  width: 44px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px;
  cursor: pointer;
}

.color-input-hex {
  max-width: 110px;
  font-family: monospace;
  font-size: 0.9rem;
}

/* Theme preset cards */
.theme-presets-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.theme-preset-light {
  background: #fafafa !important;
  color: #333 !important;
  border-color: #e0e0e0 !important;
}
.theme-preset-light .theme-preset-swatch {
  background: #4a6fa5 !important;
}
.theme-preset-dark {
  background: #1a1a2e !important;
  color: #e0e0e0 !important;
  border-color: #3a3a4e !important;
}
.theme-preset-dark .theme-preset-swatch {
  background: #6a9fd8 !important;
}
.theme-preset-custom {
  background: linear-gradient(135deg, #fafafa 50%, #1a1a2e 50%) !important;
  color: #333 !important;
  border-color: #e0e0e0 !important;
}
.theme-preset-custom .theme-preset-swatch {
  background: linear-gradient(135deg, #e07b39, #4a6fa5) !important;
}

/* Bold-checkbox label */
.label-checkbox-inline {
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: normal;
}

.u-mt-6 {
  margin-top: 6px !important;
}
.u-mb-8 {
  margin-bottom: 8px !important;
}
.u-max-w-120 {
  max-width: 120px !important;
}

.u-color-error {
  color: #c00 !important;
}
.u-ws-pre-line {
  white-space: pre-line !important;
}

/* alert/form-hint spacing */
.u-mb-16-alert {
  margin-bottom: 16px !important;
}

.form-section-title {
  margin-top: 0 !important;
  margin-bottom: 20px !important;
}

.form-section {
  margin-bottom: 30px !important;
}

.input-qr-display {
  font-size: 1.3rem !important;
  letter-spacing: 0.3em !important;
  text-align: center !important;
}

.row-equal-width {
  display: flex !important;
}

.row-equal-width > div {
  flex: 1 !important;
}

.u-mb-4 {
  margin-bottom: 4px !important;
}

.u-w-50 {
  width: 50px !important;
}
