/* ===================================================================
   Betime Solution — Main CSS Theme
   =================================================================== */

:root {
  --bt-primary:    #1565C0;
  --bt-secondary:  #0D47A1;
  --bt-accent:     #42A5F5;
  --bt-success:    #2E7D32;
  --bt-warning:    #F57F17;
  --bt-danger:     #B71C1C;
  --bt-dark:       #1A237E;
  --bt-light:      #E3F2FD;
  --bt-bg:         #F4F6FB;
  --bt-card-bg:    #FFFFFF;
  --bt-text:       #212121;
  --bt-muted:      #757575;
  --bt-border:     #E0E0E0;
  --bt-shadow:     0 2px 12px rgba(21,101,192,0.10);
  --bt-radius:     12px;
  --bt-radius-sm:  8px;
}

/* ----- Layout ----- */
body.betime-portal {
  background: var(--bt-bg);
  font-family: 'Sarabun', 'Noto Sans Thai', sans-serif;
  color: var(--bt-text);
}

.bt-container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ----- Topbar ----- */
.bt-topbar {
  background: var(--bt-primary);
  color: #fff;
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
}
.bt-topbar .bt-logo {
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: #fff;
  text-decoration: none;
}
.bt-topbar .bt-nav {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}
.bt-topbar .bt-nav a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: var(--bt-radius-sm);
  font-size: 0.9rem;
  transition: background 0.2s;
}
.bt-topbar .bt-nav a:hover,
.bt-topbar .bt-nav a.active {
  background: rgba(255,255,255,0.15);
  color: #fff;
}
.bt-user-badge {
  background: rgba(255,255,255,0.2);
  border-radius: 20px;
  padding: 4px 14px;
  font-size: 0.85rem;
  color: #fff;
}

/* ----- Cards ----- */
.bt-card {
  background: var(--bt-card-bg);
  border-radius: var(--bt-radius);
  box-shadow: var(--bt-shadow);
  padding: 24px;
  transition: box-shadow 0.2s, transform 0.2s;
}
.bt-card:hover {
  box-shadow: 0 6px 24px rgba(21,101,192,0.16);
  transform: translateY(-2px);
}
.bt-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--bt-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.bt-card-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--bt-primary);
  line-height: 1.1;
}
.bt-card-sub {
  font-size: 0.85rem;
  color: var(--bt-muted);
  margin-top: 4px;
}

/* ----- KPI Grid ----- */
.bt-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ----- Department Grid ----- */
.bt-dept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin: 24px 0;
}
.bt-dept-card {
  background: var(--bt-card-bg);
  border-radius: var(--bt-radius);
  box-shadow: var(--bt-shadow);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  color: var(--bt-text);
  display: block;
  transition: box-shadow 0.2s, transform 0.2s;
  border-top: 4px solid var(--bt-primary);
}
.bt-dept-card:hover {
  box-shadow: 0 8px 32px rgba(21,101,192,0.18);
  transform: translateY(-4px);
  text-decoration: none;
  color: var(--bt-text);
}
.bt-dept-card .icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  display: block;
}
.bt-dept-card h3 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0 0 6px;
}
.bt-dept-card p {
  font-size: 0.82rem;
  color: var(--bt-muted);
  margin: 0;
}

/* ----- Buttons ----- */
.bt-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--bt-radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.2s, transform 0.1s;
  text-decoration: none;
}
.bt-btn:hover { opacity: 0.88; transform: translateY(-1px); }
.bt-btn-primary   { background: var(--bt-primary);  color: #fff; }
.bt-btn-success   { background: var(--bt-success);  color: #fff; }
.bt-btn-warning   { background: var(--bt-warning);  color: #fff; }
.bt-btn-danger    { background: var(--bt-danger);   color: #fff; }
.bt-btn-outline   { background: transparent; color: var(--bt-primary); border: 2px solid var(--bt-primary); }
.bt-btn-sm { padding: 6px 14px; font-size: 0.82rem; }

/* ----- Badge / Tag ----- */
.bt-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
}
.bt-badge-green  { background: #E8F5E9; color: #2E7D32; }
.bt-badge-orange { background: #FFF3E0; color: #E65100; }
.bt-badge-red    { background: #FFEBEE; color: #C62828; }
.bt-badge-blue   { background: #E3F2FD; color: #1565C0; }
.bt-badge-grey   { background: #F5F5F5; color: #616161; }

/* ----- Table ----- */
.bt-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.bt-table th {
  background: var(--bt-light);
  color: var(--bt-primary);
  font-weight: 700;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 2px solid var(--bt-border);
}
.bt-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--bt-border);
  vertical-align: middle;
}
.bt-table tr:hover td { background: #F8FBFF; }

/* ----- Progress Bar ----- */
.bt-progress {
  background: var(--bt-border);
  border-radius: 6px;
  height: 8px;
  overflow: hidden;
  width: 100%;
}
.bt-progress-bar {
  height: 100%;
  border-radius: 6px;
  background: var(--bt-primary);
  transition: width 0.5s ease;
}
.bt-progress-bar.success { background: var(--bt-success); }
.bt-progress-bar.warning { background: var(--bt-warning); }
.bt-progress-bar.danger  { background: var(--bt-danger);  }

/* ----- Chat UI ----- */
.bt-chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  border: 1px solid var(--bt-border);
  border-radius: var(--bt-radius);
  overflow: hidden;
  background: var(--bt-card-bg);
}
.bt-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bt-chat-msg {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: var(--bt-radius);
  font-size: 0.9rem;
  line-height: 1.6;
}
.bt-chat-msg.user {
  background: var(--bt-primary);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.bt-chat-msg.ai {
  background: var(--bt-light);
  color: var(--bt-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.bt-chat-msg.ai .source {
  font-size: 0.75rem;
  color: var(--bt-muted);
  margin-top: 6px;
}
.bt-chat-input-row {
  display: flex;
  padding: 12px;
  border-top: 1px solid var(--bt-border);
  gap: 8px;
}
.bt-chat-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid var(--bt-border);
  border-radius: var(--bt-radius-sm);
  font-size: 0.9rem;
  outline: none;
  font-family: inherit;
}
.bt-chat-input:focus { border-color: var(--bt-primary); }

/* ----- STT Tool ----- */
.bt-stt-drop {
  border: 3px dashed var(--bt-accent);
  border-radius: var(--bt-radius);
  padding: 48px;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s;
  background: var(--bt-light);
}
.bt-stt-drop:hover, .bt-stt-drop.dragover {
  background: #BBDEFB;
}
.bt-stt-drop .icon { font-size: 3rem; color: var(--bt-primary); }
.bt-transcript-box {
  background: #FAFAFA;
  border: 1px solid var(--bt-border);
  border-radius: var(--bt-radius-sm);
  padding: 16px;
  min-height: 160px;
  font-size: 0.9rem;
  line-height: 1.8;
  white-space: pre-wrap;
  max-height: 340px;
  overflow-y: auto;
}

/* ----- Notifications / Alerts ----- */
.bt-alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--bt-radius-sm);
  margin-bottom: 12px;
  font-size: 0.9rem;
}
.bt-alert-info    { background: #E3F2FD; border-left: 4px solid var(--bt-primary); }
.bt-alert-success { background: #E8F5E9; border-left: 4px solid var(--bt-success); }
.bt-alert-warning { background: #FFF3E0; border-left: 4px solid var(--bt-warning); }
.bt-alert-danger  { background: #FFEBEE; border-left: 4px solid var(--bt-danger);  }

/* ----- Form ----- */
.bt-form-group { margin-bottom: 20px; }
.bt-label { display: block; font-weight: 600; font-size: 0.9rem; margin-bottom: 6px; color: var(--bt-text); }
.bt-label .reqd { color: var(--bt-danger); }
.bt-input, .bt-select, .bt-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--bt-border);
  border-radius: var(--bt-radius-sm);
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  background: #fff;
}
.bt-input:focus, .bt-select:focus, .bt-textarea:focus {
  border-color: var(--bt-primary);
  box-shadow: 0 0 0 3px rgba(21,101,192,0.10);
}
.bt-textarea { resize: vertical; min-height: 100px; }

/* ----- Spinner ----- */
.bt-spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--bt-border);
  border-top-color: var(--bt-primary);
  border-radius: 50%;
  animation: bt-spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes bt-spin { to { transform: rotate(360deg); } }

/* ----- Section header ----- */
.bt-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 28px 0 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--bt-border);
}
.bt-section-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--bt-primary);
  margin: 0;
}

/* ----- Responsive ----- */
@media (max-width: 768px) {
  .bt-kpi-grid   { grid-template-columns: repeat(2, 1fr); }
  .bt-dept-grid  { grid-template-columns: repeat(2, 1fr); }
  .bt-container  { padding: 0 12px; }
  .bt-topbar .bt-nav { display: none; }
}
@media (max-width: 480px) {
  .bt-kpi-grid  { grid-template-columns: 1fr; }
  .bt-dept-grid { grid-template-columns: 1fr; }
}
