/* ============================================================
   STYLE.CSS — Thiệt Chẩn YHCT (Giao diện đơn giản & chuẩn giáo trình)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Noto+Serif:ital,wght@0,400;0,600;0,700;1,400&display=swap');

:root {
  --bg-app: #f7f9fa;
  --bg-card: #ffffff;
  --text-main: #1f2937;
  --text-muted: #6b7280;
  --text-dark: #111827;
  
  --primary: #9b2c2c;
  --primary-hover: #7b1d1d;
  --primary-light: #fff5f5;
  --primary-border: #fed7d7;
  
  --border-color: #e2e8f0;
  --border-subtle: #edf2f7;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
  --shadow-card: 0 4px 20px rgba(0,0,0,0.08);
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
}

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

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-app);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 16px 48px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ================= HEADER ================= */
.app-header {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 28px;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: #fff;
  font-family: 'Noto Serif', serif;
  font-size: 22px;
  font-weight: 700;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(155, 44, 44, 0.25);
}

.brand-info h1 {
  font-size: 19px;
  font-weight: 700;
  color: var(--text-dark);
  letter-spacing: -0.3px;
}

.brand-info p {
  font-size: 13px;
  color: var(--text-muted);
}

/* ================= BUTTONS ================= */
.btn-secondary {
  background: #fff;
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--bg-app);
  border-color: #cbd5e0;
}

/* ================= UPLOAD SECTION ================= */
.upload-section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.upload-box {
  background: var(--bg-card);
  border: 2px dashed #cbd5e0;
  border-radius: var(--radius-lg);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s ease;
  position: relative;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}

.upload-box:hover, .upload-box.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.upload-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.upload-icon {
  font-size: 42px;
  line-height: 1;
}

.upload-placeholder h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dark);
}

.upload-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.btn-select {
  margin-top: 6px;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  padding: 7px 18px;
  border-radius: 30px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-select:hover {
  background: var(--primary);
  color: #fff;
}

/* ================= PREVIEW CONTAINER ================= */
.preview-container {
  position: relative;
  max-width: 100%;
  max-height: 320px;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.preview-container img {
  max-width: 100%;
  max-height: 320px;
  object-fit: contain;
  display: block;
  background: #111;
  border-radius: var(--radius-md);
}

.btn-remove-img {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.btn-remove-img:hover {
  background: var(--primary);
}

/* ================= ACTION BAR ================= */
.action-bar {
  display: flex;
  justify-content: center;
}

.btn-analyze {
  width: 100%;
  max-width: 320px;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 13px 28px;
  border-radius: 30px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(155, 44, 44, 0.3);
  transition: all 0.2s ease;
}

.btn-analyze:hover:not(:disabled) {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(155, 44, 44, 0.4);
}

.btn-analyze:disabled {
  background: #cbd5e0;
  color: #a0aec0;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ================= STATUS MESSAGE ================= */
.status-message {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  text-align: center;
}

.status-message.info {
  background: #ebf8ff;
  color: #2b6cb0;
  border: 1px solid #bee3f8;
}

.status-message.error {
  background: #fff5f5;
  color: #c53030;
  border: 1px solid #fed7d7;
}

.status-message.success {
  background: #f0fff4;
  color: #276749;
  border: 1px solid #c6f6d5;
}

/* ================= RESULT SECTION (TEXTBOOK STYLE) ================= */
.result-section {
  margin-top: 32px;
  animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.textbook-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 36px 40px;
  box-shadow: var(--shadow-card);
  font-family: 'Noto Serif', serif;
  color: #1a202c;
  max-width: 660px;
  margin: 0 auto;
}

/* Tiêu đề thiệt đồ */
.card-header {
  margin-bottom: 22px;
  text-align: left;
}

.tongue-title {
  font-size: 20px;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.2px;
  line-height: 1.4;
}

/* Ảnh ở giữa */
.card-image-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
  background: #fafafa;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.card-image-wrapper img {
  max-width: 100%;
  max-height: 360px;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Nội dung văn bản giáo trình */
.card-body {
  font-size: 16px;
  line-height: 1.8;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.block-section {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.section-heading {
  font-size: 17px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 2px;
}

.detail-list {
  list-style: none;
  padding-left: 20px;
}

.detail-list li {
  position: relative;
  padding-left: 14px;
  margin-bottom: 4px;
  color: #2d3748;
}

.detail-list li .bullet {
  position: absolute;
  left: 0;
  color: #4a5568;
}

.detail-list strong {
  font-weight: 600;
  color: #1a202c;
}

/* Khối Ý nghĩa lâm sàng */
.clinical-meaning-box {
  margin-top: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
  font-size: 16.5px;
  line-height: 1.7;
}

.meaning-label {
  font-weight: 700;
  color: #111827;
  margin-right: 4px;
}

.meaning-content {
  color: #2d3748;
}

/* Card footer buttons */
.card-footer {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  font-family: 'Inter', sans-serif;
}

/* ================= FOOTER ================= */
.app-footer {
  margin-top: auto;
  padding-top: 40px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.hidden {
  display: none !important;
}

/* Responsive */
@media (max-width: 640px) {
  .app-container {
    padding: 16px 12px 32px;
  }
  .textbook-card {
    padding: 24px 18px;
  }
  .tongue-title {
    font-size: 18px;
  }
  .card-body {
    font-size: 15px;
  }
}
