/* ==========================================================================
   P-Files 现代极简轻奢设计系统 (Modern Glassmorphism & Cyber Deep Dark)
   ========================================================================== */

:root {
  --bg-main: #0a0d14;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-hover: rgba(26, 34, 52, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.03);
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-active: rgba(99, 102, 241, 0.5);

  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.25);

  --accent-cyan: #06b6d4;
  --accent-pink: #ec4899;
  --accent-amber: #f59e0b;
  --accent-emerald: #10b981;
  --accent-rose: #f43f5e;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --shadow-glow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --shadow-card: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(236, 72, 153, 0.12) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(6, 182, 212, 0.08) 0px, transparent 60%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
}

/* 滚动条美化 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #475569;
}

/* 基础容器 */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  width: 100%;
}

/* 玻璃拟态卡片 */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}

/* 导航栏 */
.navbar {
  border-bottom: 1px solid var(--border-glass);
  background: rgba(10, 13, 20, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 64px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}
.brand-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), var(--accent-pink));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* 按钮设计 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid transparent;
  outline: none;
  text-decoration: none;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4f46e5);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}
.btn-primary:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--primary-glow);
}
.btn-secondary {
  background: var(--bg-glass);
  border-color: var(--border-glass);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}
.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  border-color: rgba(244, 63, 94, 0.3);
  color: #fda4af;
}
.btn-danger:hover {
  background: rgba(244, 63, 94, 0.3);
}
.btn-sm {
  padding: 4px 10px;
  font-size: 0.8rem;
}
.btn-block {
  width: 100%;
}

/* 表单输入控件 */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 0.95rem;
  transition: var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
textarea.form-control {
  resize: vertical;
}

/* 策略独立多选卡片 (Strategy Switch Grid) */
.strategy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.strategy-card {
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 12px;
  transition: var(--transition);
}
.strategy-card:hover {
  border-color: rgba(255, 255, 255, 0.15);
}
.strategy-card.active {
  border-color: var(--border-active);
  background: rgba(99, 102, 241, 0.06);
}
.strategy-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.strategy-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
}
.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #334155;
  transition: .3s;
  border-radius: 20px;
}
.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .3s;
  border-radius: 50%;
}
input:checked + .slider {
  background-color: var(--primary);
}
input:checked + .slider:before {
  transform: translateX(18px);
}

/* 拖拽上传区域 */
.dropzone {
  border: 2px dashed rgba(99, 102, 241, 0.4);
  border-radius: var(--radius-lg);
  padding: 36px 20px;
  text-align: center;
  background: rgba(99, 102, 241, 0.02);
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.08);
}
.dropzone-icon {
  font-size: 2.5rem;
  margin-bottom: 8px;
}

/* 状态标签 Badge */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.2;
}
.badge-success { background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-danger { background: rgba(244, 63, 94, 0.15); color: #fda4af; border: 1px solid rgba(244, 63, 94, 0.3); }
.badge-info { background: rgba(6, 182, 212, 0.15); color: #38bdf8; border: 1px solid rgba(6, 182, 212, 0.3); }
.badge-gray { background: rgba(148, 163, 184, 0.1); color: #94a3b8; border: 1px solid rgba(148, 163, 184, 0.2); }

/* 表格组件 */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.data-table {
  width: 100%;
  min-width: 780px; /* 保护表格在小屏幕下不被强行压扁，可横向平滑滚动 */
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}
.data-table th {
  padding: 14px 12px;
  color: var(--text-dim);
  font-weight: 600;
  border-bottom: 1px solid var(--border-glass);
  white-space: nowrap;
}
.data-table td {
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  vertical-align: middle;
  white-space: nowrap;
}
.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* 第一列 (提取码与文件名) 宽度限制与防溢出 */
.data-table th:first-child,
.data-table td:first-child {
  max-width: 320px;
  width: 320px;
  overflow: hidden;
}

.file-name-container {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 300px;
  min-width: 0;
  overflow: hidden;
}
.file-name-text {
  font-weight: 600;
  color: #fff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

/* 文件名智能截断 (保留完整后缀) */
.filename-truncate-box {
  display: inline-flex;
  align-items: baseline;
  max-width: 230px;
  min-width: 0;
  overflow: hidden;
  vertical-align: middle;
  cursor: default;
  transition: var(--transition);
}
.filename-truncate-box:hover .filename-stem {
  color: var(--accent-cyan);
}
.filename-stem {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex-shrink: 1;
  font-weight: 600;
  color: #fff;
  transition: color 0.15s ease;
}
.filename-ext {
  flex-shrink: 0;
  color: #a5b4fc;
  font-family: monospace;
  font-weight: 700;
  font-size: 0.88rem;
  margin-left: 1px;
}

/* 版本号徽章 */
.version-badge {
  font-family: monospace;
  font-size: 0.72rem;
  font-weight: 700;
  color: #a5b4fc;
  background: rgba(99, 102, 241, 0.16);
  border: 1px solid rgba(99, 102, 241, 0.35);
  padding: 2px 7px;
  border-radius: 6px;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
}

/* 模态框 Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}
.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 680px;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-glow);
  transform: translateY(20px);
  transition: var(--transition);
}
.modal-overlay.active .modal-box {
  transform: translateY(0);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
}

/* 提取页单页卡片设计 */
.hero-box {
  width: 100%;
  max-width: 520px;
  margin: 60px auto;
  padding: 36px 28px;
  text-align: center;
  box-sizing: border-box;
}

.code-input-display {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  font-size: 2rem;
  letter-spacing: 6px;
  font-weight: 800;
  text-align: center;
  text-transform: uppercase;
  color: #fff;
  background: rgba(15, 23, 42, 0.8);
  border: 2px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: 14px 10px;
  margin: 20px 0;
  display: block;
  outline: none;
  transition: var(--transition);
}
.code-input-display:focus {
  border-color: var(--primary);
  box-shadow: 0 0 20px var(--primary-glow);
}

/* 提示通知 Toast */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 90vw;
}
.toast {
  background: #1e293b;
  border: 1px solid var(--border-glass);
  border-left: 4px solid var(--primary);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  font-size: 0.9rem;
  animation: slideIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ==========================================================================
   📱 移动端与小屏幕自适应 (Responsive Design for Mobile)
   ========================================================================== */

@media (max-width: 768px) {
  .container {
    padding: 0 12px;
  }
  
  .navbar .nav-content {
    height: auto;
    padding: 10px 0;
    flex-wrap: wrap;
    gap: 8px;
  }
  .brand {
    font-size: 1.1rem;
  }
  .nav-actions {
    gap: 6px;
  }
  .nav-actions .btn {
    padding: 5px 10px;
    font-size: 0.8rem;
  }

  .hero-box {
    margin: 24px auto;
    padding: 24px 16px;
    border-radius: var(--radius-md);
  }
  
  .code-input-display {
    font-size: 1.5rem;
    letter-spacing: 4px;
    padding: 12px 6px;
    margin: 16px 0;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    margin: 16px 0 !important;
  }
  .stat-card {
    padding: 12px 14px !important;
    gap: 10px !important;
  }
  .stat-icon {
    width: 38px !important;
    height: 38px !important;
    font-size: 1.5rem !important;
  }
  .stat-num {
    font-size: 1.3rem !important;
  }
  .stat-label {
    font-size: 0.72rem !important;
  }

  .strategy-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .dropzone {
    padding: 24px 14px;
  }
  .dropzone-icon {
    font-size: 2rem;
  }

  .data-table th, .data-table td {
    padding: 10px 8px;
    font-size: 0.82rem;
  }

  .search-toolbar {
    width: 100% !important;
    margin-top: 8px;
  }
  .search-toolbar input {
    flex: 1 1 140px !important;
    width: auto !important;
  }

  .modal-box {
    width: 95%;
    max-height: 90vh;
  }
  
  #toast-container {
    bottom: 16px;
    right: 16px;
    left: 16px;
  }
}

@media (max-width: 420px) {
  .stats-grid {
    grid-template-columns: 1fr !important;
  }
  .code-input-display {
    font-size: 1.3rem;
    letter-spacing: 2px;
  }
}
