/* ============================================
   YATAI Admin - Menu Management Styles
   Only visible in admin mode (body.admin-mode)
   ============================================ */

/* --- Admin controls on menu items (hidden by default) --- */
.admin-controls {
  display: none;
}

body.admin-mode .admin-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 6px 0;
}

.admin-btn {
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  transition: opacity 0.2s;
}

.admin-btn:active {
  opacity: 0.7;
}

.admin-btn-toggle {
  background: #2ecc71;
  color: #fff;
}

.admin-btn-toggle.inactive {
  background: #95a5a6;
}

.admin-btn-edit {
  background: #3498db;
  color: #fff;
}

.admin-btn-delete {
  background: #e74c3c;
  color: #fff;
}

/* --- Inactive item styling --- */
body.admin-mode .menu-item.item-inactive {
  opacity: 0.4;
  position: relative;
}

body.admin-mode .menu-item.item-inactive::after {
  content: 'HIDDEN';
  position: absolute;
  top: 8px;
  right: 8px;
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 3px;
}

/* --- Add item button (per category, hidden by default) --- */
.admin-add-btn {
  display: none;
}

body.admin-mode .admin-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  border: 2px dashed rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

body.admin-mode .admin-add-btn:hover,
body.admin-mode .admin-add-btn:active {
  border-color: #e8a735;
  color: #e8a735;
}

/* --- Publish Bar (fixed bottom) --- */
.admin-publish-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #2c3e50;
  padding: 12px 20px;
  z-index: 200;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
  transition: transform 0.3s ease;
}

.publish-bar-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1200px;
  margin: 0 auto;
}

.publish-bar-status {
  color: #ecf0f1;
  font-size: 14px;
  font-weight: 500;
}

.admin-publish-bar.has-changes .publish-bar-status {
  color: #e8a735;
}

.publish-bar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.koen-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: #bdc3c7;
  cursor: pointer;
  margin-right: 8px;
}

.koen-toggle input {
  accent-color: #e8a735;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.btn-discard {
  background: #7f8c8d;
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}

.btn-publish {
  background: #e8a735;
  color: #1a1a1a;
  border: none;
  padding: 8px 24px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 700;
}

.btn-exit-admin {
  background: #95a5a6;
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 500;
}

/* --- Modal overlay --- */
.admin-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
}

.admin-modal.visible {
  display: flex;
}

.admin-modal-content {
  background: #2c3e50;
  border-radius: 12px;
  padding: 24px;
  width: 90%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  color: #ecf0f1;
  -webkit-overflow-scrolling: touch;
}

.admin-modal-content h3 {
  margin-bottom: 16px;
  font-size: 18px;
  color: #e8a735;
}

/* --- PIN modal --- */
.pin-modal input {
  width: 100%;
  padding: 14px;
  font-size: 24px;
  text-align: center;
  letter-spacing: 12px;
  border: 2px solid #34495e;
  border-radius: 8px;
  background: #1a1a1a;
  color: #ecf0f1;
  margin-bottom: 16px;
}

.pin-modal input:focus {
  outline: none;
  border-color: #e8a735;
}

.pin-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.pin-error {
  color: #e74c3c;
  font-size: 13px;
  margin-top: 8px;
  min-height: 20px;
}

/* --- Edit modal --- */
.edit-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.edit-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: #95a5a6;
}

.edit-form input,
.edit-form select {
  padding: 10px 12px;
  font-size: 15px;
  border: 1px solid #34495e;
  border-radius: 6px;
  background: #1a1a1a;
  color: #ecf0f1;
}

.edit-form input:focus,
.edit-form select:focus {
  outline: none;
  border-color: #e8a735;
}

.edit-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* --- Shared button styles --- */
.btn-cancel {
  background: #7f8c8d;
  color: #fff;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.btn-confirm {
  background: #e8a735;
  color: #1a1a1a;
  border: none;
  padding: 10px 24px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 700;
}

.btn-confirm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* --- Image upload in edit modal --- */
.edit-image-section {
  position: relative;
  margin-bottom: 8px;
  cursor: pointer;
  border-radius: 10px;
  overflow: hidden;
  background: #1a1a1a;
  border: 2px dashed #34495e;
  transition: border-color 0.2s;
}

.edit-image-section:active {
  border-color: #e8a735;
}

.edit-img-wrap {
  width: 100%;
  height: 160px;
  overflow: hidden;
  background: #1a1a1a;
}

.edit-img-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.edit-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #666;
  font-size: 13px;
  gap: 6px;
}

.edit-img-placeholder::before {
  content: '+';
  font-size: 32px;
  color: #555;
  line-height: 1;
}

.edit-img-tap-hint {
  text-align: center;
  font-size: 11px;
  color: #888;
  padding: 6px 0;
  background: rgba(0,0,0,0.3);
}

.edit-checkbox {
  flex-direction: row !important;
  align-items: center !important;
  gap: 8px !important;
  font-size: 14px !important;
  color: #ecf0f1 !important;
  cursor: pointer;
}

.edit-checkbox input {
  width: 18px;
  height: 18px;
  accent-color: #e8a735;
}

/* --- Toast notification --- */
.admin-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #2ecc71;
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  z-index: 400;
  opacity: 0;
  transition: all 0.3s ease;
  pointer-events: none;
}

.admin-toast.error {
  background: #e74c3c;
}

.admin-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Crop modal --- */
.crop-modal {
  max-width: 360px;
  width: 90vw;
}

.crop-hint {
  font-size: 12px;
  color: #95a5a6;
  margin-bottom: 8px;
}

.crop-container {
  width: 300px;
  height: 225px;
  margin: 0 auto;
  border: 2px solid #e8a735;
  border-radius: 6px;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
}

.crop-container:active {
  cursor: grabbing;
}

#cropCanvas {
  display: block;
  width: 300px;
  height: 225px;
}

.crop-zoom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  color: #95a5a6;
  font-size: 14px;
}

.crop-zoom-label {
  min-width: 42px;
  text-align: center;
  font-size: 12px;
  color: #e8a735;
}

.crop-zoom input[type="range"] {
  flex: 1;
  accent-color: #e8a735;
  height: 6px;
}

/* --- Password modal (replaces PIN) --- */
.pin-modal input {
  letter-spacing: 2px;
  font-size: 18px;
}

/* --- Admin card overlay (button row below card content) --- */
.admin-card-overlay {
  display: none;
}

body.admin-mode .admin-card-overlay {
  display: flex;
  gap: 6px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.06);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  justify-content: center;
  flex-wrap: wrap;
}

body.admin-mode .menu-card {
  position: relative;
}

/* Portrait (list layout): button row at end of flex row */
@media (orientation: portrait), (max-width: 768px) {
  body.admin-mode .admin-card-overlay {
    flex-direction: column;
    gap: 4px;
    padding: 6px 8px;
    border-top: none;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    justify-content: center;
    align-items: stretch;
  }
}

:root.light body.admin-mode .admin-card-overlay {
  background: rgba(0, 0, 0, 0.03);
  border-top-color: rgba(0, 0, 0, 0.1);
}

@media (orientation: portrait), (max-width: 768px) {
  :root.light body.admin-mode .admin-card-overlay {
    border-left-color: rgba(0, 0, 0, 0.1);
  }
}

.admin-card-btn {
  background: rgba(255, 255, 255, 0.95);
  color: #333;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s;
  white-space: nowrap;
}

.admin-card-btn:active {
  transform: scale(0.92);
}

.admin-card-btn.best-on {
  background: #FEE500;
  color: #3C1E1E;
}

.admin-card-btn.best-off {
  background: rgba(255, 255, 255, 0.6);
  color: #888;
}

.admin-card-btn.btn-edit-card {
  background: #3498db;
  color: #fff;
}

.admin-card-btn.btn-del-card {
  background: #e74c3c;
  color: #fff;
}

/* --- Admin settings button in publish bar --- */
.btn-admin-settings {
  background: #e8a735;
  color: #1a1a1a;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 700;
}

/* --- Admin add item FAB (per category) --- */
body.admin-mode .admin-add-fab {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  border: 2px dashed rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  background: transparent;
  color: rgba(255, 255, 255, 0.5);
  font-size: 24px;
  cursor: pointer;
  transition: all 0.2s;
  width: 100%;
}

body.admin-mode .admin-add-fab:hover {
  border-color: #e8a735;
  color: #e8a735;
}

.admin-add-fab {
  display: none;
}

/* --- Settings modal --- */
.settings-modal {
  max-width: 520px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

.settings-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}

.settings-tab {
  flex: 1;
  padding: 8px 12px;
  background: #34495e;
  color: #95a5a6;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.settings-tab.active {
  background: #e8a735;
  color: #1a1a1a;
}

.settings-tab:hover:not(.active) {
  background: #3d566e;
  color: #ecf0f1;
}

.settings-list {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 8px;
}

.settings-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  margin-bottom: 4px;
  font-size: 13px;
  color: #95a5a6;
  font-weight: 600;
}

.settings-add-cat-btn {
  background: #2980b9;
  color: #fff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.settings-add-cat-btn:hover {
  background: #3498db;
}

.settings-del-btn {
  background: #c0392b;
  color: #fff;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
}

.settings-del-btn:hover {
  background: #e74c3c;
}

.settings-cat-name {
  font-size: 13px;
  font-weight: 700;
  color: #e8a735;
  padding: 10px 0 4px;
  border-bottom: 1px solid #34495e;
  margin-bottom: 4px;
}

.settings-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.settings-sort-btns {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex-shrink: 0;
}

.settings-sort-btn {
  background: #34495e;
  color: #bdc3c7;
  border: none;
  width: 22px;
  height: 16px;
  font-size: 8px;
  cursor: pointer;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}

.settings-sort-btn:hover:not(:disabled) {
  background: #e8a735;
  color: #1a1a1a;
}

.settings-sort-btn:disabled {
  opacity: 0.2;
  cursor: not-allowed;
}

.settings-item-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: #ecf0f1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.settings-item-price {
  font-size: 12px;
  color: #95a5a6;
  min-width: 60px;
  text-align: right;
}

.settings-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex-shrink: 0;
}

.settings-toggle input {
  width: 16px;
  height: 16px;
  accent-color: #e8a735;
  cursor: pointer;
}

.settings-toggle-label {
  font-size: 11px;
  font-weight: 700;
  min-width: 28px;
}

.settings-toggle-label.best-label {
  color: #FEE500;
}

.settings-toggle-label.active-label {
  color: #2ecc71;
}

.settings-edit-btn {
  background: #34495e;
  color: #ecf0f1;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
}

.settings-edit-btn:hover {
  background: #3d566e;
}

/* --- Auto translate section in edit modal --- */
.edit-translate-section {
  margin-top: 4px;
}

.btn-translate {
  background: #2980b9;
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  transition: background 0.2s;
}

.btn-translate:hover {
  background: #3498db;
}

.btn-translate:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.translate-status {
  font-size: 11px;
  color: #95a5a6;
  margin-top: 6px;
  white-space: pre-line;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
}

/* --- Edit modal wider for Korean labels --- */
.edit-modal {
  max-width: 440px;
  max-height: 85vh;
}

/* --- Options editor --- */
.edit-options-section {
  margin-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 12px;
}

.edit-options-section > label {
  display: block;
  font-size: 13px;
  color: #aaa;
  margin-bottom: 8px;
}

.edit-options-empty {
  color: #666;
  font-size: 13px;
  padding: 4px 0;
}

.edit-option-row {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
  align-items: center;
}

.edit-option-row input {
  flex: 1;
  padding: 8px;
  border: 1px solid #444;
  border-radius: 6px;
  background: #1a1a1a;
  color: #fff;
  font-size: 14px;
}

.edit-option-row input:focus {
  border-color: var(--red);
  outline: none;
}

.opt-delete {
  width: 32px;
  height: 32px;
  border: none;
  background: #c0392b;
  color: #fff;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-add-option {
  width: 100%;
  padding: 8px;
  border: 2px dashed #555;
  border-radius: 6px;
  background: transparent;
  color: #aaa;
  font-size: 14px;
  cursor: pointer;
  margin-top: 4px;
}

.btn-add-option:hover {
  border-color: var(--red);
  color: var(--red);
}

/* --- Light mode overrides for admin UI --- */
:root.light body.admin-mode .admin-add-fab {
  border-color: rgba(0, 0, 0, 0.5);
  color: #000;
}

:root.light body.admin-mode .admin-add-fab:hover {
  border-color: #C49A00;
  color: #C49A00;
}

:root.light .admin-modal-content {
  background: #fff;
  color: #222;
}

:root.light .admin-modal-content h3 {
  color: #A1161A;
}

:root.light .edit-form label {
  color: #555;
}

:root.light .edit-form input,
:root.light .edit-form select {
  background: #f5f5f5;
  border-color: #ccc;
  color: #222;
}

:root.light .edit-form input:focus,
:root.light .edit-form select:focus {
  border-color: #C49A00;
}

:root.light .edit-image-section {
  background: #f0f0f0;
  border-color: #ccc;
}

:root.light .edit-img-wrap {
  background: #f0f0f0;
}

:root.light .edit-img-placeholder {
  color: #999;
}

:root.light .edit-img-tap-hint {
  background: rgba(0, 0, 0, 0.05);
  color: #666;
}

:root.light .edit-checkbox {
  color: #222 !important;
}

:root.light .edit-options-section > label {
  color: #555;
}

:root.light .edit-options-empty {
  color: #999;
}

:root.light .edit-option-row input {
  background: #f5f5f5;
  border-color: #ccc;
  color: #222;
}

:root.light .edit-option-row input:focus {
  border-color: #C49A00;
}

:root.light .edit-options-section {
  border-top-color: #e0e0e0;
}

:root.light .btn-add-option {
  border-color: #ccc;
  color: #666;
}

:root.light .pin-modal input {
  background: #f5f5f5;
  border-color: #ccc;
  color: #222;
}

:root.light .pin-modal input:focus {
  border-color: #C49A00;
}

:root.light .settings-tab {
  background: #e8e8e8;
  color: #666;
}

:root.light .settings-tab.active {
  background: #A1161A;
  color: #fff;
}

:root.light .settings-tab:hover:not(.active) {
  background: #ddd;
  color: #333;
}

:root.light .settings-item-name {
  color: #222;
}

:root.light .settings-item-price {
  color: #666;
}

:root.light .settings-cat-name {
  color: #A1161A;
  border-bottom-color: #ddd;
}

:root.light .settings-item {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}

:root.light .settings-sort-btn {
  background: #e0e0e0;
  color: #555;
}

:root.light .settings-sort-btn:hover:not(:disabled) {
  background: #C49A00;
  color: #fff;
}

:root.light .settings-edit-btn {
  background: #e0e0e0;
  color: #333;
}

:root.light .settings-edit-btn:hover {
  background: #d0d0d0;
}

:root.light .translate-status {
  color: #666;
}

:root.light .crop-hint {
  color: #666;
}

:root.light .admin-publish-bar {
  background: #fff;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

:root.light .publish-bar-status {
  color: #333;
}

:root.light .settings-section-header {
  color: #555;
}
