/* ==========================================================================
   Lightweight Specification Grid Table System (Modern Clean Theme)
   ========================================================================== */

:root {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --border-light: #e2e8f0;
  --border-strong: #cbd5e1;
  --border-module: #64748b;
  
  --accent-blue: #2563eb;
  --accent-blue-hover: #1d4ed8;
  --accent-light: #eff6ff;
  
  --chip-bg: #f1f5f9;
  --chip-text: #475569;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.app-header {
  height: 60px;
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent-blue);
  color: white;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}

.logo-text h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.header-status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: #16a34a;
  background: #f0fdf4;
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid #bbf7d0;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

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

/* Main Layout */
.app-main {
  max-width: 1400px;
  margin: 20px auto;
  padding: 0 16px;
}

.spec-table-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* Toolbar */
.table-toolbar {
  padding: 16px 20px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.select-control {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  background-color: var(--bg-card);
  color: var(--text-primary);
  font-size: 0.9rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: all 0.2s;
}

.select-control:hover {
  border-color: var(--accent-blue);
}

.select-control:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Buttons */
.btn {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.btn-primary {
  background-color: var(--accent-blue);
  color: white;
}

.btn-primary:hover {
  background-color: var(--accent-blue-hover);
}

.btn-secondary {
  background-color: var(--bg-card);
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background-color: var(--bg-subtle);
  color: var(--text-primary);
}

/* Pure Matrix Spec Table */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.pure-spec-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: left;
}

.pure-spec-table th {
  background-color: #f8fafc;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  white-space: nowrap;
}

.pure-spec-table th:last-child {
  border-right: none;
}

.pure-spec-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
  border-right: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
}

.pure-spec-table td:last-child {
  border-right: none;
}

/* Distinct Module Rows */
.module-cell {
  background-color: #f8fafc;
  font-weight: 700;
  color: var(--accent-blue);
  text-align: center;
  vertical-align: middle;
  border-right: 1px solid var(--border-strong) !important;
}

.module-first-row td {
  border-top: 2px solid var(--border-module) !important;
}

.param-name-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.param-label {
  font-weight: 500;
  color: var(--text-primary);
}

.param-key-chip {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  background-color: var(--chip-bg);
  color: var(--chip-text);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #e2e8f0;
}

.val-cell {
  font-weight: 600;
  color: #0f172a;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  background: white;
  width: 700px;
  max-width: 90vw;
  max-height: 85vh;
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  background: #0f172a;
}

.json-code {
  color: #38bdf8;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  white-space: pre-wrap;
  word-break: break-all;
}

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ==========================================================================
   H5 Mobile Responsive Adaptation (移动端/手机端 适配)
   ========================================================================== */
@media (max-width: 768px) {
  .app-header {
    height: auto;
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 16px;
    gap: 10px;
  }

  .logo-text h2 {
    font-size: 1rem;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .header-actions .btn {
    flex: 1;
    justify-content: center;
    font-size: 0.8rem;
    padding: 6px 10px;
  }

  .app-main {
    margin: 10px auto;
    padding: 0 8px;
  }

  .table-toolbar {
    padding: 12px;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .toolbar-controls {
    flex-direction: column;
    width: 100%;
    gap: 8px;
  }

  .select-control {
    width: 100%;
    font-size: 0.85rem;
    padding: 8px 10px;
  }

  .pure-spec-table {
    font-size: 0.8rem;
    min-width: 650px; /* Ensure table scrolls horizontally on small screens */
  }

  .pure-spec-table th,
  .pure-spec-table td {
    padding: 8px 10px;
  }

  .param-name-cell {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .param-key-chip {
    font-size: 0.7rem;
    padding: 1px 4px;
  }
}
