/* 重置和基礎樣式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  color: #333;
}

footer {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  padding: 1rem;
  background: linear-gradient(135deg, #06c755 0%, #05b048 100%);
  color: white;
  box-shadow: 0 -2px 10px rgba(6, 199, 85, 0.3);
  position: relative;
  overflow: hidden;
}

footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="75" cy="75" r="1" fill="rgba(255,255,255,0.1)"/><circle cx="50" cy="10" r="0.5" fill="rgba(255,255,255,0.1)"/><circle cx="10" cy="50" r="0.5" fill="rgba(255,255,255,0.1)"/><circle cx="90" cy="50" r="0.5" fill="rgba(255,255,255,0.1)"/><circle cx="50" cy="90" r="0.5" fill="rgba(255,255,255,0.1)"/></pattern></defs><rect width="100" height="100" fill="url(%23grain)"/></svg>');
  opacity: 0.3;
  pointer-events: none;
}

footer > div {
  position: relative;
  z-index: 1;
}

footer a {
  color: white;
  text-decoration: none;
  font-weight: 600;
  font-size: 1.1rem;
  padding: 0.5rem 1rem;
  border-radius: 25px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

footer a:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

footer a i {
  font-size: 1.2rem;
}

/* 工具類 */
.hidden {
  display: none !important;
}

.full-width {
  width: 100%;
}

/* 頂部導航欄 */
.navbar {
  background: #fff;
  padding: 1rem 2rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1000;
}

.navbar-brand {
  display: flex;
  align-items: center;
}

.navbar-brand h1 {
  font-size: 1.5rem;
  font-weight: bold;
  color: #06c755;
}

.navbar-brand i {
  margin-right: 0.5rem;
  font-size: 2rem;
}

.navbar-actions {
  display: flex;
  gap: 0.5rem;
}

/* 搜尋欄 */
.search-bar {
  background: #fff;
  padding: 1rem 2rem;
  border-bottom: 1px solid #e0e0e0;
}

.search-bar input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #06c755;
  border-radius: 25px;
  font-size: 1rem;
  outline: none;
  transition: all 0.3s ease;
}

.search-bar input:focus {
  border-color: #05b048;
  box-shadow: 0 0 0 3px rgba(6, 199, 85, 0.1);
}

/* 主要內容 */
.main-content {
  display: flex;
  min-height: calc(100vh - 80px);
}

/* 側邊欄 */
.sidebar {
  width: 300px;
  background: #fff;
  border-right: 1px solid #e0e0e0;
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 80px);
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-shrink: 0;
}

.sidebar-header h3 {
  color: #333;
  font-size: 1.2rem;
}

.count-badge {
  background: #06c755;
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 12px;
  font-size: 0.8rem;
}

.menu-list {
  margin-top: 1rem;
  flex: 1;
  overflow-y: auto;
}

/* 側邊欄底部iframe容器 */
.sidebar-footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.sidebar-footer iframe {
  width: 100%;
  height: 300px;
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.sidebar-footer iframe:hover {
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  transform: translateY(-2px);
}

/* 空的狀態樣式 */
.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  color: #666;
}

.empty-state i {
  color: #ccc;
  margin-bottom: 1rem;
}

.empty-state p {
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.empty-state small {
  color: #999;
  font-size: 0.9rem;
}

.menu-item {
  border: 2px solid #f0f0f0;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  background: #fff;
}

.menu-item:hover {
  border-color: #06c755;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(6, 199, 85, 0.15);
}

.menu-item.selected {
  border-color: #06c755;
  background: #f8fff9;
}

.menu-item h4 {
  color: #333;
  margin-bottom: 0.5rem;
  font-size: 1rem;
}

.menu-item img {
  width: 100%;
  border-radius: 4px;
  margin-top: 0.5rem;
}

.menu-thumbnail {
  width: 100%;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  border-radius: 4px;
  margin-top: 0.5rem;
  overflow: hidden;
}

.menu-thumbnail canvas {
  max-width: 100%;
  max-height: 100%;
  border-radius: 4px;
}

.thumbnail-placeholder {
  color: #999;
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem;
}

/* 內容區域 */
.content {
  flex: 1;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.95);
  margin: 1rem;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* 歡迎畫面 */
.welcome-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
}

.welcome-content {
  max-width: 500px;
}

.welcome-content i {
  color: #06c755;
  margin-bottom: 1rem;
}

.welcome-content h2 {
  color: #333;
  margin-bottom: 1rem;
  font-size: 2rem;
}

.welcome-content p {
  color: #666;
  margin-bottom: 2rem;
  font-size: 1.1rem;
  line-height: 1.6;
}

/* 未選取選單畫面 */
.no-selection-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
}

.no-selection-content {
  max-width: 500px;
}

.no-selection-content i {
  color: #06c755;
  margin-bottom: 1rem;
}

.no-selection-content h2 {
  color: #333;
  margin-bottom: 1rem;
  font-size: 2rem;
}

.no-selection-content p {
  color: #666;
  margin-bottom: 2rem;
  font-size: 1.1rem;
  line-height: 1.6;
}

.no-selection-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
}

/* 選單詳細資訊 */
.menu-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  height: 100%;
}

.detail-form h3,
.areas-section h3 {
  color: #333;
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  border-bottom: 2px solid #06c755;
  padding-bottom: 0.5rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #555;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #e0e0e0;
  border-radius: 6px;
  font-size: 1rem;
  transition: all 0.3s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #06c755;
  box-shadow: 0 0 0 3px rgba(6, 199, 85, 0.1);
}

.form-group input[readonly] {
  background: #f8f9fa;
  color: #6c757d;
}

/* JSON 匯入選項 */
.import-options {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  margin-top: 0.5rem;
}

.import-options input[type="file"] {
  flex: 1;
  min-width: 200px;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: white;
}

.import-options .btn {
  flex-shrink: 0;
  white-space: nowrap;
  min-width: 100px;
}

.help-text {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: #6c757d;
  font-style: italic;
}

/* 圖片預覽 */
.image-preview {
  border: 2px dashed #e0e0e0;
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-preview canvas {
  max-width: 100%;
  max-height: 300px;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 動作按鈕 */
.action-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 2rem;
}

/* 區域列表 */
.areas-list {
  overflow-y: auto;
}

.area-item {
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.area-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.area-index {
  background: #06c755;
  color: white;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: bold;
}

.area-details {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem;
  font-size: 0.9rem;
  word-break: break-all;
}

.area-detail {
  display: flex;
  flex-direction: column;
}

.area-detail strong {
  color: #555;
  font-size: 0.8rem;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

/* 選單編輯器 */
.menu-editor h3 {
  color: #333;
  margin-bottom: 1.5rem;
  font-size: 1.5rem;
  border-bottom: 2px solid #06c755;
  padding-bottom: 0.5rem;
}

.editor-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.canvas-container {
  border: 2px dashed #e0e0e0;
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f8f9fa;
}

.canvas-container canvas {
  max-width: 100%;
  max-height: 500px;
  border: 2px solid #06c755;
  border-radius: 4px;
  cursor: crosshair;
  box-shadow: 0 4px 12px rgba(6, 199, 85, 0.15);
  background: white;
  transition: all 0.3s ease;
}

.canvas-container canvas:hover {
  box-shadow: 0 6px 20px rgba(6, 199, 85, 0.25);
}

.canvas-container canvas:active {
  cursor: grab;
}

.canvas-container.has-image {
  border-color: #06c755;
  background: white;
}

.area-editor {
  background: #f8f9fa;
  padding: 1.5rem;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}

.area-editor h4 {
  color: #333;
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

.bounds-inputs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.action-inputs {
  margin-bottom: 1rem;
}

.postback-inputs {
  display: grid;
  gap: 0.5rem;
}

.area-actions {
  margin-bottom: 1.5rem;
}

.current-areas {
  border-top: 1px solid #e0e0e0;
  padding-top: 1rem;
}

.current-area {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  transition: all 0.3s ease;
  cursor: pointer;
}

.current-area:hover {
  border-color: #06c755;
  box-shadow: 0 2px 8px rgba(6, 199, 85, 0.1);
  transform: translateY(-2px);
}

.current-area.selected {
  border-color: #06c755;
  background: linear-gradient(145deg, #f8fffa, #fff);
  box-shadow: 0 4px 12px rgba(6, 199, 85, 0.15);
}

.current-area-info {
  font-size: 0.9rem;
  flex: 1;
  cursor: pointer;
}

.current-area-info strong {
  color: #06c755;
  font-size: 1rem;
}

.area-bounds {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.25rem;
  font-family: "Courier New", monospace;
}

.area-actions {
  display: flex;
  gap: 0.5rem;
  margin-left: 1rem;
}

.area-actions .btn {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  min-width: auto;
}

.editor-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  padding-top: 1.5rem;
  border-top: 1px solid #e0e0e0;
}

/* 按鈕樣式 */
.btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  background: none;
}

/* 按鈕內的圖標樣式 */
.btn i,
.btn i.fas,
.btn i.fab,
.btn i.far {
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
  margin-right: 0.25rem;
}

/* 大按鈕的圖標樣式 */
.btn-large i,
.btn-large i.fas,
.btn-large i.fab,
.btn-large i.far {
  font-size: 1.2rem;
  margin-right: 0.5rem;
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: #06c755;
  color: white;
}

.btn-primary:hover {
  background: #05b048;
}

.btn-secondary {
  background: #6c757d;
  color: white;
}

.btn-secondary:hover {
  background: #5a6268;
}

.btn-success {
  background: #28a745;
  color: white;
}

.btn-success:hover {
  background: #218838;
}

.btn-info {
  background: #17a2b8;
  color: white;
}

.btn-info:hover {
  background: #138496;
}

.btn-warning {
  background: #ffc107;
  color: #212529;
}

.btn-warning:hover {
  background: #e0a800;
}

.btn-danger {
  background: #dc3545;
  color: white;
}

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

.btn-large {
  padding: 1rem 2rem;
  font-size: 1.2rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn:disabled:hover {
  transform: none;
  box-shadow: none;
}

/* 模態框 */
.modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
}

.modal.show {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  padding: 1.5rem;
  border-bottom: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  color: #333;
}

.close {
  font-size: 1.5rem;
  font-weight: bold;
  cursor: pointer;
  color: #999;
  transition: color 0.3s ease;
}

.close:hover {
  color: #333;
}

.modal-body {
  padding: 1.5rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* 載入覆蓋層 */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
  backdrop-filter: blur(2px);
}

.loading-spinner {
  text-align: center;
  color: #06c755;
}

.loading-spinner i {
  margin-bottom: 1rem;
}

.loading-spinner p {
  font-size: 1.1rem;
  font-weight: 600;
}

/* 響應式設計 */
@media (max-width: 768px) {
  .navbar {
    padding: 1rem;
    flex-direction: column;
    gap: 1rem;
  }

  .navbar-actions {
    width: 100%;
    justify-content: center;
  }

  .main-content {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    max-height: 300px;
    padding: 1rem;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .sidebar-header {
    flex-shrink: 0;
    margin-bottom: 0;
    margin-right: 1rem;
  }

  .menu-list {
    flex: 1;
    margin-top: 0;
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
  }

  .sidebar-footer {
    margin-top: 0;
    margin-left: 1rem;
    padding-top: 0;
    border-top: none;
    border-left: 1px solid #e0e0e0;
    flex-shrink: 0;
  }

  .sidebar-footer iframe {
    width: 250px;
    height: 200px;
  }

  .menu-detail {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .editor-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

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

  .action-buttons {
    flex-direction: column;
  }

  .modal-content {
    width: 95%;
    margin: 1rem;
  }

  footer {
    flex-direction: column;
    gap: 15px;
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .navbar-brand {
    font-size: 1.2rem;
  }

  .btn {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
  }

  .content {
    padding: 1rem;
    margin: 0.5rem;
  }

  .sidebar {
    padding: 1rem;
    max-height: 250px;
  }

  footer {
    padding: 0.75rem;
    gap: 10px;
  }

  footer a {
    font-size: 1rem;
    padding: 0.4rem 0.8rem;
  }
}

/* 滾動條樣式 */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: #06c755;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #05b048;
}

/* 動畫 */
.fade-in {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.slide-in {
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
