/* ========== ADMIN PORTAL STYLES ========== */
/* Dark theme matching ElectriCirque brand */

:root {
  --admin-bg: #000000;
  --admin-surface: #0a0a1a;
  --admin-card: #100030;
  --admin-border: #1a1a3a;
  --admin-accent: #0020b0;
  --admin-accent-hover: #0030e0;
  --admin-accent-soft: #8060ff;
  --admin-text: #ffffff;
  --admin-text-dim: #8888aa;
  --admin-success: #00c853;
  --admin-danger: #ff3d57;
  --admin-warning: #ffab00;
  --admin-radius: 10px;
  --admin-radius-sm: 6px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--admin-bg);
  color: var(--admin-text);
  min-height: 100vh;
  line-height: 1.5;
}

a { color: var(--admin-accent-soft); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========== Nav ========== */
.admin-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--admin-surface);
  border-bottom: 1px solid var(--admin-border);
}

.admin-nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-nav-logo {
  font-size: 18px;
  font-weight: 700;
  color: var(--admin-text);
  text-decoration: none;
}

.admin-nav-logo span {
  color: var(--admin-accent-soft);
  font-weight: 400;
}

.admin-nav-links {
  display: flex;
  align-items: center;
  gap: 20px;
}

.admin-nav-links a {
  color: var(--admin-text-dim);
  font-size: 14px;
  padding: 6px 12px;
  border-radius: var(--admin-radius-sm);
  transition: color 0.2s, background 0.2s;
}

.admin-nav-links a:hover,
.admin-nav-links a.active {
  color: var(--admin-text);
  background: rgba(255,255,255,0.05);
  text-decoration: none;
}

.admin-nav-logout {
  background: none;
  border: 1px solid var(--admin-border);
  color: var(--admin-text-dim);
  font-size: 13px;
  padding: 6px 14px;
  border-radius: var(--admin-radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.admin-nav-logout:hover {
  border-color: var(--admin-danger);
  color: var(--admin-danger);
}

.admin-nav-undo {
  display: flex;
  gap: 4px;
  margin-left: auto;
}
.admin-nav-undo .btn:disabled {
  opacity: 0.3;
  cursor: default;
}

/* ========== Container ========== */
.admin-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 30px 20px;
}

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

.admin-header h1 {
  font-size: 24px;
  font-weight: 600;
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--admin-radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--admin-accent);
  color: white;
}

.btn-primary:hover {
  background: var(--admin-accent-hover);
  text-decoration: none;
}

.btn-danger {
  background: transparent;
  border: 1px solid var(--admin-danger);
  color: var(--admin-danger);
}

.btn-danger:hover {
  background: var(--admin-danger);
  color: white;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--admin-border);
  color: var(--admin-text-dim);
}

.btn-ghost:hover {
  border-color: var(--admin-text-dim);
  color: var(--admin-text);
}

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

/* ========== Category Tabs ========== */
.category-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.category-tab {
  padding: 8px 16px;
  border-radius: var(--admin-radius-sm);
  background: transparent;
  border: 1px solid var(--admin-border);
  color: var(--admin-text-dim);
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.category-tab:hover {
  border-color: var(--admin-accent-soft);
  color: var(--admin-text);
}

.category-tab.active {
  background: var(--admin-accent);
  border-color: var(--admin-accent);
  color: white;
}

/* ========== Service Grid ========== */
.service-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.service-card {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  overflow: hidden;
  transition: border-color 0.2s;
  position: relative;
}

.service-card:hover {
  border-color: var(--admin-accent-soft);
}

.service-card-img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: block;
}

.service-card-body {
  padding: 14px;
}

.service-card-category {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--admin-accent-soft);
  margin-bottom: 4px;
}

.service-card-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 6px;
}

.service-card-desc {
  font-size: 13px;
  color: var(--admin-text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 12px;
}

.service-card-actions {
  display: flex;
  gap: 8px;
}

/* ========== Drag Handle ========== */
.service-card-drag {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 28px;
  height: 28px;
  background: rgba(0,0,0,0.7);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  color: var(--admin-text-dim);
  font-size: 14px;
  z-index: 2;
}

.service-card-drag:active { cursor: grabbing; }

.service-card.dragging {
  opacity: 0.4;
  border-color: var(--admin-accent);
}

.service-card.drag-over {
  border-color: var(--admin-accent-soft);
  box-shadow: 0 0 0 2px rgba(128, 96, 255, 0.3);
}

/* ========== Order Badge ========== */
.service-card-order {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  background: rgba(0,0,0,0.7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--admin-text-dim);
  z-index: 2;
}

/* ========== Save Order Bar ========== */
.save-order-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--admin-surface);
  border-top: 1px solid var(--admin-accent);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 200;
  transform: translateY(100%);
  transition: transform 0.3s;
}

.save-order-bar.visible { transform: translateY(0); }

/* ========== Login Page ========== */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-box {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-box h1 {
  font-size: 22px;
  margin-bottom: 6px;
}

.login-box p {
  color: var(--admin-text-dim);
  font-size: 14px;
  margin-bottom: 28px;
}

.login-box .logo-text {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 4px;
}

.login-box .logo-text span {
  color: var(--admin-accent-soft);
}

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--admin-text-dim);
  margin-bottom: 6px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--admin-bg);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius-sm);
  color: var(--admin-text);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--admin-accent-soft);
}

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

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='%238888aa' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 34px;
}

.form-error {
  color: var(--admin-danger);
  font-size: 13px;
  margin-top: 6px;
}

/* ========== Edit Page Layout ========== */
.edit-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 30px;
  align-items: start;
}

.edit-panel {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 24px;
}

.edit-panel h2 {
  font-size: 16px;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--admin-border);
}

/* ========== Image Upload ========== */
.upload-zone {
  border: 2px dashed var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 16px;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--admin-accent-soft);
  background: rgba(128, 96, 255, 0.05);
}

.upload-zone p {
  color: var(--admin-text-dim);
  font-size: 14px;
}

.upload-zone .upload-icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.5;
}

.image-preview {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: var(--admin-radius-sm);
  margin-bottom: 12px;
}

/* ========== Toast ========== */
.admin-toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: var(--admin-radius-sm);
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.3s;
}

.admin-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.admin-toast-success {
  background: var(--admin-success);
  color: white;
}

.admin-toast-error {
  background: var(--admin-danger);
  color: white;
}

/* ========== Breadcrumb ========== */
.admin-breadcrumb {
  margin-bottom: 20px;
}

.admin-breadcrumb a {
  font-size: 14px;
  color: var(--admin-text-dim);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.admin-breadcrumb a:hover {
  color: var(--admin-text);
}

/* ========== Edit Page Sticky Save Bar ========== */
.edit-save-bar {
  position: sticky;
  top: 60px; /* below the nav */
  z-index: 90;
  background: var(--admin-card);
  border-bottom: 1px solid var(--admin-border);
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.edit-save-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.edit-save-bar-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--admin-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.edit-save-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .edit-save-bar-inner { padding: 8px 12px; }
  .edit-save-bar-title { font-size: 13px; }
}

/* ========== Delete Confirm Modal ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.modal-box {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 30px;
  max-width: 420px;
  width: 90%;
  text-align: center;
}

.modal-box h3 { margin-bottom: 10px; }
.modal-box p { color: var(--admin-text-dim); font-size: 14px; margin-bottom: 24px; }

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ========== Loading Spinner ========== */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ========== Service Visibility Toggle (Dashboard) ========== */
.service-card--hidden {
  opacity: 0.5;
}

.service-card--hidden:hover {
  opacity: 0.75;
}

.service-card-hidden-badge {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  background: rgba(255, 171, 0, 0.9);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 10px;
  border-radius: 4px;
  pointer-events: none;
}

.service-card-visibility {
  position: absolute;
  top: 8px;
  right: 40px;
  z-index: 3;
  width: 30px;
  height: 30px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: var(--admin-text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
}

.service-card-visibility:hover {
  background: rgba(0, 0, 0, 0.9);
  border-color: var(--admin-warning);
  color: var(--admin-warning);
}

.service-card--hidden .service-card-visibility {
  color: var(--admin-warning);
  border-color: rgba(255, 171, 0, 0.4);
}

/* ========== Visibility Toggle (Edit Page) ========== */
.visibility-toggle-label {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--admin-text);
  user-select: none;
}

.visibility-toggle-label input[type="checkbox"] {
  accent-color: var(--admin-success);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.visibility-warning {
  margin-top: 6px;
  font-size: 13px;
  color: var(--admin-warning);
  padding: 8px 12px;
  background: rgba(255, 171, 0, 0.08);
  border: 1px solid rgba(255, 171, 0, 0.25);
  border-radius: var(--admin-radius-sm);
}

/* ========== Responsive ========== */
@media (max-width: 768px) {
  .edit-layout { grid-template-columns: 1fr; }
  .service-grid { grid-template-columns: 1fr; }
  .admin-header { flex-direction: column; align-items: flex-start; }
  .login-box { padding: 28px 20px; }
}

@media (max-width: 480px) {
  .admin-nav-inner { padding: 0 12px; }
  .admin-container { padding: 20px 12px; }
  .category-tabs { gap: 2px; }
  .category-tab { padding: 6px 10px; font-size: 12px; }
}

/* ========== Image Editor Modal ========== */
.img-editor-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.img-editor-modal {
  background: var(--admin-surface);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

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

.img-editor-header h3 { font-size: 16px; margin: 0; }

.img-editor-close {
  background: none;
  border: none;
  color: var(--admin-text-dim);
  font-size: 24px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.img-editor-close:hover { color: var(--admin-text); }

.img-editor-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.img-editor-upload {
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.img-editor-upload .upload-zone { width: 100%; }

/* Cropper area */
.img-editor-cropper { }

.img-editor-canvas-wrap {
  max-height: 400px;
  overflow: hidden;
  background: #050510;
  border-radius: var(--admin-radius-sm);
}

.img-editor-canvas-wrap img {
  display: block;
  max-width: 100%;
}

/* Toolbar */
.img-editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  gap: 8px;
  flex-wrap: wrap;
}

.img-editor-toolbar-group {
  display: flex;
  gap: 4px;
}

.img-editor-btn {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  color: var(--admin-text-dim);
  font-size: 13px;
  padding: 6px 12px;
  border-radius: var(--admin-radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.img-editor-btn:hover {
  border-color: var(--admin-accent-soft);
  color: var(--admin-text);
}

/* SEO fields */
.img-editor-seo {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--admin-border);
}

/* Footer */
.img-editor-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--admin-border);
}

/* Loading overlay */
.img-editor-loading {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 10;
}

.img-editor-loading p { color: var(--admin-text-dim); font-size: 14px; }

/* Existing images browser in image editor */
.img-editor-existing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
  max-height: 250px;
  overflow-y: auto;
  padding: 4px;
}

.img-editor-existing-item {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s;
  aspect-ratio: 1;
}

.img-editor-existing-item:hover {
  border-color: var(--admin-accent-soft);
}

.img-editor-existing-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ========== Image Library Popup (full screen) ========== */
.img-editor-library {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 700;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 20px;
}

.img-editor-library-inner {
  background: var(--admin-surface, #0d0d1a);
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.img-editor-library-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.img-editor-library-grid {
  columns: 4;
  column-gap: 16px;
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

@media (max-width: 1200px) {
  .img-editor-library-grid { columns: 3; }
}
@media (max-width: 800px) {
  .img-editor-library-grid { columns: 2; }
}

.img-library-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 0.2s, transform 0.2s;
  background: var(--admin-card);
  break-inside: avoid;
  margin-bottom: 16px;
}

.img-library-item:hover {
  border-color: var(--admin-accent-soft);
  transform: translateY(-2px);
}

.img-library-item img {
  width: 100%;
  height: auto;
  display: block;
}

.img-library-item-info {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
  padding: 20px 8px 6px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.img-library-item-alt {
  font-size: 11px;
  color: var(--admin-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.img-library-item-source {
  font-size: 9px;
  color: var(--admin-text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Library multi-select */
.img-library-multi-bar {
  column-span: all;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 16px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--admin-border);
  font-size: 13px;
  color: var(--admin-text-dim);
}

.img-library-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.4);
  background: rgba(0,0,0,0.5);
  z-index: 2;
  transition: all 0.15s;
}

.img-library-item.selected .img-library-check {
  background: var(--admin-accent-soft);
  border-color: var(--admin-accent-soft);
}

.img-library-item.selected .img-library-check::after {
  content: '✓';
  color: white;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.img-library-item.selected {
  border-color: var(--admin-accent-soft);
  box-shadow: 0 0 0 2px rgba(128, 96, 255, 0.3);
}

/* Library action chooser */
.img-editor-library-actions {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 710;
  display: flex;
  align-items: center;
  justify-content: center;
}

.img-editor-library-actions-inner {
  text-align: center;
  max-width: 320px;
  width: 100%;
}

.img-editor-library-actions-inner img {
  width: 200px;
  height: 200px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 16px;
  border: 1px solid var(--admin-border);
}

.img-editor-library-actions-inner h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--admin-text);
}

.img-editor-library-actions-inner .btn {
  display: block;
  width: 100%;
  margin-bottom: 8px;
  text-align: center;
}

.img-editor-existing-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0,0,0,0.7);
  color: var(--admin-text-dim);
  font-size: 9px;
  padding: 2px 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ========== Multi-Image Manager Panel ========== */
.img-role-section {
  margin-bottom: 20px;
}

.img-role-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.img-role-header h4 {
  font-size: 14px;
  font-weight: 500;
  margin: 0;
}

.img-role-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--admin-accent);
  color: white;
}

.img-role-badge--thumbnail { background: #1565c0; }
.img-role-badge--cover     { background: #2e7d32; }
.img-role-badge--main      { background: #6a1b9a; }
.img-role-badge--gallery   { background: #e65100; }

.img-role-preview {
  position: relative;
  border-radius: var(--admin-radius-sm);
  overflow: hidden;
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
}

.img-role-preview img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

/* Floating role label overlay on image previews */
.img-role-label {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 3;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: #fff;
  pointer-events: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.4);
  line-height: 1;
}
.img-role-label--thumbnail { background: #1565c0; }
.img-role-label--cover     { background: #2e7d32; }
.img-role-label--main      { background: #6a1b9a; }
.img-role-label--gallery   { background: #e65100; }

.img-role-label .img-role-ratio {
  font-weight: 400;
  opacity: 0.85;
  font-size: 10px;
}

/* Action buttons bar — better contrast and sizing */
.img-role-preview .img-role-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
  padding: 8px 6px;
  background: rgba(0,0,0,0.82);
}

.img-role-preview .img-role-actions .btn {
  font-size: 12px;
  padding: 5px 10px;
  white-space: nowrap;
  border-color: rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(4px);
  transition: all 0.15s;
}
.img-role-preview .img-role-actions .btn:hover {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.5);
  color: #fff;
}
.img-role-preview .img-role-actions .btn-danger {
  border-color: var(--admin-danger);
  color: var(--admin-danger);
  background: rgba(255,61,87,0.1);
}
.img-role-preview .img-role-actions .btn-danger:hover {
  background: var(--admin-danger);
  color: #fff;
}

.img-role-placeholder {
  height: 120px;
  border: 2px dashed var(--admin-border);
  border-radius: var(--admin-radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--admin-text-dim);
  font-size: 13px;
}

.img-role-placeholder .placeholder-role {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 4px;
  color: #fff;
}
.img-role-placeholder .placeholder-role--thumbnail { background: #1565c0; }
.img-role-placeholder .placeholder-role--cover     { background: #2e7d32; }
.img-role-placeholder .placeholder-role--main      { background: #6a1b9a; }
.img-role-placeholder .placeholder-role--gallery   { background: #e65100; }

.img-role-placeholder .placeholder-hint {
  font-size: 12px;
  color: var(--admin-text-dim);
}

.img-role-placeholder:hover {
  border-color: var(--admin-accent-soft);
  color: var(--admin-text);
}

/* Image visibility toggle */
.img-visibility-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0 2px;
  font-size: 12px;
  color: var(--admin-text-dim);
  cursor: pointer;
  user-select: none;
}

.img-visibility-toggle input[type="checkbox"] {
  accent-color: var(--admin-accent-soft);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* Role switch button */
.img-role-switch {
  font-size: 11px !important;
  padding: 4px 8px !important;
  border-color: var(--admin-accent-soft) !important;
  color: var(--admin-accent-soft) !important;
}

.img-role-switch:hover {
  background: var(--admin-accent-soft) !important;
  color: var(--admin-text) !important;
}

/* Gallery visibility checkbox */
.img-gallery-visible {
  position: absolute;
  bottom: 4px;
  left: 4px;
  z-index: 3;
  cursor: pointer;
  background: rgba(0,0,0,0.65);
  border-radius: 4px;
  padding: 3px;
  line-height: 0;
}

.img-gallery-visible input[type="checkbox"] {
  accent-color: var(--admin-accent-soft);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

/* Gallery role badge overlay */
.img-gallery-role-label {
  position: absolute;
  top: 4px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  background: #e65100;
  color: #fff;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.img-gallery-thumb.img-hidden img {
  opacity: 0.35;
}

.img-thumb-edit {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.2);
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  z-index: 3;
}

.img-gallery-thumb:hover .img-thumb-edit {
  opacity: 1;
}

.img-thumb-edit:hover {
  background: var(--admin-accent-soft);
  border-color: var(--admin-accent-soft);
  color: #fff;
}

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

.img-gallery-thumb {
  position: relative;
  border-radius: var(--admin-radius-sm);
  overflow: hidden;
  border: 1px solid var(--admin-border);
  cursor: grab;
  aspect-ratio: 1;
}

.img-gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.img-gallery-thumb .img-thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  background: rgba(0,0,0,0.75);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  color: var(--admin-danger);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: none;
  transition: background 0.15s;
  z-index: 3;
}
.img-gallery-thumb .img-thumb-remove:hover {
  background: var(--admin-danger);
  border-color: var(--admin-danger);
  color: #fff;
}

.img-gallery-thumb:hover .img-thumb-remove { display: flex; align-items: center; justify-content: center; }

.img-gallery-thumb.dragging { opacity: 0.4; }
.img-gallery-thumb.drag-over { box-shadow: 0 0 0 2px var(--admin-accent-soft); }

/* SEO info on thumbnail hover */
.img-thumb-seo {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 6px;
  background: rgba(0,0,0,0.7);
  font-size: 10px;
  color: var(--admin-text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 768px) {
  .img-editor-modal { max-width: 100%; max-height: 100vh; border-radius: 0; }
  .img-editor-canvas-wrap { max-height: 300px; }
  .img-editor-toolbar { justify-content: center; }
  .img-gallery-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ========== Category Editor ========== */
.category-editor-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.category-editor-card {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  transition: border-color 0.2s;
  cursor: grab;
}

.category-editor-card:hover {
  border-color: var(--admin-accent-soft);
}

.category-editor-card.dragging {
  opacity: 0.4;
}

.category-editor-card.drag-over {
  border-color: var(--admin-accent-soft);
  box-shadow: 0 0 0 2px rgba(128, 96, 255, 0.3);
}

.category-editor-drag {
  font-size: 18px;
  color: var(--admin-text-dim);
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}

.category-editor-order {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--admin-accent);
  color: var(--admin-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.category-editor-thumb {
  width: 120px;
  height: 68px;
  object-fit: cover;
  border-radius: var(--admin-radius-sm);
  background: var(--admin-bg);
  flex-shrink: 0;
}

.category-editor-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--admin-text-dim);
  border: 1px dashed var(--admin-border);
}

.category-editor-info {
  flex: 1;
  min-width: 0;
}

.category-editor-info h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 2px;
}

.category-editor-info p {
  font-size: 13px;
  color: var(--admin-text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 4px;
}

.category-editor-count {
  font-size: 12px;
  color: var(--admin-accent-soft);
}

/* Category edit modal layout */
.cat-edit-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-top: 16px;
}

/* Services list in edit modal */
.cat-services-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 300px;
  overflow-y: auto;
}

.cat-service-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--admin-bg);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius-sm);
  font-size: 14px;
  cursor: grab;
  transition: border-color 0.2s;
}

.cat-service-item:hover {
  border-color: var(--admin-accent-soft);
}

.cat-service-item.dragging {
  opacity: 0.4;
}

.cat-service-item.drag-over {
  border-color: var(--admin-accent-soft);
  box-shadow: 0 0 0 2px rgba(128, 96, 255, 0.2);
}

.cat-service-drag {
  color: var(--admin-text-dim);
  font-size: 14px;
  cursor: grab;
  user-select: none;
}

.cat-service-item img {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .cat-edit-layout {
    grid-template-columns: 1fr;
  }
  .category-editor-card {
    flex-wrap: wrap;
  }
  .category-editor-thumb {
    width: 80px;
    height: 45px;
  }
}

/* ========== Admin Gallery Grid (mirrors frontend .gallery-grid exactly) ========== */
.admin-gallery-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 350px;
  gap: 20px;
  position: relative;
}

.admin-gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  border: 1px solid var(--admin-border);
  cursor: grab;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.admin-gallery-item:hover {
  border-color: var(--admin-accent-soft);
}

.admin-gallery-item.dragging {
  opacity: 0.4;
}

.admin-gallery-item.drag-over {
  border-color: var(--admin-accent-soft);
  box-shadow: 0 0 0 2px rgba(128, 96, 255, 0.3);
}

.admin-gallery-item {
  min-height: 0;
}

.admin-gallery-item > img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.admin-gallery-item:hover > img {
  transform: scale(1.03);
}

/* Drag handle */
.admin-gallery-drag {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 28px;
  height: 28px;
  background: rgba(0, 0, 0, 0.7);
  border-radius: var(--admin-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--admin-text-dim);
  z-index: 3;
  cursor: grab;
  opacity: 0.6;
  transition: opacity 0.2s;
}

.admin-gallery-item:hover .admin-gallery-drag {
  opacity: 1;
}

/* Category badge */
.admin-gallery-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--admin-text-dim);
  z-index: 3;
}

/* Hover overlay with actions */
.admin-gallery-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  padding: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.25s ease;
  z-index: 3;
}

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

.admin-gallery-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 2px;
}

.admin-gallery-alt {
  font-size: 13px;
  font-weight: 500;
  color: var(--admin-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.admin-gallery-caption {
  font-size: 11px;
  color: var(--admin-text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.admin-gallery-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
}

.admin-gallery-actions .btn {
  font-size: 11px !important;
  padding: 5px 10px !important;
}

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

@media (max-width: 768px) {
  .admin-gallery-grid {
    grid-template-columns: 1fr;
    grid-auto-rows: 300px;
    max-width: 400px;
    margin: 0 auto;
  }
  .admin-gallery-overlay {
    opacity: 1;
  }
}

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

/* ========== Tall Toggle Button ========== */
.admin-gallery-tall-toggle {
  position: absolute;
  top: 38px;
  right: 8px;
  background: rgba(0, 0, 0, 0.7);
  border: 1px solid transparent;
  color: var(--admin-text-dim);
  font-size: 10px;
  padding: 3px 8px;
  border-radius: 20px;
  cursor: pointer;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.2s, border-color 0.2s;
  white-space: nowrap;
}

.admin-gallery-item:hover .admin-gallery-tall-toggle {
  opacity: 1;
}

.admin-gallery-tall-toggle:hover {
  border-color: var(--admin-accent-soft);
  color: var(--admin-text);
}

/* ========== Focus Mode ========== */
.gallery-focus-active .admin-gallery-item:not(.focus-mode) {
  opacity: 0.3;
  pointer-events: none;
  transition: opacity 0.25s;
}

.admin-gallery-item.focus-mode {
  border-color: var(--admin-accent-soft);
  box-shadow: 0 0 0 3px rgba(128, 96, 255, 0.3);
  cursor: crosshair;
  z-index: 10;
  user-select: none;
}

.admin-gallery-item.focus-mode > img {
  cursor: crosshair;
  transition: none;
}

.admin-gallery-item.focus-mode:hover > img {
  transform: none;
}

.admin-gallery-item.focus-mode .admin-gallery-overlay,
.admin-gallery-item.focus-mode .admin-gallery-drag,
.admin-gallery-item.focus-mode .admin-gallery-badge,
.admin-gallery-item.focus-mode .admin-gallery-tall-toggle,
.admin-gallery-item.focus-mode .admin-size-presets,
.admin-gallery-item.focus-mode .admin-resize-handle {
  display: none;
}

/* Focus reticle */
.admin-gallery-focus-reticle {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 2px solid var(--admin-accent-soft);
  border-radius: 50%;
  pointer-events: none;
  z-index: 5;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5), 0 0 8px rgba(128, 96, 255, 0.4);
}

.admin-gallery-focus-reticle::before,
.admin-gallery-focus-reticle::after {
  content: '';
  position: absolute;
  background: var(--admin-accent-soft);
}

.admin-gallery-focus-reticle::before {
  width: 2px;
  height: 10px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.admin-gallery-focus-reticle::after {
  width: 10px;
  height: 2px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Focus hint */
.admin-gallery-focus-hint {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  background: rgba(0, 0, 0, 0.85);
  color: var(--admin-text);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 11px;
  white-space: nowrap;
  pointer-events: none;
}

/* Focus done button */
.admin-gallery-focus-done {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 6;
  background: var(--admin-accent);
  color: white;
  border: none;
  padding: 8px 24px;
  border-radius: var(--admin-radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.admin-gallery-focus-done:hover {
  background: var(--admin-accent-hover);
}

/* ========== Resize Handles (all corners) ========== */
.admin-resize-handle {
  position: absolute;
  width: 20px;
  height: 20px;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.2s;
}

.admin-resize-br { bottom: 6px; right: 6px; cursor: nwse-resize; }
.admin-resize-bl { bottom: 6px; left: 6px; cursor: nesw-resize; }
.admin-resize-tr { top: 6px; right: 6px; cursor: nesw-resize; }
.admin-resize-tl { top: 6px; left: 6px; cursor: nwse-resize; }

.admin-resize-handle::before,
.admin-resize-handle::after {
  content: '';
  position: absolute;
  background: var(--admin-accent-soft);
  border-radius: 1px;
}

.admin-resize-handle::before {
  bottom: 0; right: 0;
  width: 14px; height: 2px;
}

.admin-resize-handle::after {
  bottom: 0; right: 0;
  width: 2px; height: 14px;
}

.admin-gallery-item:hover .admin-resize-handle {
  opacity: 1;
}

.admin-gallery-item.resizing {
  outline: 2px solid var(--admin-accent-soft);
  outline-offset: -2px;
  z-index: 5;
}

/* Size presets (T/N/W buttons) */
.admin-size-presets {
  position: absolute;
  top: 38px;
  right: 8px;
  display: flex;
  gap: 3px;
  z-index: 3;
  opacity: 0;
  transition: opacity 0.2s;
}

.admin-gallery-item:hover .admin-size-presets {
  opacity: 1;
}

.admin-size-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(0, 0, 0, 0.7);
  color: var(--admin-text-dim);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  padding: 0;
}

.admin-size-btn:hover {
  border-color: var(--admin-accent-soft);
  color: var(--admin-text);
}

.admin-size-btn.active {
  background: var(--admin-accent-soft);
  border-color: var(--admin-accent-soft);
  color: white;
}

/* ========== Edge Handles (between adjacent images) ========== */
.admin-border-handle {
  position: absolute;
  width: 12px;
  margin-left: -3px;
  cursor: col-resize;
  z-index: 2;
  transition: background 0.15s;
  border-radius: 3px;
  background: rgba(128, 96, 255, 0.15);
}

.admin-border-handle:hover,
.admin-border-handle.dragging {
  background: rgba(128, 96, 255, 0.5);
  z-index: 4;
}

.admin-border-handle-h {
  position: absolute;
  height: 12px;
  margin-top: -3px;
  cursor: row-resize;
  z-index: 2;
  transition: background 0.15s;
  border-radius: 3px;
  background: rgba(128, 96, 255, 0.15);
}

.admin-border-handle-h:hover,
.admin-border-handle-h.dragging {
  background: rgba(128, 96, 255, 0.5);
  z-index: 4;
}

/* Save bar active - prevent overlap with bottom actions */
.admin-container.save-bar-active {
  padding-bottom: 70px;
}

/* Grid edit mode outline */
.grid-edit-mode .admin-gallery-grid {
  outline: 1px dashed rgba(128, 96, 255, 0.3);
  outline-offset: -1px;
}

/* Only show resize handles and size presets in grid edit mode */
.admin-container:not(.grid-edit-mode) .admin-resize-handle,
.admin-container:not(.grid-edit-mode) .admin-size-presets {
  display: none;
}

/* ========== Preset Panel ========== */
.admin-preset-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.admin-preset-bar label {
  font-size: 12px;
  color: var(--admin-text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 600;
}

.admin-preset-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius-sm);
  cursor: pointer;
  color: var(--admin-text-dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all 0.2s;
}

.admin-preset-btn:hover,
.admin-preset-btn.active {
  border-color: var(--admin-accent-soft);
  color: var(--admin-text);
  background: rgba(128, 96, 255, 0.08);
}

.admin-preset-btn svg {
  display: block;
}

/* Hide resize/border features on small screens */
@media (max-width: 1024px) {
  .admin-resize-handle,
  .admin-border-handle,
  .admin-border-handle-h,
  .admin-preset-bar,
  .admin-size-presets {
    display: none;
  }
}
