/* ==========================================================================
   PRO AUTO POSTER - ENTERPRISE SAAS WEB DASHBOARD STYLESHEET
   Compatible with tuanhomni.com Subdomain Deployment (fbp.tuanhomni.com)
   ========================================================================== */

:root {
  --font-main: 'Plus Jakarta Sans', 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Fira Code', monospace;

  /* Colors */
  --bg-page: #f4f6f9;
  --bg-card: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-topbar: #ffffff;
  
  --border-color: #e5e7eb;
  --border-light: #f1f5f9;
  
  --primary-blue: #2563eb;
  --primary-blue-light: #eff6ff;
  --primary-blue-hover: #1d4ed8;

  --accent-red: #ef4444;
  --accent-red-hover: #dc2626;
  --accent-red-light: #fef2f2;

  --accent-green: #10b981;
  --accent-green-light: #ecfdf5;

  --accent-amber: #f59e0b;
  --accent-amber-light: #fffbeb;

  --text-main: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card: 0 1px 3px 0 rgba(0, 0, 0, 0.07), 0 1px 2px -1px rgba(0, 0, 0, 0.07);
  --shadow-dropdown: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-page);
  color: var(--text-main);
  font-size: 13.5px;
  line-height: 1.5;
  overflow-x: hidden;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==================== TOP WINDOW APP BAR ==================== */
.top-app-bar {
  height: 52px;
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 100;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-icon-badge {
  width: 26px;
  height: 26px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
}

.app-window-title {
  font-size: 13.5px;
  font-weight: 600;
  color: #334155;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.agent-status-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.agent-status-pill.online {
  background: #ecfdf5;
  color: #059669;
  border-color: #a7f3d0;
}

.agent-status-pill.offline {
  background: #fef2f2;
  color: #dc2626;
  border-color: #fecaca;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.agent-status-pill.offline .status-dot {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.ecosystem-badge {
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  padding: 4px 10px;
  border-radius: 6px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s;
}

.ecosystem-badge:hover {
  background: #e2e8f0;
  color: #0f172a;
}

.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-main);
  cursor: pointer;
}

/* ==================== 3-COLUMN MAIN LAYOUT ==================== */
.app-layout-container {
  display: flex;
  flex: 1;
  height: calc(100vh - 52px);
  overflow: hidden;
}

/* ==================== CỘT 1: SIDEBAR ==================== */
.sidebar {
  width: 240px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 16px 12px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 20px 8px;
}

.brand-logo-box {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.logo-letter {
  color: #ffffff;
  font-size: 24px;
  font-weight: 900;
  font-family: var(--font-main);
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.1;
  letter-spacing: -0.3px;
}

.brand-sub {
  font-size: 13px;
  font-weight: 800;
  color: #2563eb;
  letter-spacing: 0.5px;
}

.sidebar-section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.6px;
  padding: 10px 10px 8px 10px;
  text-transform: uppercase;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  color: #475569;
  text-decoration: none;
  font-weight: 600;
  font-size: 13.5px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.nav-icon {
  font-size: 16px;
  width: 20px;
  display: flex;
  justify-content: center;
  color: #64748b;
  transition: color 0.2s;
}

.nav-item:hover {
  background-color: #f8fafc;
  color: #0f172a;
}

.nav-item:hover .nav-icon {
  color: var(--primary-blue);
}

.nav-item.active {
  background-color: var(--primary-blue-light);
  color: var(--primary-blue);
}

.nav-item.active .nav-icon {
  color: var(--primary-blue);
}

/* Submenu Accordion */
.nav-group-toggle {
  position: relative;
  justify-content: space-between;
}

.group-arrow {
  font-size: 11px;
  color: #94a3b8;
  transition: transform 0.25s ease;
  margin-left: auto;
}

.nav-group.open .group-arrow {
  transform: rotate(180deg);
}

.nav-sub-menu {
  display: none;
  flex-direction: column;
  gap: 2px;
  padding-left: 28px;
  margin-top: 2px;
}

.nav-group.open .nav-sub-menu {
  display: flex;
}

.nav-sub-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: #64748b;
  text-decoration: none;
  font-size: 12.5px;
  font-weight: 500;
  transition: all 0.2s;
}

.nav-sub-item:hover {
  color: var(--primary-blue);
  background-color: #f1f5f9;
}

/* Sidebar Footer User Card */
.sidebar-footer-card {
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

.user-card-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-md);
  background: #f8fafc;
  border: 1px solid var(--border-color);
  cursor: pointer;
}

.user-avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #2563eb;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

.user-details {
  flex: 1;
  overflow: hidden;
}

.user-label {
  font-size: 10.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.user-id {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--primary-blue);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-dropdown-icon {
  font-size: 11px;
  color: #94a3b8;
}

.sidebar-version-tag {
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

/* ==================== CỘT 2: MAIN CONTENT PANEL ==================== */
.main-content-panel {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.view-section {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.table-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-icon-box {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--primary-blue-light);
  color: var(--primary-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.section-heading {
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.2px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-outline {
  background: #ffffff;
  border-color: var(--border-color);
  color: #475569;
}

.btn-outline:hover {
  background: #f8fafc;
  color: var(--primary-blue);
  border-color: #cbd5e1;
}

.btn-outline-danger {
  background: #ffffff;
  border-color: #fecaca;
  color: #dc2626;
}

.btn-outline-danger:hover {
  background: #fef2f2;
}

.btn-primary {
  background: var(--primary-blue);
  color: #ffffff;
}

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

.btn-gold {
  background: #f59e0b;
  color: #ffffff;
}

.btn-gold:hover {
  background: #d97706;
}

/* Enterprise Table */
.table-responsive-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  flex: 1;
  margin-bottom: 16px;
}

.enterprise-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.enterprise-table thead {
  background-color: #f8fafc;
  border-bottom: 1px solid var(--border-color);
}

.enterprise-table th {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.3px;
}

.enterprise-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background-color 0.15s ease;
}

.enterprise-table tbody tr:hover {
  background-color: #f8fafc;
}

.enterprise-table td {
  padding: 12px 16px;
  font-size: 13px;
  vertical-align: middle;
}

/* Table Item Components */
.account-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-avatar-fb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #1877f2;
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}

.account-info-box {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.account-name-text {
  font-weight: 700;
  color: #1e293b;
  font-size: 13px;
}

.account-uid-text {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.action-label-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  color: #334155;
}

.action-icon-blue {
  color: #3b82f6;
  font-size: 13px;
}

/* Status Badges */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
}

.badge-status.success {
  color: #10b981;
}

.badge-status.failed {
  color: #ef4444;
}

.badge-status.running {
  color: #2563eb;
}

.time-cell {
  color: #64748b;
  font-size: 12px;
  font-family: var(--font-mono);
  text-align: right;
}

/* Live KPI Strip */
.kpi-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px 20px;
  box-shadow: var(--shadow-card);
}

.kpi-box {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.kpi-label {
  font-size: 12px;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 2px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 900;
  line-height: 1;
  font-family: var(--font-main);
}

.kpi-total .kpi-value { color: #2563eb; }
.kpi-success .kpi-value { color: #10b981; }
.kpi-danger .kpi-value { color: #ef4444; }
.kpi-warning .kpi-value { color: #f59e0b; }

/* ==================== CỘT 3: CONTROL SIDEBAR ==================== */
.control-sidebar {
  width: 380px;
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-color);
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex-shrink: 0;
}

/* Big Red Start Action Button */
.btn-start-action {
  width: 100%;
  height: 48px;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border: none;
  border-radius: var(--radius-md);
  color: #ffffff;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(239, 68, 68, 0.4);
  transition: all 0.25s ease;
}

.btn-start-action:hover {
  background: linear-gradient(135deg, #dc2626, #b91c1c);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(239, 68, 68, 0.5);
}

.btn-start-action.running {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.4);
}

/* Accordion Cards */
.accordion-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.accordion-header {
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  background: #ffffff;
  transition: background-color 0.15s;
}

.accordion-header:hover {
  background-color: #f8fafc;
}

.accordion-title {
  font-size: 12.5px;
  font-weight: 800;
  color: #0f172a;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.2px;
}

.accordion-title i {
  color: #2563eb;
  font-size: 14px;
}

.accordion-icon {
  font-size: 11px;
  color: #94a3b8;
  transition: transform 0.25s ease;
}

.accordion-card.collapsed .accordion-icon {
  transform: rotate(180deg);
}

.accordion-card.collapsed .accordion-body {
  display: none;
}

.accordion-body {
  padding: 14px;
  border-top: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Form Controls */
.form-group-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: #475569;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.btn-text-sparkle {
  background: none;
  border: none;
  color: #2563eb;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.btn-text-sparkle:hover {
  text-decoration: underline;
}

.range-inputs-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.range-prefix {
  font-size: 12px;
  color: #64748b;
  font-weight: 500;
}

.input-control {
  width: 100%;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 13px;
  color: var(--text-main);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-control:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.input-with-icon {
  position: relative;
}

.input-icon-right {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  pointer-events: none;
}

.select-control {
  width: 100%;
  padding: 8px 12px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 13px;
  color: var(--text-main);
  outline: none;
  cursor: pointer;
}

.textarea-control {
  width: 100%;
  padding: 10px 12px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 12.5px;
  color: var(--text-main);
  resize: vertical;
  outline: none;
  line-height: 1.5;
}

.textarea-control:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Tag Pills Bar */
.tag-pills-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-pill {
  font-size: 11px;
  font-weight: 600;
  background: #eff6ff;
  color: #2563eb;
  padding: 3px 8px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #dbeafe;
  transition: all 0.15s;
  user-select: none;
}

.tag-pill:hover {
  background: #2563eb;
  color: #ffffff;
}

/* Info Note Box (Exact mockup styling) */
.info-note-box {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 11.5px;
}

.note-title {
  font-weight: 700;
  color: #b45309;
  margin-bottom: 4px;
}

.note-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: #92400e;
}

.note-list code {
  font-family: var(--font-mono);
  background: rgba(245, 158, 11, 0.15);
  padding: 1px 4px;
  border-radius: 3px;
  font-weight: 600;
}

/* Checkbox Settings */
.checkbox-setting-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 12.5px;
  color: #334155;
  font-weight: 500;
}

.checkbox-setting-row input {
  display: none;
}

.custom-chk {
  width: 16px;
  height: 16px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.checkbox-setting-row input:checked + .custom-chk {
  background: var(--primary-blue);
  border-color: var(--primary-blue);
}

.checkbox-setting-row input:checked + .custom-chk::after {
  content: '✓';
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
}

.inline-number-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #475569;
  font-weight: 500;
}

.input-control-sm {
  width: 70px;
  padding: 4px 8px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  text-align: center;
  font-size: 12px;
}

.inline-unit {
  color: var(--text-muted);
  font-size: 11.5px;
}

/* ==================== MODAL ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal-content {
  background: #ffffff;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 520px;
  box-shadow: var(--shadow-dropdown);
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 15px;
  font-weight: 800;
  color: #0f172a;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 20px;
  color: #94a3b8;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-footer {
  padding: 14px 20px;
  background: #f8fafc;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-secondary {
  background: #e2e8f0;
  color: #334155;
}

.btn-secondary:hover {
  background: #cbd5e1;
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.toast {
  background: #1e293b;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: var(--shadow-dropdown);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideUp 0.25s ease;
}

.toast.success { background: #059669; }
.toast.error { background: #dc2626; }
.toast.info { background: #2563eb; }

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

/* ==================== RESPONSIVE DESIGN ==================== */
@media (max-width: 1180px) {
  .control-sidebar {
    width: 320px;
  }
}

@media (max-width: 960px) {
  .app-layout-container {
    flex-direction: column;
    height: auto;
    overflow-y: auto;
  }
  
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .control-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border-color);
  }
}
