/* Functional module pages: stats, tables, toolbars (dark theme) */

/* ——— Workflow page shell (login-daily-plan, visit-customers, order-booking, collections, day-end) ——— */
body.sm-workflow-page {
  margin: 0;
  min-height: 100vh;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: #e2e8f0;
  background-color: #0b1220;
  background-image:
    radial-gradient(ellipse 120% 90% at 100% 0%, rgba(16, 185, 129, 0.18), transparent 55%),
    radial-gradient(ellipse 80% 60% at 0% 100%, rgba(59, 130, 246, 0.08), transparent 45%),
    linear-gradient(165deg, #0f172a 0%, #0c4c3e 48%, #042f2e 100%);
}

.sm-workflow-page .sh-top {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  background: rgba(15, 23, 42, 0.65);
}

.sm-workflow-page .sh-brand {
  font-weight: 800;
  color: #34d399;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sm-workflow-page .sh-brand:hover {
  color: #6ee7b7;
}

/* Visual workflow strip: five steps, current step highlighted */
.sm-workflow-rail {
  margin-bottom: 1.15rem;
  padding: 0.65rem 0.75rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sm-wf-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  justify-content: space-between;
  align-items: stretch;
  min-width: min-content;
}

.sm-wf-steps li {
  flex: 1 1 0;
  min-width: 4.5rem;
  max-width: 100%;
}

.sm-wf-steps a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  padding: 0.45rem 0.35rem;
  border-radius: 10px;
  text-decoration: none;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.sm-wf-steps a:hover {
  color: #f8fafc;
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.08);
}

.sm-wf-steps li.is-current a {
  color: #6ee7b7;
  border-color: rgba(52, 211, 153, 0.45);
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.18), rgba(15, 23, 42, 0.5));
  box-shadow: 0 0 0 1px rgba(16, 185, 129, 0.12);
}

.sm-wf-steps .sm-wf-num {
  font-size: 0.75rem;
  font-weight: 900;
  color: #94a3b8;
  line-height: 1;
}

.sm-wf-steps .sm-wf-name {
  line-height: 1.15;
  margin-top: 0.15rem;
}

.sm-wf-steps li.is-current .sm-wf-num {
  color: #34d399;
}

/* Page title block */
.sm-hero {
  margin-bottom: 1.35rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sm-hero h1 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.sm-hero h1 > i {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(16, 185, 129, 0.25), rgba(15, 23, 42, 0.8));
  border: 1px solid rgba(52, 211, 153, 0.25);
  font-size: 1.05rem;
}

/* Info / sync callouts */
.sm-info-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(56, 189, 248, 0.25);
  background: linear-gradient(135deg, rgba(14, 116, 144, 0.2), rgba(15, 23, 42, 0.65));
  font-size: 0.82rem;
  line-height: 1.45;
  color: #e2e8f0;
  margin-bottom: 1rem;
}

.sm-info-banner strong {
  color: #f8fafc;
}

.sm-info-banner i {
  margin-top: 0.1rem;
  color: #38bdf8;
  flex-shrink: 0;
}

/* Full-contacts + table CRM: green outline (matches field accent) */
#smOpenFullContacts {
  border-color: rgba(16, 185, 129, 0.65) !important;
  color: #6ee7b7 !important;
  background: transparent !important;
}

#smOpenFullContacts:hover {
  background: rgba(16, 185, 129, 0.12) !important;
  color: #ecfdf5 !important;
}

.sm-table-wrap .sm-btn-crm {
  border-color: rgba(16, 185, 129, 0.65) !important;
  color: #6ee7b7 !important;
  background: transparent !important;
}

.sm-table-wrap .sm-btn-crm:hover {
  background: rgba(16, 185, 129, 0.12) !important;
  color: #ecfdf5 !important;
}

.sm-module {
  max-width: 1040px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.75rem;
  flex: 1;
}

.sm-module h1 {
  font-size: 1.5rem;
  font-weight: 800;
  color: #f8fafc;
  margin: 0 0 0.4rem 0;
  letter-spacing: -0.02em;
}

.sm-module .sm-lead {
  color: #94a3b8;
  font-size: 0.92rem;
  margin-bottom: 1.25rem;
  line-height: 1.5;
}

.sm-stat-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

@media (min-width: 576px) {
  .sm-stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 992px) {
  .sm-stat-grid.sm-stat-3 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* Daily plan — four KPI tiles */
@media (min-width: 992px) {
  .sm-stat-grid.sm-stat-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 576px) and (max-width: 991px) {
  .sm-stat-grid.sm-stat-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

.sm-stat-grid .sm-stat-grid-full {
  grid-column: 1 / -1;
}

/* Loading skeletons */
.sm-skeleton {
  position: relative;
  overflow: hidden;
  background: rgba(148, 163, 184, 0.12);
  border-radius: 8px;
}

.sm-skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.06),
    transparent
  );
  animation: sm-shimmer 1.2s ease-in-out infinite;
}

@keyframes sm-shimmer {
  100% {
    transform: translateX(100%);
  }
}

.sm-stat-card.is-loading .sm-skeleton-label {
  height: 0.65rem;
  width: 55%;
  margin-bottom: 0.5rem;
}

.sm-stat-card.is-loading .sm-skeleton-value {
  height: 1.5rem;
  width: 70%;
}

/* Daily plan hero — date pill */
.sm-date-pill {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.35);
  background: rgba(16, 185, 129, 0.1);
}

.sm-greeting-line {
  font-size: 0.88rem;
  color: #94a3b8;
  margin-top: 0.35rem;
}

.sm-plan-meta {
  font-size: 0.72rem;
  color: #64748b;
  margin-top: 0.35rem;
  min-height: 1rem;
}

.sm-stat-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 1rem 1.15rem;
  border-top: 3px solid rgba(52, 211, 153, 0.45);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.sm-stat-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
}

.sm-stat-card .sm-stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-bottom: 0.35rem;
}

.sm-stat-card .sm-stat-value {
  font-size: 1.35rem;
  font-weight: 800;
  color: #6ee7b7;
  line-height: 1.2;
}

/* Fallback stats (from orders API) — Bootstrap .text-warning was overridden by green above */
.sm-stat-card .sm-stat-value.text-warning {
  color: #fbbf24 !important;
}

/* Day end — “Deeper reports” yellow highlight (matches field mockup) */
.sm-panel.sm-deeper-reports {
  border: 1px solid rgba(251, 191, 36, 0.45);
  background: linear-gradient(
    145deg,
    rgba(251, 191, 36, 0.12) 0%,
    rgba(255, 255, 255, 0.04) 55%
  );
  box-shadow: 0 4px 24px rgba(251, 191, 36, 0.08);
}

.sm-panel.sm-deeper-reports h2 {
  color: #fef3c7 !important;
  letter-spacing: 0.08em;
  padding: 0.4rem 0.65rem;
  margin: -0.35rem -0.65rem 0.75rem -0.65rem;
  border-radius: 10px;
  background: linear-gradient(90deg, rgba(251, 191, 36, 0.42), rgba(251, 191, 36, 0.08));
  border: 1px solid rgba(251, 191, 36, 0.35);
}

.sm-panel.sm-deeper-reports h2 i {
  color: #ca8a04 !important;
}

.sm-deeper-lead {
  color: rgba(254, 243, 199, 0.88) !important;
}

.sm-deeper-btn {
  background: #fbbf24 !important;
  color: #1c1917 !important;
  border: 1px solid #f59e0b !important;
  font-weight: 600;
}

.sm-deeper-btn:hover {
  background: #f59e0b !important;
  color: #0c0a09 !important;
}

.sm-btn-refresh-accent {
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.85), 0 4px 12px rgba(0, 0, 0, 0.2);
}

.sm-panel {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 1.2rem 1.3rem;
  margin-bottom: 1.05rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.sm-panel h2 {
  font-size: 0.8rem;
  font-weight: 700;
  color: #cbd5e1;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 0.85rem 0;
}

.sm-table-wrap {
  overflow-x: auto;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.sm-table-wrap table {
  margin-bottom: 0;
  font-size: 0.82rem;
}

.sm-table-wrap th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
  white-space: nowrap;
}

.sm-badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.sm-badge-success {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

.sm-badge-warn {
  background: rgba(245, 158, 11, 0.2);
  color: #fcd34d;
}

.sm-badge-muted {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
}

.sm-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.65rem 0.75rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(0, 0, 0, 0.18);
}

.sm-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.sm-toolbar input,
.sm-toolbar select {
  max-width: 100%;
}

.sm-empty {
  color: #94a3b8;
  font-size: 0.88rem;
  padding: 0.5rem 0;
}

.sm-step {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #6ee7b7;
  margin-bottom: 0.35rem;
}

@media print {
  .no-print {
    display: none !important;
  }

  body.sm-workflow-page {
    background: #fff !important;
    color: #111 !important;
  }

  .sm-workflow-page .sm-panel,
  .sm-workflow-page .sm-stat-card {
    border: 1px solid #ccc !important;
    background: #fff !important;
    color: #111 !important;
  }

  .sm-workflow-page .table-dark {
    --bs-table-bg: #fff;
    color: #111 !important;
  }
}
