/* ==========================================================================
   COMPONENTS — buttons, cards, badges, forms, drawer, modal, toast, dropdown
   ========================================================================== */

/* ---------------- BUTTONS ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 8px 14px; border-radius: var(--radius-sm); font-size: var(--fs-sm); font-weight: 600;
  border: 1px solid var(--border); background: var(--bg-surface); color: var(--text-primary);
  transition: all var(--transition); white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.btn:active { transform: scale(.98); }
.btn.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.btn-primary:hover { background: var(--accent-hover); }
.btn.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.btn-danger:hover { opacity: .9; }
.btn.btn-ghost { background: transparent; border-color: transparent; }
.btn.btn-ghost:hover { background: var(--bg-hover); }
.btn.btn-sm { padding: 5px 10px; font-size: var(--fs-xs); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- CARD / STAT CARD ---------------- */
.card {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; box-shadow: var(--shadow-xs);
}
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat-card {
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 6px;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.stat-card .stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-card .stat-icon { width: 34px; height: 34px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; }
.stat-card .stat-value { font-size: var(--fs-2xl); font-weight: 800; line-height: 1; }
.stat-card .stat-label { color: var(--text-secondary); font-size: var(--fs-sm); font-weight: 500; }
.stat-card .stat-sub { font-size: var(--fs-xs); color: var(--text-tertiary); }

/* ---------------- BADGE ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: var(--radius-full); font-size: var(--fs-xs); font-weight: 600; line-height: 1.6;
  white-space: nowrap;
}
.dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; display: inline-block; }

/* ---------------- FORMS ---------------- */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: var(--fs-xs); font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; }
.form-control {
  width: 100%; padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--bg-surface-2); color: var(--text-primary); font-size: var(--fs-sm); outline: none;
  transition: border-color var(--transition), background var(--transition);
}
.form-control:focus { border-color: var(--accent); background: var(--bg-surface); }
textarea.form-control { resize: vertical; min-height: 64px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: var(--fs-xs); color: var(--text-tertiary); margin-top: 4px; }

select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; padding-right: 28px; }

/* Multi-select chips (nhân sự) */
.chip-select { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-option {
  display: flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: var(--radius-full);
  border: 1px solid var(--border); font-size: var(--fs-xs); font-weight: 600; background: var(--bg-surface-2);
  transition: all var(--transition);
}
.chip-option.selected { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip-option:not(.readonly) { cursor: pointer; }
.chip-option.type-chip { cursor: pointer; }
.chip-option.type-chip.selected { background: var(--chip-color, var(--accent)); border-color: var(--chip-color, var(--accent)); color: #fff; }
.chip-option.readonly { cursor: default; pointer-events: none; }
.chip-option.type-chip.readonly:not(.selected) { opacity: .4; }

/* ---------------- FILTER BAR ---------------- */
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.filter-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--radius-full);
  border: 1px solid var(--border); background: var(--bg-surface); font-size: var(--fs-xs); font-weight: 600;
  color: var(--text-secondary); transition: all var(--transition);
}
.filter-btn:hover { border-color: var(--border-strong); }
.filter-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.filter-divider { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }

/* ---------------- TOAST ---------------- */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 260px; max-width: 360px; background: var(--bg-surface); border: 1px solid var(--border);
  border-radius: var(--radius-md); box-shadow: var(--shadow-md); padding: 12px 14px;
  display: flex; align-items: flex-start; gap: 10px; animation: toastIn .22s ease-out;
  border-left: 3px solid var(--accent);
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }
.toast .toast-title { font-size: var(--fs-sm); font-weight: 700; margin-bottom: 2px; }
.toast .toast-msg { font-size: var(--fs-xs); color: var(--text-secondary); }
.toast.hide { animation: toastOut .18s ease-in forwards; }
@keyframes toastIn { from { opacity:0; transform: translateX(20px); } to { opacity:1; transform:translateX(0); } }
@keyframes toastOut { to { opacity:0; transform: translateX(20px); } }

/* ---------------- MODAL (Quick Add) ---------------- */
.modal-overlay {
  position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: flex-start;
  justify-content: center; padding-top: 12vh; z-index: 1000; opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal-box {
  background: var(--bg-surface); border-radius: var(--radius-lg); width: 560px; max-width: 92vw;
  box-shadow: var(--shadow-lg); transform: translateY(-8px) scale(.98); transition: transform var(--transition);
  max-height: 78vh; display: flex; flex-direction: column; overflow: hidden;
}
.modal-overlay.open .modal-box { transform: translateY(0) scale(1); }
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: var(--fs-md); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; }
.qa-conflict-slot { flex: 1 1 100%; margin-bottom: 4px; }
.qa-conflict-slot:empty { margin: 0; }

/* Cảnh báo trùng lịch — QuickAdd / Job popup */
.conflict-box {
  background: var(--danger-bg, #fef2f2);
  border: 1px solid rgba(239, 68, 68, .22);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.45;
}
.conflict-box.overload-box { background: #fffbeb; border-color: rgba(245, 158, 11, .3); }
.conflict-title { color: var(--danger); font-weight: 700; margin-bottom: 4px; }
.overload-box .conflict-title { color: #b45309; }
.conflict-hint { color: var(--text-secondary); font-size: 11.5px; margin-bottom: 6px; }
.conflict-lines { display: flex; flex-direction: column; gap: 4px; }
.conflict-person b { color: var(--danger); }
.conflict-job { display: inline; }
.conflict-job em { color: var(--text-tertiary); font-style: normal; font-size: 11.5px; }

/* ---------------- JOB POPUP (modal ở giữa màn hình — KHÔNG dùng drawer trượt) ---------------- */
.drawer-overlay {
  position: fixed; inset: 0; background: var(--overlay); z-index: 900; opacity: 0; pointer-events: none;
  transition: opacity var(--transition);
  display: flex; align-items: center; justify-content: center; padding: 4vh 16px;
}
.drawer-overlay.open { opacity: 1; pointer-events: all; }
.drawer {
  position: relative; width: 720px; max-width: 100%; max-height: 92vh; background: var(--bg-surface);
  border: 1px solid var(--border); border-radius: var(--radius-lg); z-index: 901; box-shadow: var(--shadow-lg);
  transform: scale(.96) translateY(8px); opacity: 0; transition: transform var(--transition), opacity var(--transition);
  display: flex; flex-direction: column; overflow: hidden;
}
.drawer-overlay.open .drawer { transform: scale(1) translateY(0); opacity: 1; }
.drawer-header { padding: 16px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.drawer-header .drawer-title { font-size: var(--fs-md); font-weight: 700; flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 20px 22px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; align-content: start; }
.drawer-body > .drawer-section.full { grid-column: 1 / -1; }
.drawer-footer { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; flex-shrink: 0; }
.drawer-section { margin-bottom: 20px; }
.drawer-section-title { font-size: var(--fs-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--text-tertiary); margin-bottom: 8px; display: flex; align-items: center; gap: 6px; }
.drawer-info-row { display: flex; align-items: flex-start; gap: 10px; padding: 5px 0; font-size: var(--fs-sm); }
.drawer-info-row .label { color: var(--text-tertiary); width: 92px; flex-shrink: 0; }
.drawer-info-row .value { color: var(--text-primary); font-weight: 500; flex: 1; min-width: 0; }
.drawer-info-row.drawer-info-members .value { display: flex; align-items: flex-start; }
.drawer-info-row.drawer-info-members .member-pill-list { width: 100%; }

/* ---- Popup Lịch đăng bài (layout gọn 1 cột) ---- */
.drawer.drawer-post { width: 580px; }
.drawer-body.drawer-body-post,
.drawer-body.drawer-body-shoot-staff { grid-template-columns: 1fr; gap: 12px; padding: 16px 20px; }

/* ---- Popup Lịch quay/chụp (1 cột — đồng bộ Quick Add) ---- */
.drawer.drawer-shoot { width: 560px; }
.drawer-body.drawer-body-shoot-mgr,
.drawer-body.drawer-body-shoot-view {
  display: block;
  padding: 18px 20px;
}
.drawer-body-shoot-mgr .shoot-extra {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: 4px;
}
.shoot-view-val {
  font-size: var(--fs-sm);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.shoot-view-brief {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  white-space: pre-wrap;
  line-height: 1.5;
  padding: 10px 12px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.chip-select .member-pill { flex: 0 0 auto; }
.pd-card {
  background: var(--bg-surface-2); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 14px 16px; margin-bottom: 0;
}
.drawer-body-post .drawer-section,
.drawer-body-shoot-staff .drawer-section { margin-bottom: 0; }
.pd-summary-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.pd-client-name { font-size: var(--fs-md); font-weight: 800; flex: 1; min-width: 120px; }
.pd-kv { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 6px 0; font-size: var(--fs-sm); border-top: 1px solid var(--border); }
.pd-kv:first-of-type { border-top: none; padding-top: 0; }
.pd-kv > span { color: var(--text-tertiary); flex-shrink: 0; min-width: 88px; }
.pd-kv > b { text-align: right; font-weight: 600; }
.pd-kv > .member-pill-list { text-align: left; flex: 1; }
.pd-card-title { font-size: var(--fs-xs); font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--text-tertiary); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.pd-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.pd-date-field .form-label { margin-bottom: 4px; font-size: 11px; }
.pd-members { margin-top: 4px; }
.member-pill-list { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-start; }
.drawer-info-row .value .member-pill-list { justify-content: flex-start; }
.pd-kv .member-pill-list { justify-content: flex-start; text-align: left; }
.pd-kv-members { flex-direction: column; align-items: flex-start; gap: 6px; }
.pd-kv-members > span { min-width: 0; }
.member-pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px 4px 4px;
  background: var(--bg-surface); border: 1px solid var(--border); border-radius: 20px; font-size: 12px; font-weight: 600;
}
.post-status-btns .btn { flex: 1; min-width: 120px; }

@media (max-width: 900px) {
  .drawer { width: 100%; max-height: 96vh; }
  .drawer-body { grid-template-columns: 1fr; }
  .drawer-overlay { padding: 0; align-items: flex-end; }
  .drawer { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
}

/* ---------------- CHECKLIST ---------------- */
.checklist-item { display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: var(--fs-sm); }
.checklist-item.done .checklist-text { text-decoration: line-through; color: var(--text-tertiary); }
.checklist-item input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.checklist-text { flex: 1; }
.checklist-remove { opacity: 0; color: var(--text-tertiary); }
.checklist-item:hover .checklist-remove { opacity: 1; }

/* ---------------- TIMELINE ---------------- */
.timeline-item { display: flex; gap: 10px; padding: 8px 0; border-left: 2px solid var(--border); margin-left: 6px; padding-left: 16px; position: relative; }
.timeline-item::before { content: ''; position: absolute; left: -6px; top: 10px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); }
.timeline-item .t-title { font-size: var(--fs-sm); font-weight: 600; }
.timeline-item .t-meta { font-size: var(--fs-xs); color: var(--text-tertiary); }

/* ---------------- FILE GRID ---------------- */
.file-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.file-thumb { aspect-ratio: 1; border-radius: var(--radius-sm); border: 1px solid var(--border); overflow: hidden; position: relative; background: var(--bg-surface-2); display: flex; align-items: center; justify-content: center; }
.file-thumb img, .file-thumb video { width: 100%; height: 100%; object-fit: cover; }
.file-thumb .file-remove { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.55); color: #fff; border-radius: 50%; width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity var(--transition); }
.file-thumb:hover .file-remove { opacity: 1; }

/* ---------------- TABS ---------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab-btn { padding: 9px 14px; font-size: var(--fs-sm); font-weight: 600; color: var(--text-secondary); border-bottom: 2px solid transparent; }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------------- DROPDOWN / CONTEXT MENU ---------------- */
.dropdown-menu {
  position: absolute; background: var(--bg-surface); border: 1px solid var(--border); border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); min-width: 200px; z-index: 950; padding: 6px; display: none;
}
.dropdown-menu.open { display: block; }
.dropdown-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--radius-sm); font-size: var(--fs-sm); color: var(--text-primary); }
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* ---------------- TOOLTIP-ish empty state ---------------- */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 50px 20px; color: var(--text-tertiary); text-align: center; gap: 8px; }
.empty-state svg { width: 40px; height: 40px; opacity: .5; }

/* ---------------- SKELETON LOADING ---------------- */
.skel { background: linear-gradient(90deg, var(--bg-surface-2) 25%, var(--bg-hover) 37%, var(--bg-surface-2) 63%); background-size: 400% 100%; animation: skel 1.4s infinite; border-radius: var(--radius-sm); }
@keyframes skel { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
