/* =========================================
   首页样式 - Index Page Styles
   ========================================= */

/* 控制面板 */
.control-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-radius: 18px;
  margin-bottom: 30px;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(12px);
  position: relative;
  z-index: 1000;
}

/* 搜索表单 */
.search-form {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 240px;
  position: relative;
}

.search-wrapper {
  position: relative;
  flex: 1;
  z-index: 10001;
}

.search-field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.15);
}

.search-field input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 15px;
  color: #333;
}

.search-field input::placeholder {
  color: #999;
  font-size: 14px;
}

.search-field input:disabled {
  cursor: not-allowed;
}

.search-field input:focus {
  outline: none;
}

.search-icon {
  font-size: 16px;
  color: #667eea;
}

.search-loading {
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-spinner {
  font-size: 16px;
  color: #667eea;
  animation: spin 1s linear infinite;
}

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

/* 搜索历史 */
.search-history {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
  z-index: 2147483647;
  max-height: 300px;
  overflow: hidden;
  margin-top: 4px;
}

.search-history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid #eee;
  font-size: 14px;
  font-weight: 600;
  color: #666;
}

.clear-history-btn {
  background: none;
  border: none;
  color: #999;
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.clear-history-btn:hover {
  background: #f5f5f5;
  color: #666;
}

.search-history-list {
  max-height: 240px;
  overflow-y: auto;
}

.search-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.2s ease;
  font-size: 14px;
  color: #333;
}

.search-history-item:hover,
.search-history-item.selected {
  background: #f8f9fa;
}

.search-history-item .search-term {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-history-item .remove-item {
  color: #999;
  font-size: 12px;
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 3px;
  opacity: 0;
  transition: all 0.2s ease;
}

.search-history-item:hover .remove-item {
  opacity: 1;
}

.search-history-item .remove-item:hover {
  background: #eee;
  color: #666;
}

.search-history-empty {
  padding: 16px;
  text-align: center;
  color: #999;
  font-size: 14px;
}

/* 搜索/清除按钮 */
.btn-search,
.btn-clear {
  border: none;
  border-radius: 12px;
  padding: 10px 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 14px;
}

.btn-search {
  background: #ffffff;
  color: #667eea;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.25);
}

.btn-search:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(102, 126, 234, 0.35);
}

.btn-clear {
  background: transparent;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.btn-clear:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* 视图控制 */
.view-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
}

.toggle-group {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  gap: 4px;
}

.toggle-btn {
  border: none;
  padding: 8px 16px;
  border-radius: 999px;
  background: transparent;
  color: white;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toggle-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.toggle-btn.is-active {
  background: white;
  color: #667eea;
  font-weight: 600;
  box-shadow: 0 6px 14px rgba(102, 126, 234, 0.25);
}

.size-group .toggle-btn {
  min-width: 48px;
  text-align: center;
}

/* 搜索反馈 */
.search-feedback {
  margin-bottom: 20px;
  color: white;
  line-height: 1.6;
}

.search-feedback strong {
  font-size: 18px;
}

.search-feedback__tip {
  font-size: 14px;
  opacity: 0.9;
}

.link-reset {
  color: white;
  font-weight: 600;
  text-decoration: underline;
}

/* 应用网格 */
.apps-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 24px;
  margin-bottom: 40px;
  transition: all 0.25s ease;
}

.apps-grid[data-size="large"] {
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}

.apps-grid[data-size="medium"] {
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}

.apps-grid[data-size="small"] {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

.apps-grid[data-view="list"] {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* 应用卡片 */
.app-card {
  background: white;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.app-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.app-preview {
  position: relative;
  height: 200px;
  overflow: hidden;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
}

.apps-grid[data-size="large"] .app-preview {
  height: 260px;
}

.apps-grid[data-size="small"] .app-preview {
  height: 150px;
}

.app-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.app-preview:hover img {
  transform: scale(1.05);
}

.app-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.app-card:hover .app-overlay {
  opacity: 1;
}

.btn-view {
  background: white;
  color: #667eea;
  padding: 10px 25px;
  border-radius: 20px;
  text-decoration: none;
  font-weight: 600;
  transition: transform 0.2s ease;
}

.btn-view:hover {
  transform: scale(1.1);
}

.app-info {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.app-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-name {
  font-size: 20px;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-author {
  font-size: 14px;
  color: #667eea;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(102, 126, 234, 0.12);
  flex-shrink: 0;
}

.app-author.is-placeholder {
  color: #999;
  background: rgba(0, 0, 0, 0.05);
}

.app-description {
  font-size: 14px;
  color: #666;
  line-height: 1.6;
  margin-bottom: 12px;
  height: 67.2px; /* 3行固定高度: 14px * 1.6 * 3 */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-description p,
.app-description ul,
.app-description ol {
  margin: 0 0 8px 0;
}

.app-description ul,
.app-description ol {
  padding-left: 18px;
}

.app-description li {
  margin-bottom: 4px;
}

.app-description p:last-child,
.app-description ul:last-child,
.app-description ol:last-child {
  margin-bottom: 0;
}

.app-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: #888;
}

.app-meta-left {
  display: flex;
  align-items: center;
  gap: 6px;
}

.app-meta-separator {
  color: #ccc;
}

.app-meta-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.app-action-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: #f5f5f5;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.app-action-btn:hover {
  background: #e8e8e8;
}

.app-action-btn img {
  width: 14px;
  height: 14px;
}

.app-views {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: #888;
}

.app-views-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.apps-grid[data-view="list"] .app-meta {
  justify-content: flex-start;
  gap: 24px;
}

.app-actions--admin {
  margin-top: 12px;
}

.app-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
}

.btn-delete {
  flex: 1;
  padding: 8px 16px;
  background: #fee;
  border: 1px solid #fcc;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #c33;
  transition: all 0.2s ease;
}

.btn-delete:hover {
  background: #fdd;
  border-color: #f99;
}

.btn-regenerate {
  flex: 1;
  padding: 8px 16px;
  background: #e3f2fd;
  border: 1px solid #90caf9;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: #1976d2;
  transition: all 0.2s ease;
}

.btn-regenerate:hover {
  background: #bbdefb;
  border-color: #42a5f5;
}

.btn-regenerate:disabled {
  background: #f5f5f5;
  border-color: #e0e0e0;
  color: #999;
  cursor: not-allowed;
}

.btn-manage {
  display: inline-block;
  padding: 6px 12px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: white;
  text-decoration: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
}

.btn-manage:hover {
  background: linear-gradient(135deg, #5a6fd8, #6a4190);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

/* 列表视图样式 */
.apps-grid[data-view="list"] .app-card {
  flex-direction: row;
}

.apps-grid[data-view="list"] .app-preview {
  width: 320px;
  height: auto;
  min-height: 180px;
  flex-shrink: 0;
}

.apps-grid[data-view="list"] .app-preview img {
  height: 100%;
}

.apps-grid[data-view="list"] .app-info {
  padding: 24px;
}

.apps-grid[data-view="list"] .app-description {
  max-height: 150px;
}

.apps-grid[data-view="list"] .app-description:hover {
  padding-bottom: 40px;
}

.apps-grid[data-view="list"] .app-actions {
  justify-content: flex-start;
  max-width: 360px;
}

/* 列表视图 - 大尺寸 */
.apps-grid[data-view="list"][data-size="large"] .app-preview {
  width: 420px;
  min-height: 240px;
}

.apps-grid[data-view="list"][data-size="large"] .app-info {
  padding: 28px 32px;
}

.apps-grid[data-view="list"][data-size="large"] .app-name {
  font-size: 24px;
}

.apps-grid[data-view="list"][data-size="large"] .app-description {
  font-size: 15px;
  max-height: 180px;
}

/* 列表视图 - 中尺寸 (默认) */
.apps-grid[data-view="list"][data-size="medium"] .app-preview {
  width: 320px;
  min-height: 180px;
}

/* 列表视图 - 小尺寸 */
.apps-grid[data-view="list"][data-size="small"] .app-preview {
  width: 220px;
  min-height: 130px;
}

.apps-grid[data-view="list"][data-size="small"] .app-info {
  padding: 16px 20px;
}

.apps-grid[data-view="list"][data-size="small"] .app-name {
  font-size: 16px;
}

.apps-grid[data-view="list"][data-size="small"] .app-description {
  font-size: 13px;
  max-height: 100px;
  -webkit-line-clamp: 2;
}

/* 应用详情浮窗 */
.modal-app-preview {
  width: 100%;
  height: 300px;
  overflow: hidden;
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  border-radius: 20px 20px 0 0;
}

.modal-app-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.modal-app-info {
  padding: 32px;
}

.modal-app-name {
  font-size: 28px;
  color: #333;
  margin-bottom: 12px;
  line-height: 1.3;
}

.modal-app-author {
  margin-bottom: 20px;
}

.modal-app-description {
  font-size: 16px;
  color: #666;
  line-height: 1.8;
  margin-bottom: 24px;
  padding: 20px;
  background: #f9f9f9;
  border-radius: 12px;
  border-left: 4px solid #667eea;
}

.modal-app-description p,
.modal-app-description ul,
.modal-app-description ol {
  margin: 0 0 12px 0;
}

.modal-app-description ul,
.modal-app-description ol {
  padding-left: 24px;
}

.modal-app-description li {
  margin-bottom: 6px;
}

.modal-app-description p:last-child,
.modal-app-description ul:last-child,
.modal-app-description ol:last-child {
  margin-bottom: 0;
}

.modal-app-meta {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: #999;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid #eee;
}

.modal-app-actions {
  display: flex;
  gap: 12px;
}

.modal-app-actions .btn-primary,
.modal-app-actions .btn-secondary {
  flex: 1;
  text-align: center;
  text-decoration: none;
}

/* 响应式设计 - 首页 */
@media (max-width: 768px) {
  .control-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .search-form {
    width: 100%;
  }

  .view-controls {
    width: 100%;
    justify-content: space-between;
  }

  .apps-grid[data-view="list"] .app-card {
    flex-direction: column;
  }

  .apps-grid[data-view="list"] .app-preview {
    width: 100%;
  }

  .apps-grid[data-view="list"] .app-actions {
    width: 100%;
  }

  .apps-grid {
    grid-template-columns: 1fr;
  }

  .app-description-hint {
    font-size: 11px;
    padding: 5px 10px;
    gap: 4px;
  }

  .hint-icon {
    font-size: 12px;
  }

  .app-description:hover {
    padding-bottom: 36px;
  }

  .modal-app-preview {
    height: 200px;
  }

  .modal-app-info {
    padding: 24px 20px;
  }

  .modal-app-name {
    font-size: 24px;
  }

  .modal-app-description {
    font-size: 14px;
    padding: 16px;
  }

  .modal-app-actions {
    flex-direction: column;
  }

  .modal-app-actions .btn-primary,
  .modal-app-actions .btn-secondary {
    width: 100%;
  }
}
.btn-view-app {
  flex: 1;
  padding: 8px 16px;
  background: #f5f5f5;
  color: white;
  text-decoration: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  text-align: center;
  transition: background 0.2s ease;
}

.btn-view-app:hover {
  background: #0056b3;
}

