/* ----------------------- 01. Bố cục: cấu hình phiên + trạng thái luồng ----------------------- */
.ms-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  margin-top: 30px;
  align-items: start;
}

.ms-card {
  background-color: #fff;
  border-radius: 8px;
  padding: 20px 24px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  box-sizing: border-box;
}

/* ----------------------- 02. Tabs ----------------------- */
.ms-tabs {
  display: flex;
  gap: 24px;
  border-bottom: 1px solid #e5e5e5;
  margin-bottom: 18px;
}

.ms-tab {
  padding: 8px 0;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  font-size: 14px;
  font-family: inherit;
  color: #555;
  cursor: pointer;
}

.ms-tab.active {
  color: #3f51b5;
  border-bottom-color: #3f51b5;
}

.ms-tab-panel {
  display: none;
}

.ms-tab-panel.active {
  display: block;
}

/* ----------------------- 03. Form ----------------------- */
.ms-field {
  margin-bottom: 16px;
}

.ms-field label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 14px;
  color: #333;
}

.ms-field input,
.ms-field select,
.ms-field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background-color: #fff;
  box-sizing: border-box;
}

.ms-field textarea {
  resize: vertical;
}

.ms-field input:focus,
.ms-field select:focus,
.ms-field textarea:focus {
  outline: none;
  border-color: #3f51b5;
}

.ms-field input:disabled {
  background-color: #f5f5f5;
}

.ms-counter {
  font-size: 12px;
  color: #999;
  font-weight: 400;
}

.ms-hint {
  margin: 6px 0 0;
  font-size: 12px;
  color: #b26a00;
}

.ms-hint:empty {
  display: none;
}

/* ----------------------- 04. Danh sách nơi đăng ----------------------- */
.ms-section-head {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 14px;
  color: #333;
}

.ms-destinations {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
}

.ms-destination {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid #eee;
  border-radius: 8px;
  margin-bottom: 8px;
}

.ms-dest-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background-color: #f2f3f7;
  font-size: 16px;
  flex-shrink: 0;
}

.ms-dest-icon img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.ms-dest-info {
  flex: 1;
  min-width: 0;
}

.ms-dest-name {
  font-size: 14px;
  font-weight: 500;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ms-dest-meta {
  font-size: 12px;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ms-dest-remove {
  border: none;
  background: none;
  color: #999;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.ms-dest-remove:hover {
  color: #d32f2f;
}

.ms-dest-remove:disabled {
  visibility: hidden;
}

.ms-empty {
  margin: 4px 0 14px;
  font-size: 13px;
  color: #888;
}

/* ----------------------- 05. Nút ----------------------- */
.ms-primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: 6px;
  background-color: #4a5cf0;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: background-color 0.2s;
}

.ms-primary-btn:hover {
  background-color: #3846d4;
}

.ms-primary-btn:disabled {
  background-color: #a9b1f5;
  cursor: not-allowed;
}

.ms-primary-btn.danger {
  background-color: #d32f2f;
}

.ms-primary-btn.danger:hover {
  background-color: #b71c1c;
}

.ms-primary-btn[hidden] {
  display: none;
}

.ms-secondary-btn {
  padding: 10px 20px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background-color: #fff;
  color: #333;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.ms-outline-btn {
  width: 100%;
  padding: 10px;
  border: 1px dashed #9fa8f5;
  border-radius: 8px;
  background-color: #f8f9ff;
  color: #4a5cf0;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

.ms-outline-btn:hover {
  background-color: #eef0fe;
}

.ms-outline-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ms-link-btn {
  display: block;
  margin: 14px 0 0;
  padding: 0;
  border: none;
  background: none;
  color: #3f51b5;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.ms-link-btn:hover {
  text-decoration: underline;
}

.ms-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid #f0f0f0;
}

.ms-actions .ms-primary-btn {
  flex: 1;
}

/* ----------------------- 06. Lịch sử ----------------------- */
.ms-table-wrap {
  overflow-x: auto;
}

.ms-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ms-table th,
.ms-table td {
  padding: 10px 8px;
  border-bottom: 1px solid #f0f0f0;
  text-align: left;
  white-space: nowrap;
}

.ms-table th {
  color: #888;
  font-weight: 500;
}

.ms-table td:first-child {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ms-result {
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
}

.ms-result.ok {
  background-color: #e8f5e9;
  color: #2e7d32;
}

.ms-result.none {
  background-color: #f5f5f5;
  color: #777;
}

/* ----------------------- 07. Trạng thái luồng ----------------------- */
.ms-status {
  margin-bottom: 16px;
  font-size: 15px;
  color: #333;
}

.ms-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 500;
}

.ms-badge.idle    { background-color: #f2f3f7; color: #666; }
.ms-badge.waiting { background-color: #fff4e5; color: #b26a00; }
.ms-badge.live    { background-color: #fdecea; color: #d32f2f; }

.ms-badge.live::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #d32f2f;
  animation: ms-blink 1s infinite;
}

@keyframes ms-blink {
  50% { opacity: 0.3; }
}

.ms-stats {
  margin: 0 0 16px;
}

.ms-stats div {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f3f3f3;
  font-size: 14px;
}

.ms-stats dt {
  color: #888;
}

.ms-stats dd {
  margin: 0;
  color: #222;
  font-weight: 500;
}

.ms-ingest {
  margin-bottom: 16px;
  padding: 12px;
  border-radius: 8px;
  background-color: #f8f9ff;
}

.ms-ingest[hidden] {
  display: none;
}

.ms-ingest-help {
  margin: 0 0 10px;
  font-size: 12px;
  color: #555;
  line-height: 1.5;
}

.ms-ingest label {
  display: block;
  margin: 8px 0 4px;
  font-size: 12px;
  color: #666;
}

.ms-copy-row {
  display: flex;
  gap: 6px;
}

.ms-copy-row input {
  flex: 1;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid #d5d9f5;
  border-radius: 6px;
  background-color: #fff;
  font-size: 13px;
  font-family: Consolas, monospace;
}

.ms-copy-btn {
  padding: 6px 10px;
  border: 1px solid #4a5cf0;
  border-radius: 6px;
  background-color: #fff;
  color: #4a5cf0;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.ms-copy-btn:hover {
  background-color: #eef0fe;
}

.ms-errors {
  margin: 0 0 16px;
  padding: 10px 12px 10px 28px;
  border-radius: 8px;
  background-color: #fdecea;
  color: #b71c1c;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.ms-errors[hidden] {
  display: none;
}

.ms-recommend {
  font-size: 13px;
  color: #555;
}

.ms-recommend summary {
  color: #3f51b5;
  cursor: pointer;
}

.ms-recommend ul {
  margin: 10px 0 0;
  padding-left: 18px;
  line-height: 1.6;
}

/* ----------------------- 08. Modal ----------------------- */
.ms-modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 70px 16px 16px;
  background-color: rgba(0, 0, 0, 0.45);
  z-index: 20000; /* Trên header (z-index 10000) */
  overflow-y: auto;
}

.ms-modal-overlay.open {
  display: flex;
}

.ms-modal {
  position: relative;
  width: 100%;
  max-width: 540px;
  background-color: #fff;
  border-radius: 10px;
  padding: 22px 24px 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  box-sizing: border-box;
}

.ms-modal h3 {
  margin: 0 0 16px;
  font-size: 19px;
  color: #222;
}

.ms-modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  border: none;
  background: none;
  font-size: 22px;
  line-height: 1;
  color: #999;
  cursor: pointer;
}

.ms-modal-close:hover {
  color: #333;
}

.ms-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.ms-guide {
  margin: 0 0 14px;
  padding-left: 20px;
  font-size: 14px;
  color: #444;
  line-height: 1.6;
}

.ms-guide li {
  margin-bottom: 8px;
}

/* ----------------------- 09. Thông báo nhanh (toast) ----------------------- */
.ms-toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 20001;
}

.ms-toast {
  min-width: 240px;
  max-width: 380px;
  padding: 12px 16px;
  border-radius: 6px;
  background-color: #323232;
  color: #fff;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.ms-toast.success { background-color: #2e7d32; }
.ms-toast.error   { background-color: #c62828; }

/* ----------------------- 10. Màn hình nhỏ ----------------------- */
@media (max-width: 1000px) {
  .ms-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .ms-card {
    padding: 16px;
  }
}
