/* =============================================
   ADMIN PANEL STYLES
   ============================================= */

:root {
  --admin-primary: #e10000;
  --admin-dark: #24211d;
  --admin-bg: #f0f2f5;
  --admin-card: #ffffff;
  --admin-border: #dde1e6;
  --admin-text: #333;
  --admin-text-light: #666;
  --admin-success: #22c55e;
  --admin-warning: #f59e0b;
  --admin-danger: #ef4444;
  --admin-radius: 8px;
  --admin-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

* { 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);
  line-height: 1.5;
}

/* --- Login Overlay --- */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--admin-dark);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--admin-card);
  border-radius: 12px;
  padding: 2.5rem;
  width: 380px;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.login-card h2 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--admin-dark);
}

/* --- Top Bar --- */
.admin-topbar {
  background: var(--admin-dark);
  color: #fff;
  padding: 0 1.5rem;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.admin-topbar .logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
  font-size: 1rem;
}
.admin-topbar .logo img { height: 32px; }
.admin-topbar .logo span { color: var(--admin-primary); }
.admin-topbar-actions { display: flex; gap: 0.5rem; }

/* --- Tabs --- */
.admin-tabs {
  display: flex;
  background: var(--admin-card);
  border-bottom: 1px solid var(--admin-border);
  padding: 0 1.5rem;
}
.admin-tab {
  padding: 0.75rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--admin-text-light);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.admin-tab:hover { color: var(--admin-text); }
.admin-tab.active {
  color: var(--admin-primary);
  border-bottom-color: var(--admin-primary);
}

/* --- Main Layout --- */
.admin-main { padding: 1.5rem; max-width: 1400px; margin: 0 auto; }

/* --- Cards --- */
.admin-card {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  box-shadow: var(--admin-shadow);
  margin-bottom: 1.5rem;
}
.admin-card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.admin-card-header h2 {
  font-size: 1rem;
  font-weight: 600;
}
.admin-card-body { padding: 1.5rem; }

/* --- Buttons --- */
.btn-admin {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--admin-border);
  background: var(--admin-card);
  color: var(--admin-text);
  transition: all 0.15s;
}
.btn-admin:hover { background: #f5f5f5; }
.btn-admin-primary {
  background: var(--admin-primary);
  color: #fff;
  border-color: var(--admin-primary);
}
.btn-admin-primary:hover { background: #c40000; }
.btn-admin-success {
  background: var(--admin-success);
  color: #fff;
  border-color: var(--admin-success);
}
.btn-admin-success:hover { background: #16a34a; }
.btn-admin-danger {
  background: var(--admin-danger);
  color: #fff;
  border-color: var(--admin-danger);
}
.btn-admin-danger:hover { background: #dc2626; }
.btn-admin-sm { padding: 0.3rem 0.6rem; font-size: 0.75rem; }
.btn-admin-lg { padding: 0.75rem 1.5rem; font-size: 0.9375rem; }
.btn-admin:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Bulk Actions Bar --- */
.bulk-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: var(--admin-radius);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.bulk-bar #bulkCount {
  font-weight: 600;
  font-size: 0.8125rem;
  margin-right: 0.5rem;
  color: #4338ca;
}

/* --- Product Table --- */
.product-table {
  width: 100%;
  border-collapse: collapse;
}
.product-table th,
.product-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--admin-border);
  font-size: 0.8125rem;
}
.product-table th {
  font-weight: 600;
  color: var(--admin-text-light);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: #fafbfc;
}
.product-table tr:hover td { background: #f8f9fa; }
.product-table .thumb {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  object-fit: cover;
  background: #f0f0f0;
}
.product-table .product-name-cell {
  font-weight: 500;
  color: var(--admin-dark);
}
.product-table .badge-cell {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
}
.badge-visible { background: #dcfce7; color: #166534; }
.badge-hidden { background: #fef2f2; color: #991b1b; }
.badge-featured { background: #fef9c3; color: #854d0e; }
.badge-sold-out { background: #fee2e2; color: #991b1b; }

/* --- Drag Handle --- */
.drag-handle {
  cursor: grab;
  color: var(--admin-text-light);
  font-size: 1rem;
  user-select: none;
  text-align: center;
}
.drag-handle:active { cursor: grabbing; }
.cat-drag {
  cursor: grab;
  color: var(--admin-text-light);
  font-size: 1rem;
  user-select: none;
  flex-shrink: 0;
}

/* SortableJS ghost */
.sortable-ghost {
  opacity: 0.4;
  background: #eef2ff;
}

/* --- Action Buttons in Table --- */
.action-btns { display: flex; gap: 0.3rem; }

/* --- Search / Filter Bar --- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.search-input {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem 1rem;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  font-size: 0.875rem;
  outline: none;
}
.search-input:focus { border-color: var(--admin-primary); }
.filter-select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  font-size: 0.875rem;
  background: #fff;
  outline: none;
}

/* --- Forms --- */
.form-group {
  margin-bottom: 1.25rem;
}
.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--admin-text);
}
.form-group label .hint {
  font-weight: 400;
  color: var(--admin-text-light);
  font-size: 0.75rem;
}
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border 0.15s;
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--admin-primary);
  box-shadow: 0 0 0 2px rgba(225,0,0,0.1);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

/* --- Checkbox / Toggle --- */
.toggle-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.toggle-switch {
  position: relative;
  width: 40px;
  height: 22px;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 11px;
  cursor: pointer;
  transition: 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 2px;
  top: 2px;
  background: white;
  border-radius: 50%;
  transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--admin-success); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

/* --- Specs Editor --- */
.specs-list { display: flex; flex-direction: column; gap: 0.5rem; }
.spec-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.spec-row input { flex: 1; }
.spec-row .btn-remove-spec,
.additional-image-row .btn-remove-spec {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: #fee2e2;
  color: var(--admin-danger);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.spec-row .btn-remove-spec:hover,
.additional-image-row .btn-remove-spec:hover { background: #fecaca; }

/* --- Image Preview --- */
.image-preview-box {
  width: 120px;
  height: 120px;
  border: 2px dashed var(--admin-border);
  border-radius: var(--admin-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #fafbfc;
  margin-top: 0.5rem;
}
.image-preview-box img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.image-preview-box .placeholder {
  color: var(--admin-text-light);
  font-size: 0.75rem;
  text-align: center;
}

/* --- Image Preview Grid (all images) --- */
.image-preview-grid {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.img-preview-thumb {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid var(--admin-success);
  position: relative;
  background: #fafbfc;
}
.img-preview-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.img-preview-thumb.img-error {
  border-color: var(--admin-danger);
}
.img-preview-thumb.img-error::after {
  content: '!';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--admin-danger);
  font-weight: 700;
  font-size: 1.2rem;
  background: rgba(255,255,255,0.8);
}

/* --- Additional Images --- */
.additional-images { display: flex; flex-direction: column; gap: 0.5rem; }
.additional-image-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}
.additional-image-row input { flex: 1; }

/* --- Modal / Editor Panel --- */
.editor-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  display: none;
}
.editor-overlay.open { display: block; }
.editor-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 640px;
  max-width: 100%;
  height: 100%;
  background: var(--admin-card);
  z-index: 201;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 24px rgba(0,0,0,0.15);
}
.editor-overlay.open + .editor-panel,
.editor-panel.open { transform: translateX(0); }
.editor-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--admin-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.editor-header h2 { font-size: 1.125rem; font-weight: 600; }
.editor-close {
  width: 32px;
  height: 32px;
  border: none;
  background: none;
  font-size: 1.25rem;
  cursor: pointer;
  border-radius: 6px;
  color: var(--admin-text-light);
}
.editor-close:hover { background: #f0f0f0; }
.editor-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}
.editor-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--admin-border);
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* --- Toast Notification --- */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.toast {
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideIn 0.3s ease;
}
.toast-success { background: var(--admin-success); }
.toast-error { background: var(--admin-danger); }
.toast-info { background: #3b82f6; }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --- Category Cards --- */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.category-card {
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 1rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  background: var(--admin-card);
}
.category-card img {
  width: 60px;
  height: 60px;
  border-radius: 6px;
  object-fit: cover;
  background: #f0f0f0;
}
.category-card-info { flex: 1; }
.category-card-info h3 { font-size: 0.875rem; font-weight: 600; margin-bottom: 0.2rem; }
.category-card-info p { font-size: 0.75rem; color: var(--admin-text-light); margin: 0; }
.category-card-actions { display: flex; gap: 0.3rem; }

/* --- Stats Bar --- */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--admin-card);
  border: 1px solid var(--admin-border);
  border-radius: var(--admin-radius);
  padding: 1rem 1.25rem;
}
.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--admin-text-light);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-card .stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--admin-dark);
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--admin-text-light);
}
.empty-state h3 { font-size: 1.125rem; margin-bottom: 0.5rem; color: var(--admin-text); }

/* --- Rental-specific badges --- */
.badge-available { background: #dcfce7; color: #166534; }
.badge-limited { background: #fef9c3; color: #854d0e; }
.badge-rented { background: #fee2e2; color: #991b1b; }

/* --- Unit Cards --- */
.unit-card {
  border: 1px solid var(--admin-border);
  border-radius: 6px;
  margin-bottom: 0.5rem;
  background: #fafbfc;
}
.unit-card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  user-select: none;
}
.unit-card-header:hover { background: #f0f2f5; }
.unit-card-serial {
  font-size: 0.75rem;
  font-family: monospace;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.unit-card-label {
  font-size: 0.6875rem;
  color: var(--admin-text-light);
  margin-left: 0.25rem;
  font-family: inherit;
  font-weight: 400;
}
.unit-card-toggle {
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  font-size: 0.75rem;
  cursor: pointer;
  color: var(--admin-text-light);
  border-radius: 4px;
  transition: transform 0.2s;
}
.unit-card-toggle:hover { background: #e5e7eb; }
.unit-card-toggle.open { transform: rotate(90deg); }
.unit-card-body {
  display: none;
  padding: 0.75rem;
  border-top: 1px solid var(--admin-border);
}
.unit-card-body.open { display: block; }
.unit-card-body .unit-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}
.unit-card-body .unit-field-full {
  grid-column: 1 / -1;
}
.unit-card-body label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--admin-text-light);
  margin-bottom: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.unit-card-body input,
.unit-card-body select,
.unit-card-body textarea {
  width: 100%;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--admin-border);
  border-radius: 4px;
  font-size: 0.8125rem;
  font-family: inherit;
  outline: none;
}
.unit-card-body input:focus,
.unit-card-body select:focus,
.unit-card-body textarea:focus {
  border-color: var(--admin-primary);
}
.unit-card-body textarea { resize: vertical; min-height: 48px; }
.unit-status-badge {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.unit-status-available { background: #dcfce7; color: #166534; }
.unit-status-rented { background: #fee2e2; color: #991b1b; }
.unit-status-maintenance { background: #fef3c7; color: #92400e; }

/* --- Responsive --- */
@media (max-width: 768px) {
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .editor-panel { width: 100%; }
  .toolbar { flex-direction: column; }
  .admin-tabs { overflow-x: auto; }
  .bulk-bar { flex-direction: column; align-items: stretch; }
}
