/* ============================================================
   BDShapers Enterprise Platform v2.0
   Core Design System
   ============================================================ */

:root {
  /* Brand palette */
  --bg-base:      #0F172A;   /* deep navy - sidebar / dark surfaces */
  --bg-base-2:    #1E293B;   /* lighter navy - hover states on dark */
  --accent:       #4F46E5;   /* electric indigo - primary actions */
  --accent-hover: #4338CA;
  --accent-soft:  #EEF2FF;
  --success:      #0D9488;   /* teal */
  --success-soft: #ECFDF5;
  --warning:      #F59E0B;
  --warning-soft: #FFFBEB;
  --danger:       #DC2626;
  --danger-soft:  #FEF2F2;

  --content-bg:   #F8FAFC;
  --surface:      #FFFFFF;
  --border:       #E2E8F0;

  --text-primary: #0F172A;
  --text-muted:   #64748B;
  --text-on-dark: #CBD5E1;
  --text-on-dark-active: #FFFFFF;

  /* Typography */
  --font-display: 'Outfit', 'Noto Sans Bengali', sans-serif;
  --font-body:    'Inter', 'Noto Sans Bengali', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* Layout */
  --rail-width:   72px;
  --rail-width-expanded: 260px;
  --topbar-height: 64px;
  --radius: 0.75rem;
  --radius-sm: 0.5rem;
  --shadow-card: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-elevated: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text-primary);
  background: var(--content-bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.01em;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* Focus visibility for accessibility */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   App Shell
   ============================================================ */

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---- Command Rail (signature element) ---- */
.command-rail {
  width: var(--rail-width);
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width 0.2s ease;
  overflow: hidden;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.command-rail:hover,
.command-rail.expanded {
  width: var(--rail-width-expanded);
}

.rail-brand {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  flex-shrink: 0;
}

.rail-brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #818CF8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.rail-brand-text {
  font-family: var(--font-display);
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.command-rail:hover .rail-brand-text,
.command-rail.expanded .rail-brand-text {
  opacity: 1;
}

.rail-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 0;
}

.rail-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
  padding: 16px 20px 6px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.command-rail:hover .rail-section-label,
.command-rail.expanded .rail-section-label {
  opacity: 1;
}

.rail-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 20px;
  color: var(--text-on-dark);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  border-left: 3px solid transparent;
  transition: background 0.12s ease, color 0.12s ease;
  position: relative;
}

.rail-item:hover {
  background: var(--bg-base-2);
  color: var(--text-on-dark-active);
}

.rail-item.active {
  background: var(--bg-base-2);
  color: var(--text-on-dark-active);
  border-left-color: var(--accent);
}

.rail-item-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.rail-item-label {
  opacity: 0;
  transition: opacity 0.15s ease;
}

.command-rail:hover .rail-item-label,
.command-rail.expanded .rail-item-label {
  opacity: 1;
}

/* Module status pulse dot */
.rail-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-left: auto;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.command-rail:hover .rail-status-dot,
.command-rail.expanded .rail-status-dot {
  opacity: 1;
}

.rail-status-dot.status-active {
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.7);
  animation: pulse-status 2s infinite;
}

.rail-status-dot.status-warning {
  background: var(--warning);
}

.rail-status-dot.status-inactive {
  background: #475569;
}

@keyframes pulse-status {
  0%   { box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.5); }
  70%  { box-shadow: 0 0 0 5px rgba(13, 148, 136, 0); }
  100% { box-shadow: 0 0 0 0 rgba(13, 148, 136, 0); }
}

.rail-footer {
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 12px 0;
  flex-shrink: 0;
}

/* ---- Main column ---- */
.main-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-height);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-breadcrumb {
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.topbar-breadcrumb strong {
  color: var(--text-primary);
  font-weight: 600;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.topbar-icon-btn:hover {
  background: var(--content-bg);
  color: var(--text-primary);
}

.lang-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
}

.lang-toggle a {
  padding: 6px 12px;
  color: var(--text-muted);
  transition: background 0.12s ease, color 0.12s ease;
}

.lang-toggle a.active {
  background: var(--accent);
  color: #fff;
}

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s ease;
}

.user-menu:hover { background: var(--content-bg); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

.user-menu-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.user-menu-name { font-size: 13px; font-weight: 600; }
.user-menu-role { font-size: 11px; color: var(--text-muted); }

/* ---- Content area ---- */
.content-area {
  flex: 1;
  padding: 24px;
}

.page-header {
  margin-bottom: 24px;
}

.page-title {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 4px;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}

/* ============================================================
   Components
   ============================================================ */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}

.card-body { padding: 20px; }

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-family: var(--font-display);
}

/* Stat widgets */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-card);
}

.stat-card-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 8px;
}

.stat-card-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}

.stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.stat-icon-indigo { background: var(--accent-soft); color: var(--accent); }
.stat-icon-teal   { background: var(--success-soft); color: var(--success); }
.stat-icon-amber  { background: var(--warning-soft); color: var(--warning); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  text-decoration: none;
}

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

.btn-secondary { background: var(--surface); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--content-bg); }

.btn-block { width: 100%; }

/* Forms */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-body);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

/* Alerts */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
  border: 1px solid transparent;
}

.alert-error { background: var(--danger-soft); color: var(--danger); border-color: #FECACA; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: #99F6E4; }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: #FDE68A; }

/* Toggle switch (for module enable/disable) */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #CBD5E1;
  border-radius: 24px;
  transition: background 0.2s ease;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s ease;
}

.toggle-switch input:checked + .toggle-slider { background: var(--success); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Module list (Master Admin) */
.module-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.module-row:last-child { border-bottom: none; }

.module-info { display: flex; flex-direction: column; gap: 2px; }
.module-name { font-weight: 600; font-size: 14px; }
.module-desc { font-size: 12px; color: var(--text-muted); }

/* ============================================================
   Auth pages
   ============================================================ */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  background-image: radial-gradient(circle at 20% 20%, rgba(79,70,229,0.25), transparent 50%),
                     radial-gradient(circle at 80% 80%, rgba(13,148,136,0.2), transparent 50%);
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-elevated);
  padding: 40px;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.auth-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 4px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0 0 28px;
}

.auth-footer-link {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--text-muted);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  text-transform: capitalize;
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger);  }
.badge-muted   { background: var(--content-bg);   color: var(--text-muted); border: 1px solid var(--border); }
.badge-accent  { background: var(--accent-soft);  color: var(--accent); }

/* Data table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--content-bg);
}

.data-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--content-bg); }

.data-table .cell-strong { font-weight: 600; }
.data-table .cell-muted { color: var(--text-muted); font-size: 13px; }
.data-table .cell-mono { font-family: var(--font-mono); font-size: 13px; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: var(--content-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.empty-state-title {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 4px;
}

.empty-state-text {
  font-size: 14px;
  margin: 0;
}

/* Filter tabs */
.filter-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.filter-tab {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.filter-tab:hover { color: var(--text-primary); }

.filter-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.filter-tab-count {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--content-bg);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.filter-tab.active .filter-tab-count {
  background: var(--accent-soft);
  color: var(--accent);
}

/* Detail page key-value rows */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.detail-row { display: flex; flex-direction: column; gap: 4px; }
.detail-label { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.detail-value { font-size: 15px; font-weight: 500; }

/* Outstanding balance banner */
.balance-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--bg-base), var(--bg-base-2));
  color: #fff;
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.balance-banner-label {
  font-size: 13px;
  color: var(--text-on-dark);
  margin-bottom: 4px;
}

.balance-banner-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
}

/* Ticket conversation thread */
.ticket-thread {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ticket-message {
  display: flex;
  gap: 12px;
  max-width: 85%;
}

.ticket-message.from-staff {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.ticket-message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

.ticket-message.from-customer .ticket-message-avatar {
  background: var(--content-bg);
  color: var(--text-muted);
}

.ticket-message.from-staff .ticket-message-avatar {
  background: var(--accent-soft);
  color: var(--accent);
}

.ticket-message-body {
  flex: 1;
}

.ticket-message-bubble {
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.ticket-message.from-customer .ticket-message-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
}

.ticket-message.from-staff .ticket-message-bubble {
  background: var(--accent-soft);
  border: 1px solid #C7D2FE;
}

.ticket-message-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  gap: 8px;
}

.ticket-message.from-staff .ticket-message-meta {
  justify-content: flex-end;
}

/* Inline select for staff ticket controls */
.ticket-control-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
}

.ticket-control-row .form-group {
  margin-bottom: 0;
  min-width: 160px;
}

.ticket-control-row .form-label {
  font-size: 11px;
}

@media (max-width: 640px) {
  .ticket-message { max-width: 100%; }
}

/* Progress bar */
.progress-bar { width: 100%; height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #818CF8); border-radius: 999px; transition: width 0.3s ease; }
.progress-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }

/* Milestones (timeline style) */
.milestone-list { display: flex; flex-direction: column; }
.milestone-item { display: flex; gap: 16px; padding-bottom: 24px; position: relative; }
.milestone-item:last-child { padding-bottom: 0; }
.milestone-item::before { content: ""; position: absolute; left: 11px; top: 28px; bottom: 0; width: 2px; background: var(--border); }
.milestone-item:last-child::before { display: none; }
.milestone-marker { width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; z-index: 1; font-size: 12px; }
.milestone-marker.completed { background: var(--success); color: #fff; }
.milestone-marker.in-progress { background: var(--accent); color: #fff; }
.milestone-marker.pending { background: var(--border); color: var(--text-muted); }
.milestone-content { flex: 1; padding-top: 1px; }
.milestone-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.milestone-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 4px; }
.milestone-due { font-size: 12px; color: var(--text-muted); }

/* Activity feed */
.activity-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.activity-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px; flex-shrink: 0; }
.activity-content { flex: 1; font-size: 14px; }
.activity-meta { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Kanban board */
.kanban-board { display: grid; grid-template-columns: repeat(4, minmax(260px, 1fr)); gap: 16px; overflow-x: auto; }
.kanban-column { background: var(--content-bg); border-radius: var(--radius); padding: 12px; min-height: 200px; }
.kanban-column-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; padding: 0 4px; }
.kanban-column-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); }
.kanban-column-count { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; font-size: 12px; font-weight: 600; padding: 2px 8px; color: var(--text-muted); }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px; margin-bottom: 10px; cursor: pointer; transition: box-shadow 0.12s ease, border-color 0.12s ease; }
.kanban-card:hover { box-shadow: var(--shadow-card); border-color: var(--accent); }
.kanban-card-title { font-size: 14px; font-weight: 600; margin-bottom: 8px; line-height: 1.4; }
.kanban-card-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kanban-card-assignee { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.kanban-card-due { font-size: 12px; color: var(--text-muted); }
.kanban-card-due.overdue { color: var(--danger); font-weight: 600; }

@media (max-width: 1024px) {
  .kanban-board { grid-template-columns: 1fr; }
}


@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}


@media (max-width: 768px) {
  .command-rail {
    position: fixed;
    left: -100%;
    width: var(--rail-width-expanded);
    transition: left 0.2s ease;
  }
  .command-rail.mobile-open {
    left: 0;
  }
  .content-area { padding: 16px; }
  .topbar { padding: 0 16px; }
}
