/* ========== PRM 品牌色 ========== */
:root {
  --prm-primary: #009499;
  --prm-primary-dark: #00787d;
  --prm-primary-light: #e0f2f2;
  --prm-primary-hover: #00a8ad;
  --prm-text: #2d3748;
  --prm-muted: #6b7280;
  --prm-border: #e4e7ec;
  --prm-bg: #f5f7f8;
  --prm-danger: #e53e3e;
}

body {
  background: var(--prm-bg);
  color: var(--prm-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
    "Microsoft JhengHei", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ========== Header / Brand ========== */
.prm-header {
  background: #fff;
  border-bottom: 1px solid var(--prm-border);
  padding: 0.75rem 0;
  margin-bottom: 1.5rem;
}
.prm-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.prm-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--prm-primary);
}
.prm-logo-img {
  width: 40px;
  height: 40px;
}
.prm-logo-text {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: 0.02em;
  color: var(--prm-primary);
  line-height: 1;
}
.prm-logo-text small {
  display: block;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--prm-muted);
  letter-spacing: 0;
  margin-top: 2px;
}
.prm-meta {
  font-size: 0.85rem;
  color: var(--prm-muted);
  text-align: right;
}
.prm-meta strong {
  color: var(--prm-text);
}

/* 標題 banner（仿 PRM 官網風格） */
.prm-title-bar {
  color: var(--prm-primary);
  font-weight: 700;
  font-size: 1.5rem;
  padding-bottom: 0.5rem;
  margin-bottom: 0.75rem;
  border-bottom: 2px solid var(--prm-primary-light);
}
.prm-subtitle-bar {
  background: var(--prm-primary);
  color: #fff;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  font-weight: 500;
}

/* ========== 卡片 ========== */
.card {
  border: 1px solid var(--prm-border);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}
.card-title {
  color: var(--prm-primary-dark);
  font-weight: 700;
}
.section-title {
  color: var(--prm-primary);
  font-weight: 700;
  font-size: 1.1rem;
  margin: 0 0 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--prm-border);
}

/* ========== 表單 ========== */
.form-label {
  font-weight: 600;
  color: var(--prm-text);
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
}
.form-control, .form-select {
  border-color: var(--prm-border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
}
.form-control:focus, .form-select:focus {
  border-color: var(--prm-primary);
  box-shadow: 0 0 0 0.2rem rgba(0, 148, 153, 0.2);
}
.required-mark {
  color: var(--prm-danger);
  margin-left: 2px;
}

/* ========== 按鈕 ========== */
.btn-primary {
  background: var(--prm-primary);
  border-color: var(--prm-primary);
  font-weight: 600;
  padding: 0.5rem 1.25rem;
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--prm-primary-hover);
  border-color: var(--prm-primary-hover);
}
.btn-primary:active {
  background: var(--prm-primary-dark) !important;
  border-color: var(--prm-primary-dark) !important;
}
.btn-outline-primary {
  color: var(--prm-primary);
  border-color: var(--prm-primary);
}
.btn-outline-primary:hover {
  background: var(--prm-primary);
  border-color: var(--prm-primary);
}

/* Bootstrap radio/check tint */
.form-check-input:checked {
  background-color: var(--prm-primary);
  border-color: var(--prm-primary);
}
.form-check-input:focus {
  border-color: var(--prm-primary);
  box-shadow: 0 0 0 0.2rem rgba(0, 148, 153, 0.2);
}

/* ========== 名片上傳區 ========== */
.scan-card {
  border: 1px solid var(--prm-border);
}
.dropzone {
  position: relative;
  border: 2px dashed var(--prm-primary-light);
  border-radius: 10px;
  padding: 2rem 1rem;
  text-align: center;
  transition: all 0.15s;
  cursor: pointer;
  background: #fafcfc;
}
.dropzone:hover,
.dropzone.dragover {
  border-color: var(--prm-primary);
  background: var(--prm-primary-light);
}
.dropzone-icon {
  font-size: 2.5rem;
  line-height: 1;
  color: var(--prm-primary);
}
.dropzone-text {
  margin-top: 0.5rem;
  color: var(--prm-muted);
}
.dropzone-text strong {
  color: var(--prm-text);
}

.dropzone-preview {
  position: relative;
  display: inline-block;
  max-width: 100%;
}
.dropzone-preview img {
  max-width: 100%;
  max-height: 280px;
  border-radius: 8px;
  display: block;
  margin: 0 auto;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}
.preview-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  border-radius: 8px;
  color: #fff;
}

/* ========== OCR 填入動畫 ========== */
@keyframes fillHighlight {
  0% {
    background-color: var(--prm-primary-light);
    border-color: var(--prm-primary);
  }
  100% {
    background-color: #fff;
    border-color: var(--prm-border);
  }
}
.filled-by-ocr {
  animation: fillHighlight 2.5s ease-out;
}

/* ========== 產品類別 ========== */
.category-group {
  border: 1px solid var(--prm-border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  background: #fff;
  transition: border-color 0.15s;
}
.category-group:hover {
  border-color: var(--prm-primary);
}
.category-group-title {
  font-weight: 700;
  color: var(--prm-primary-dark);
  cursor: pointer;
  user-select: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.category-group-title small {
  font-weight: 400;
  margin-left: 0.3rem;
}
.category-group-title .toggle-icon {
  color: var(--prm-primary);
  transition: transform 0.2s;
  font-size: 0.8rem;
}
.category-group.collapsed .toggle-icon {
  transform: rotate(-90deg);
}
.category-group.collapsed .category-items {
  display: none;
}
.category-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.4rem;
  margin-top: 0.75rem;
}

/* ========== OCR 辨識結果 badge ========== */
.badge-confidence-high {
  background: #10b981;
  color: #fff;
}
.badge-confidence-medium {
  background: #f59e0b;
  color: #000;
}
.badge-confidence-low {
  background: #ef4444;
  color: #fff;
}

.alert-success {
  background: var(--prm-primary-light);
  border-color: var(--prm-primary);
  color: var(--prm-primary-dark);
}

/* ========== Footer ========== */
.prm-footer {
  text-align: center;
  color: var(--prm-muted);
  font-size: 0.85rem;
  padding: 2rem 0 1rem;
}
.prm-footer a {
  color: var(--prm-primary);
  text-decoration: none;
}
.prm-footer a:hover {
  text-decoration: underline;
}

/* ========== RWD ========== */
@media (max-width: 576px) {
  .prm-title-bar {
    font-size: 1.25rem;
  }
  .prm-logo-text {
    font-size: 1.1rem;
  }
  .prm-meta {
    font-size: 0.75rem;
  }
  .dropzone {
    padding: 1.25rem 0.75rem;
  }
}
