/* ==========================================================================
   Stock Management V1 - iOS-Inspired Minimal Design System
   Black & White Brand Palette: White cards, black primary buttons, subtle gray borders
   ========================================================================== */

/* --------------------------------------------------------------------------
   Sidebar Collapsible Stock Management & Removal of Deprecated Options
   -------------------------------------------------------------------------- */
.sidebar-bg a.router-link[href*="ingredients"],
.sidebar-bg .router-link.router-link-desktop[href*="ingredients"],
.sidebar-bg .router-link.router-link-mobile[href*="ingredients"],
a.router-link[href*="/admin/ingredients"],
a.router-link[href*="ingredients"],
.sidebar-bg a.router-link[href*="modifiers"],
a.router-link[href*="/admin/modifiers"],
a.router-link[href*="modifiers"],
.sidebar-bg a.router-link[href*="expense-types"],
a.router-link[href*="/admin/expense-types"],
a.router-link[href*="expense-types"],
.sidebar-bg a.router-link[href*="expenses"],
a.router-link[href*="/admin/expenses"],
a.router-link[href*="expenses"],
.sidebar-bg a.router-link[href*="expense-report"],
a.router-link[href*="/admin/expense-report"] {
  display: none !important;
}

.sm-collapsible-group {
  margin: 2px 10px !important;
}

.sm-header-row {
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  padding: 9.5px 14px !important;
  border-radius: 12px !important;
  cursor: pointer !important;
  user-select: none !important;
  font-size: 13.5px !important;
  font-weight: 600 !important;
  color: #64748b !important;
  background-color: transparent !important;
  transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out !important;
  box-sizing: border-box !important;
}

.sm-header-row:hover {
  background-color: #f1f5f9 !important;
  color: #0f172a !important;
}

.sm-header-row:hover .sm-side-icon,
.sm-header-row:hover .sm-chevron {
  color: #0f172a !important;
  stroke: #0f172a !important;
}

.sm-header-row.is-active {
  color: #1e293b !important;
}

.sm-header-left {
  display: flex !important;
  align-items: center !important;
  gap: 12px !important;
}

.sm-side-icon {
  width: 17px !important;
  height: 17px !important;
  min-width: 17px !important;
  color: #64748b !important;
  stroke: #64748b !important;
  fill: none !important;
  margin: 0 !important;
  display: inline-block !important;
  vertical-align: middle !important;
  transition: color 0.15s ease, stroke 0.15s ease !important;
}

.sm-header-title {
  font-size: 13.5px !important;
  font-weight: 600 !important;
  color: inherit !important;
  letter-spacing: -0.01em !important;
  line-height: 1 !important;
}

.sm-chevron {
  width: 15px !important;
  height: 15px !important;
  min-width: 15px !important;
  color: #94a3b8 !important;
  stroke: currentColor !important;
  display: inline-block !important;
  transform: rotate(0deg) !important;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), color 0.15s ease !important;
  transform-origin: center center !important;
}

.sm-chevron.expanded {
  transform: rotate(90deg) !important;
}

.sm-sub-container {
  margin-left: 22px !important;
  padding-left: 12px !important;
  border-left: 1.5px solid #e2e8f0 !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 3px !important;
  overflow: hidden !important;
  transition: max-height 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease, margin 0.25s ease !important;
}

.sm-sub-container.collapsed {
  max-height: 0 !important;
  opacity: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  pointer-events: none !important;
}

.sm-sub-container.expanded {
  max-height: 400px !important;
  opacity: 1 !important;
  margin-top: 4px !important;
  margin-bottom: 6px !important;
  pointer-events: auto !important;
}

.sm-sub-item {
  cursor: pointer !important;
  font-size: 13px !important;
  font-weight: 500 !important;
  color: #64748b !important;
  padding: 7px 12px !important;
  border-radius: 10px !important;
  transition: background-color 0.15s ease, color 0.15s ease !important;
  user-select: none !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
}

.sm-sub-item:not(.active):hover {
  background-color: #f8fafc !important;
  color: #0f172a !important;
}

.sm-sub-item.active {
  background-color: #0f172a !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.15) !important;
}

.sm-sub-badge {
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9999px;
  background-color: #ef4444;
  color: #ffffff;
  line-height: 1.3;
}

.sm-sub-item.active .sm-sub-badge {
  background-color: #ffffff;
  color: #ef4444;
}

/* --------------------------------------------------------------------------
   Root Container & Page Header (Smooth Full Scrollability)
   -------------------------------------------------------------------------- */
.sm-root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #0f172a;
  background-color: #f8fafc;
  flex: 1 1 0% !important;
  height: calc(100vh - 64px) !important;
  max-height: calc(100vh - 64px) !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  scroll-behavior: smooth !important;
  box-sizing: border-box !important;
  padding: 24px 28px 96px 28px !important;
}

/* Custom Scrollbar for sm-root */
.sm-root::-webkit-scrollbar {
  width: 8px;
}
.sm-root::-webkit-scrollbar-track {
  background: #f1f5f9;
}
.sm-root::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.sm-root::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Ensure layout containers allow scrolling */
body:has(.sm-root) main,
body:has(.sm-root) .flex-1.overflow-hidden,
body:has(.sm-root) .layout-bg main {
  overflow-y: auto !important;
}

.sm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.sm-title-group h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #0f172a;
  margin: 0;
  line-height: 1.2;
}

.sm-title-group p {
  font-size: 13px;
  color: #64748b;
  margin: 4px 0 0 0;
}

.sm-actions-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   iOS-Inspired Cards
   -------------------------------------------------------------------------- */
.sm-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  padding: 20px 24px;
  margin-bottom: 24px;
  transition: border-color 0.15s ease;
}

.sm-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f1f5f9;
}

.sm-card-title {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.01em;
  margin: 0;
}

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

.sm-stat-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 104px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.sm-stat-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

.sm-stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sm-stat-value {
  font-size: 26px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.03em;
  margin-top: 8px;
  line-height: 1;
}

.sm-stat-sub {
  font-size: 12px;
  color: #64748b;
  margin-top: 6px;
  font-weight: 500;
}

.sm-stat-card.is-alert {
  border-color: #fed7aa;
  background: linear-gradient(180deg, #fffaf5 0%, #ffffff 100%);
}

.sm-stat-card.is-alert .sm-stat-value {
  color: #ea580c;
}

/* --------------------------------------------------------------------------
   Full-Width Clean Tables
   -------------------------------------------------------------------------- */
.sm-table-container {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sm-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
  font-size: 13.5px;
}

.sm-table th {
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  background-color: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

.sm-table th:first-child {
  border-top-left-radius: 10px;
}

.sm-table th:last-child {
  border-top-right-radius: 10px;
}

.sm-table td {
  padding: 14px 16px;
  color: #1e293b;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  transition: background-color 0.1s ease;
}

.sm-table tr:last-child td {
  border-bottom: none;
}

.sm-table tr:hover td {
  background-color: #f8fafc;
}

.sm-table .text-right {
  text-align: right;
}

.sm-table .text-center {
  text-align: center;
}

/* --------------------------------------------------------------------------
   Badges & Indicators
   -------------------------------------------------------------------------- */
.sm-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.sm-badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  display: inline-block;
}

.sm-badge-ok {
  background-color: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.sm-badge-ok .sm-badge-dot { background-color: #22c55e; }

.sm-badge-low {
  background-color: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}
.sm-badge-low .sm-badge-dot { background-color: #f59e0b; }

.sm-badge-out {
  background-color: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}
.sm-badge-out .sm-badge-dot { background-color: #ef4444; }

.sm-badge-neutral {
  background-color: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.sm-badge-neutral .sm-badge-dot { background-color: #94a3b8; }

.sm-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  text-transform: capitalize;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.sm-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 10px;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  text-decoration: none;
  user-select: none;
  line-height: 1.3;
}

.sm-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed !important;
}

.sm-btn-primary {
  background-color: #0f172a;
  color: #ffffff;
}
.sm-btn-primary:hover:not(:disabled) {
  background-color: #1e293b;
  transform: translateY(-0.5px);
}

.sm-btn-secondary {
  background-color: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
}
.sm-btn-secondary:hover:not(:disabled) {
  background-color: #f8fafc;
  border-color: #94a3b8;
}

.sm-btn-ghost {
  background-color: transparent;
  color: #475569;
}
.sm-btn-ghost:hover:not(:disabled) {
  background-color: #f1f5f9;
  color: #0f172a;
}

.sm-btn-danger-ghost {
  background-color: transparent;
  color: #e11d48;
}
.sm-btn-danger-ghost:hover:not(:disabled) {
  background-color: #fff1f2;
}

.sm-btn-action {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 8px;
  background-color: #0f172a;
  color: #ffffff;
  border: none;
  cursor: pointer;
  transition: all 0.15s ease;
}
.sm-btn-action:hover {
  background-color: #1e293b;
}

.sm-btn-action-outline {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 8px;
  background-color: #ffffff;
  color: #0f172a;
  border: 1px solid #cbd5e1;
  cursor: pointer;
}
.sm-btn-action-outline:hover {
  background-color: #f8fafc;
  border-color: #94a3b8;
}

/* --------------------------------------------------------------------------
   Form Controls
   -------------------------------------------------------------------------- */
.sm-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}

.sm-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sm-form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: #334155;
  letter-spacing: -0.01em;
}

.sm-input,
.sm-select {
  width: 100%;
  height: 40px;
  padding: 8px 13px;
  font-size: 13.5px;
  color: #0f172a;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  transition: all 0.15s ease;
  box-sizing: border-box;
}

.sm-input:focus,
.sm-select:focus {
  outline: none;
  border-color: #0f172a;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.sm-input::placeholder {
  color: #94a3b8;
}

.sm-textarea {
  width: 100%;
  padding: 10px 13px;
  font-size: 13.5px;
  color: #0f172a;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  transition: all 0.15s ease;
  min-height: 74px;
  box-sizing: border-box;
  font-family: inherit;
  resize: vertical;
}

.sm-textarea:focus {
  outline: none;
  border-color: #0f172a;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.sm-calc-banner {
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.sm-calc-label {
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
}

.sm-calc-value {
  font-size: 20px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.02em;
}

/* --------------------------------------------------------------------------
   Filter Pills & Search Bar
   -------------------------------------------------------------------------- */
.sm-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.sm-filter-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.sm-pill {
  padding: 6px 13px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 9999px;
  background-color: #f1f5f9;
  color: #475569;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.sm-pill:hover {
  background-color: #e2e8f0;
  color: #0f172a;
}

.sm-pill.active {
  background-color: #0f172a;
  color: #ffffff;
}

.sm-search-box {
  position: relative;
  min-width: 220px;
  flex-grow: 1;
  max-width: 340px;
}

.sm-search-box input {
  width: 100%;
  height: 38px;
  padding: 7px 12px 7px 34px;
  font-size: 13px;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  color: #0f172a;
}

.sm-search-box input:focus {
  outline: none;
  border-color: #0f172a;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.sm-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: #94a3b8;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Modals (iOS Style with Blur)
   -------------------------------------------------------------------------- */
.sm-modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  padding: 16px;
  animation: smFadeIn 0.15s ease-out;
}

.sm-modal-card {
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 40px -10px rgba(15, 23, 42, 0.2);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  animation: smSlideUp 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.sm-modal-header {
  padding: 20px 24px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #f1f5f9;
}

.sm-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.sm-modal-body {
  padding: 20px 24px;
}

.sm-modal-footer {
  padding: 16px 24px 20px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid #f1f5f9;
}

/* --------------------------------------------------------------------------
   Toast Feedback Notification
   -------------------------------------------------------------------------- */
.sm-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: #0f172a;
  color: #ffffff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.3);
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 100000;
  animation: smSlideUp 0.2s ease-out;
}

.sm-toast.is-error {
  background-color: #e11d48;
}

/* --------------------------------------------------------------------------
   Empty States
   -------------------------------------------------------------------------- */
.sm-empty {
  padding: 48px 24px;
  text-align: center;
  color: #64748b;
}

.sm-empty-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  color: #94a3b8;
  display: block;
}

.sm-empty-title {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin: 0 0 4px;
}

.sm-empty-text {
  font-size: 13px;
  color: #64748b;
  margin: 0;
}

/* --------------------------------------------------------------------------
   Animations
   -------------------------------------------------------------------------- */
@keyframes smFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes smSlideUp {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* --------------------------------------------------------------------------
   Responsive Adjustments
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .sm-root {
    padding: 16px;
  }
  .sm-stat-grid {
    grid-template-columns: 1fr 1fr;
  }
  .sm-form-grid {
    grid-template-columns: 1fr;
  }
}
