/* ==========================================================================
   TEACHABLE MACHINE CLONE - PHONG CÁCH TỐI GIẢN CHUẨN GOOGLE
   ========================================================================== */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #f1f3f4;
  color: #202124;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  touch-action: manipulation;
}

/* Header */
.navbar {
  height: 56px;
  background: #ffffff;
  border-bottom: 1px solid #dadce0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: 0 1px 2px rgba(60, 64, 67, 0.1);
}

.btn-nav-switch {
  background: #e8f0fe;
  color: #1a73e8;
  border: 1px solid #d2e3fc;
  border-radius: 6px;
  padding: 7px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s;
}

.btn-nav-switch:hover {
  background: #d2e3fc;
}

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

.brand-badge {
  background: #1a73e8;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 4px 8px;
  border-radius: 6px;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: #202124;
}

.project-tag {
  font-size: 0.85rem;
  color: #5f6368;
  background: #e8f0fe;
  padding: 3px 10px;
  border-radius: 12px;
}

/* Workspace 3 Cột */
.workspace-grid {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  flex: 1;
}

/* Mũi tên kết nối các bước */
.flow-arrow {
  color: #dadce0;
  font-size: 1.8rem;
  margin-top: 100px;
  user-select: none;
}

/* Thẻ chung chuẩn Teachable Machine */
.tm-card {
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.15);
  overflow: hidden;
  margin-bottom: 16px;
}

.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid #e8eaed;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #3c4043;
}

.card-body {
  padding: 16px;
}

/* CỘT 1: CÁC LỚP (CLASSES) */
.column-classes {
  flex: 1.3;
  min-width: 320px;
  max-width: 460px;
}

.class-card {
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(60, 64, 67, 0.15);
  margin-bottom: 16px;
  overflow: hidden;
  border-left: 6px solid var(--accent-color, #1a73e8);
}

.class-header {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f1f3f4;
}

.class-name-input {
  font-size: 1rem;
  font-weight: 600;
  color: #202124;
  border: 1px solid transparent;
  padding: 4px 8px;
  border-radius: 4px;
  outline: none;
  background: transparent;
}

.class-name-input:focus {
  background: #f8f9fa;
  border-color: #1a73e8;
}

.btn-delete-class {
  background: transparent;
  border: none;
  color: #5f6368;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
  border-radius: 4px;
}

.btn-delete-class:hover {
  background: #fce8e6;
  color: #d93025;
}

.class-content {
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Nút Mở Webcam trong thẻ lớp khi đang tắt */
.btn-open-cam {
  width: 100%;
  background: #ffffff;
  border: 1px solid #dadce0;
  border-radius: 8px;
  padding: 16px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1a73e8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.15s;
}

.btn-open-cam:hover {
  background: #f8f9fa;
  border-color: #1a73e8;
}

/* Khung Camera trực tiếp khi mở ô lấy mẫu */
.class-webcam-box {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #202124;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #dadce0;
  transform: translateZ(0);
  will-change: transform;
}

.class-canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: translateZ(0);
}

.class-cam-top-bar {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.class-cam-label {
  background: rgba(0, 0, 0, 0.65);
  color: #ffffff;
  font-size: 0.725rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
}

.class-cam-btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-card-switch-cam {
  background: rgba(0, 0, 0, 0.65);
  color: #ffffff;
  border: none;
  font-size: 0.725rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background 0.15s;
}

.btn-card-switch-cam:hover {
  background: rgba(26, 115, 232, 0.85);
}

.btn-close-cam {
  background: rgba(0, 0, 0, 0.65);
  color: #ffffff;
  border: none;
  font-size: 0.725rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-close-cam:hover {
  background: rgba(217, 48, 37, 0.85);
}

.sample-count-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: #5f6368;
}

/* Hàng Gallery ảnh mẫu đã chụp */
.sample-gallery {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0;
  min-height: 44px;
  align-items: center;
}

.sample-gallery::-webkit-scrollbar {
  height: 5px;
}

.sample-gallery::-webkit-scrollbar-thumb {
  background: #dadce0;
  border-radius: 3px;
}

.sample-thumb {
  width: 52px;
  height: 39px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid #dadce0;
  flex-shrink: 0;
}

.empty-gallery-hint {
  font-size: 0.75rem;
  color: #9aa0a6;
  font-style: italic;
}

/* Nút Bấm Giữ Để Ghi Mẫu */
.btn-hold-record {
  width: 100%;
  background: #1a73e8;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 13px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, transform 0.1s;
  min-height: 48px;
}

.btn-hold-record:hover {
  background: #1557b0;
}

.btn-hold-record.recording {
  background: #d93025 !important;
  transform: scale(0.98);
}

.btn-add-class {
  width: 100%;
  background: #ffffff;
  border: 1px dashed #dadce0;
  border-radius: 8px;
  padding: 14px;
  font-size: 0.95rem;
  font-weight: 600;
  color: #1a73e8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-add-class:hover {
  background: #e8f0fe;
  border-color: #1a73e8;
}

/* CỘT 2: HUẤN LUYỆN (TRAINING) */
.column-training {
  flex: 0.9;
  min-width: 240px;
  max-width: 320px;
}

.training-card .card-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 14px;
}

.btn-train {
  width: 100%;
  background: #1a73e8;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  padding: 14px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
  min-height: 52px;
}

.btn-train:hover:not(:disabled) {
  background: #1557b0;
}

.btn-train:disabled {
  background: #dadce0;
  color: #80868b;
  cursor: not-allowed;
}

.training-status {
  font-size: 0.85rem;
  color: #5f6368;
}

.progress-wrap {
  width: 100%;
  height: 6px;
  background: #e8eaed;
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  background: #1a73e8;
  transition: width 0.1s linear;
}

/* CỘT 3: XEM TRƯỚC (PREVIEW) */
.column-preview {
  flex: 1.3;
  min-width: 340px;
  max-width: 480px;
}

.preview-header .btn-icon {
  background: #f1f3f4;
  border: 1px solid #dadce0;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #3c4043;
  cursor: pointer;
}

.preview-header .btn-icon:hover {
  background: #e8eaed;
}

.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #202124;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 16px;
  transform: translateZ(0);
  will-change: transform;
}

#outputCanvas {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transform: translateZ(0);
}

.cam-status {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0, 0, 0, 0.6);
  color: #ffffff;
  font-size: 0.75rem;
  padding: 4px 8px;
  border-radius: 4px;
}

/* Placeholder khi ô Output chưa được mở (chưa huấn luyện xong) */
.preview-locked-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: #f8f9fa;
  border: 2px dashed #dadce0;
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  color: #5f6368;
  gap: 8px;
}

.preview-locked-placeholder .lock-icon {
  font-size: 2.2rem;
  color: #80868b;
}

.preview-locked-placeholder p {
  font-size: 0.85rem;
  line-height: 1.4;
}

/* Output Bars */
.output-section h4 {
  font-size: 0.85rem;
  color: #5f6368;
  margin-bottom: 10px;
  text-transform: uppercase;
  font-weight: 600;
}

.output-bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.empty-hint {
  font-size: 0.85rem;
  color: #80868b;
  text-align: center;
  padding: 12px;
}

.output-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.output-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 600;
}

.output-track {
  width: 100%;
  height: 14px;
  background: #e8eaed;
  border-radius: 7px;
  overflow: hidden;
}

.output-fill {
  height: 100%;
  width: 0%;
  background: var(--accent-color, #1a73e8);
  border-radius: 7px;
  transition: width 0.15s ease-out;
}

/* Tối ưu Tablet & Mobile */
@media (max-width: 992px) {
  .workspace-grid {
    flex-direction: column;
    align-items: stretch;
  }

  .flow-arrow {
    display: none;
  }

  .column-classes,
  .column-training,
  .column-preview {
    max-width: 100%;
    min-width: 100%;
  }
}
