/* ============================================================================
   MENURAMA BACKOFFICE — Stylesheet
   Corporate Menurama Identity (#ea580c) with Topbar + Sidebar Dashboard Layout
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --color-primary:       #ea580c;
  --color-primary-hover: #c2410c;
  --color-primary-light: #fff7ed;
  --color-success:       #16a34a;
  --color-success-light: #dcfce7;
  --color-error:         #dc2626;
  --color-error-light:   #fee2e2;
  --color-warning:       #d97706;
  --color-warning-light: #fef3c7;
  --color-info:          #0891b2;
  --color-info-light:    #e0f2fe;

  --color-bg:            #ffffff;
  --color-surface:       #f8fafc;
  --color-surface-hover: #f1f5f9;
  --color-sidebar:       #0f172a;
  --color-sidebar-hover: #1e293b;
  --color-border:        #e2e8f0;
  --color-text:          #1e293b;
  --color-text-secondary:#475569;
  --color-text-muted:    #94a3b8;

  --topbar-height: 64px;
  --sidebar-width: 250px;
  --radius-sm:     8px;
  --radius-md:     12px;
  --radius-lg:     16px;
  --shadow-sm:     0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md:     0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg:     0 20px 48px rgba(15, 23, 42, 0.16);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-body);
  background: var(--color-surface);
  color: var(--color-text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */
.bo-topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: #ffffff;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  z-index: 300;
}

.bo-topbar-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.bo-brand-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.bo-brand-logo {
  height: 44px;
  width: auto;
  object-fit: contain;
}

.bo-brand-badge {
  background: #0f172a;
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.22rem 0.55rem;
  border-radius: 6px;
}

.bo-env-badge {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  background: var(--color-primary-light);
  color: var(--color-primary);
  border: 1px solid rgba(234, 88, 12, 0.25);
}

.bo-topbar-right {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

/* Sync Button & Status in Topbar */
.bo-sync-group {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.bo-sync-meta {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  text-align: right;
  line-height: 1.25;
}

.btn-sync {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.48rem 0.9rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--color-primary);
  background: var(--color-primary-light);
  color: var(--color-primary);
  font-size: 0.83rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-sync:hover:not(:disabled) {
  background: var(--color-primary);
  color: #ffffff;
}

.btn-sync:disabled {
  opacity: 0.65;
  cursor: wait;
}

.btn-sync.syncing svg {
  animation: bo-spin 1s linear infinite;
}

@keyframes bo-spin {
  to { transform: rotate(360deg); }
}

/* User Profile Pill in Topbar */
.bo-user-dropdown {
  position: relative;
}

.bo-user-trigger {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}

.bo-user-trigger:hover {
  background: var(--color-surface-hover);
}

.bo-user-meta {
  text-align: right;
  line-height: 1.2;
}

.bo-user-name {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text);
}

.bo-user-email {
  display: block;
  font-size: 0.73rem;
  color: var(--color-text-secondary);
}

.bo-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
}

.bo-user-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  width: 220px;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 0.4rem 0;
  z-index: 400;
}

.bo-user-menu.open {
  display: block;
}

.bo-user-menu-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
  color: var(--color-text);
  transition: background 0.12s;
}

.bo-user-menu-item:hover {
  background: var(--color-surface-hover);
}

.bo-user-menu-item.danger {
  color: var(--color-error);
  border-top: 1px solid var(--color-border);
  margin-top: 0.25rem;
  padding-top: 0.65rem;
}

/* ── Shell (Sidebar + Main Content) ──────────────────────────────────────── */
.bo-shell {
  display: flex;
  padding-top: var(--topbar-height);
  min-height: 100vh;
}

.bo-sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar);
  color: #cbd5e1;
  position: fixed;
  top: var(--topbar-height);
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.25rem 0.85rem;
  z-index: 200;
}

.bo-nav-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 0.5rem 0.75rem 0.4rem;
}

.bo-nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.bo-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.68rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 500;
  color: #cbd5e1;
  transition: all 0.15s ease;
}

.bo-nav-link:hover {
  background: var(--color-sidebar-hover);
  color: #ffffff;
}

.bo-nav-link.active {
  background: var(--color-primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(234, 88, 12, 0.35);
}

.bo-sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.73rem;
  color: #64748b;
}

/* ── Main Content Container ──────────────────────────────────────────────── */
.bo-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 1.75rem 2.25rem 3rem;
  max-width: calc(100vw - var(--sidebar-width));
}

.bo-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.bo-page-title {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.bo-page-subtitle {
  font-size: 0.88rem;
  color: var(--color-text-secondary);
  margin-top: 0.2rem;
}

/* ── Cards & Grids ───────────────────────────────────────────────────────── */
.bo-card {
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: 1.35rem 1.5rem;
  margin-bottom: 1.5rem;
}

.bo-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.1rem;
  flex-wrap: wrap;
}

.bo-card-title {
  font-size: 1.02rem;
  font-weight: 600;
  color: var(--color-text);
}

.bo-card-subtitle {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
}

/* KPI Stat Strip */
.bo-kpi-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 1024px) {
  .bo-kpi-strip {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

.bo-kpi-box {
  background: #ffffff;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-height: 125px;
  cursor: pointer;
  transition: all 0.16s ease;
  user-select: none;
}

.bo-kpi-box:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.bo-kpi-box.active {
  border-color: var(--color-primary);
  background: #fffaf5;
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.16);
}

.bo-kpi-header {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.25;
  margin-bottom: 0.5rem;
}

.bo-kpi-header .bo-kpi-header-num {
  font-weight: 700;
}

.bo-kpi-lines {
  display: flex;
  flex-direction: column;
  gap: 0.22rem;
  margin-top: auto;
}

.bo-kpi-line {
  font-size: 0.82rem;
  font-weight: 400;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  line-height: 1.3;
}

.bo-kpi-line span:last-child {
  font-weight: 500;
  color: var(--color-text);
  margin-left: 0.5rem;
}

.bo-kpi-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
}

.bo-kpi-value {
  font-size: 1.65rem;
  font-weight: 700;
  color: var(--color-text);
  margin-top: 0.25rem;
}

.bo-kpi-sub {
  font-size: 0.76rem;
  color: var(--color-text-secondary);
  margin-top: 0.15rem;
}

/* Date Range Selector Bar */
.bo-range-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.bo-range-pill {
  padding: 0.38rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: #ffffff;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.bo-range-pill:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.bo-range-pill.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #ffffff;
  font-weight: 600;
}

.bo-custom-dates {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-left: 0.35rem;
}

.bo-input {
  padding: 0.45rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  color: var(--color-text);
  background: #ffffff;
  outline: none;
}

.bo-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.12);
}

/* Pie Charts Grid (Interactive Drilldown) */
.bo-pies-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
  gap: 1.15rem;
  margin-bottom: 1.5rem;
}

.bo-pie-card {
  background: #ffffff;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.15rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
}

.bo-pie-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.bo-pie-card.active {
  border-color: var(--color-primary);
  background: #fffaf5;
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.15);
}

.bo-pie-hint {
  font-size: 0.72rem;
  color: var(--color-primary);
  font-weight: 600;
  margin-top: 0.65rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Batch Split Layout (Left: Processes, Right: Execution History) ──────── */
.bo-batch-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .bo-batch-layout {
    grid-template-columns: 1fr;
  }
}

.bo-batch-proc-card {
  background: #ffffff;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
  cursor: pointer;
  transition: all 0.16s ease;
  position: relative;
}

.bo-batch-proc-card:hover {
  border-color: var(--color-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.bo-batch-proc-card.active {
  border-color: var(--color-primary);
  background: #fffaf5;
  box-shadow: 0 0 0 3px rgba(234, 88, 12, 0.16);
}

.bo-batch-history-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  margin-bottom: 0.75rem;
  background: #ffffff;
  transition: background 0.12s;
}

.bo-batch-history-item:hover {
  background: #f8fafc;
}
.bo-table-wrap {
  width: 100%;
  overflow-x: auto;
}

.bo-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

.bo-table th {
  text-align: left;
  padding: 0.65rem 0.9rem;
  font-size: 0.73rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-secondary);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.bo-table td {
  padding: 0.68rem 0.9rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.bo-table tr.clickable-row {
  cursor: pointer;
  transition: background 0.12s;
}

.bo-table tr.clickable-row:hover {
  background: #fff7ed;
}

/* Badges */
.bo-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.18rem 0.58rem;
  border-radius: 999px;
  font-size: 0.73rem;
  font-weight: 600;
}

.bo-badge-pro {
  background: #ffedd5;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.bo-badge-free {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
}

.bo-badge-success {
  background: var(--color-success-light);
  color: var(--color-success);
}

.bo-badge-warning {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.bo-badge-danger {
  background: var(--color-error-light);
  color: var(--color-error);
}

.bo-badge-info {
  background: var(--color-info-light);
  color: var(--color-info);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-sm {
  padding: 0.32rem 0.68rem;
  font-size: 0.78rem;
}

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

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

.btn-secondary {
  background: #ffffff;
  border-color: var(--color-border);
  color: var(--color-text);
}

.btn-secondary:hover {
  background: var(--color-surface-hover);
}

.btn-danger {
  background: var(--color-error);
  color: #ffffff;
}

.btn-danger:hover {
  background: #b91c1c;
}

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

/* Row Options Dropdown */
.bo-row-actions {
  position: relative;
  display: inline-block;
}

.bo-row-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 185px;
  background: #ffffff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  z-index: 250;
  padding: 0.3rem 0;
}

.bo-row-menu.open {
  display: block;
}

.bo-row-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.48rem 0.85rem;
  font-size: 0.82rem;
  color: var(--color-text);
  background: none;
  border: none;
  cursor: pointer;
}

.bo-row-menu-item:hover {
  background: var(--color-surface-hover);
}

.bo-row-menu-item.danger {
  color: var(--color-error);
}

/* Detail Grids */
.bo-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.bo-field {
  padding: 0.65rem 0.85rem;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.bo-field-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
}

.bo-field-value {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--color-text);
  margin-top: 0.15rem;
  word-break: break-word;
}

/* Modal (Indented JSON Viewer with Tabs & Confirmations) */
.bo-modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(3px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.bo-modal-backdrop.open {
  display: flex;
}

.bo-modal-dialog {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 960px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.bo-modal-tabs {
  display: flex;
  gap: 0.35rem;
  padding: 0.65rem 1.5rem 0;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
}

.bo-modal-tab {
  padding: 0.55rem 1rem;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  white-space: nowrap;
}

.bo-modal-tab.active {
  background: #0f172a;
  color: #ffffff;
}

.bo-modal-body {
  padding: 1.25rem 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.bo-json-pre {
  background: #0f172a;
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.55;
  padding: 1.15rem;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  max-height: 58vh;
  white-space: pre;
}

/* Flash Alerts */
.bo-flash-stack {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.bo-flash {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.87rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid transparent;
}

.bo-flash-success { background: var(--color-success-light); color: #166534; border-color: #bbf7d0; }
.bo-flash-error   { background: var(--color-error-light);   color: #991b1b; border-color: #fecaca; }
.bo-flash-warning { background: var(--color-warning-light); color: #92400e; border-color: #fde68a; }
.bo-flash-info    { background: var(--color-info-light);    color: #075985; border-color: #bae6fd; }

@media (max-width: 900px) {
  .bo-sidebar {
    width: 72px;
    padding: 1rem 0.4rem;
  }
  .bo-nav-link span, .bo-nav-section-label, .bo-sidebar-footer {
    display: none;
  }
  .bo-content {
    margin-left: 72px;
    max-width: calc(100vw - 72px);
    padding: 1.25rem;
  }
}
