/**
 * Layout - Spacing, dimensions, structure only.
 * No colors. No background. No border-color.
 * Colors are in theme.css only.
 */

:root {
  --header-height: 56px;
  --sidebar-width: 260px;
}

body,
.dashboard-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-container {
  max-width: 100%;
}

.dashboard-header {
  height: var(--header-height);
  padding: 0 1.25rem;
  box-shadow: var(--shadow-sm, 0 1px 4px rgba(0, 0, 0, 0.08));
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
}

.dashboard-header .btn-link {
  padding: 0;
}

.header-search-wrap {
  max-width: 320px;
}

.global-search-dropdown {
  max-height: 70vh;
  overflow-y: auto;
  border-radius: var(--radius-base);
  padding: 0.5rem;
}

.notifications-dropdown {
  min-width: 320px;
  max-width: 360px;
  max-height: 70vh;
  overflow-y: auto;
  border-radius: var(--radius-base);
}

.theme-toggle-btn {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-base);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Live-Chat sidebar badge ── */
.lc-sidebar-link {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
}
.lc-sidebar-link-label {
  display: flex;
  align-items: center;
  gap: 6px;
}
.lc-sidebar-badges {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
/* red filled — unread message count (sidebar) */
.sidebar-lc-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e53935;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(229,57,53,.45);
}
/* red pulsing — agent requested */
.sidebar-lc-agent-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dc2626;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  line-height: 18px;
  text-align: center;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(220,38,38,.5);
  animation: lc-agent-pulse 1.4s ease-in-out infinite;
}
@keyframes lc-agent-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.55); }
  50%       { box-shadow: 0 0 0 5px rgba(220,38,38,0); }
}

/* ── Live-Chat envelope icon in header ── */
.header-livechat-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-base);
  color: var(--text-secondary, #6c757d);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.header-livechat-btn:hover {
  background: var(--bg-hover, rgba(0,0,0,.06));
  color: var(--text-primary, #212529);
}
.header-livechat-btn .bi {
  font-size: 1.2rem;
}
.header-lc-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: #e53935;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 1px 4px rgba(229,57,53,.45);
}
/* pulse animation when new messages arrive */
@keyframes lc-badge-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); }
  100% { transform: scale(1); }
}
.header-lc-badge.lc-pop {
  animation: lc-badge-pop 0.3s ease;
}

.dashboard-body .d-flex {
  display: flex;
}

.dashboard-main {
  flex: 1;
  padding: 1.5rem;
  overflow: auto;
}

.dashboard-sidebar,
.sidebar {
  width: var(--sidebar-width);
  min-height: calc(100vh - var(--header-height));
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.sidebar-nav {
  padding: 1rem 0;
  flex: 1;
}

.sidebar-nav .nav-link,
.sidebar a {
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  border-radius: 0 var(--radius-base) var(--radius-base) 0;
  margin: 0 0.5rem 0 0;
}

.sidebar-nav-group {
  margin: 0 0.5rem 0 0;
}

.sidebar-nav-toggle {
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  border-radius: 0 var(--radius-base) var(--radius-base) 0;
}

.sidebar-nav-toggle .sidebar-nav-chevron {
  transition: transform 0.2s ease;
}

.sidebar-nav-toggle[aria-expanded="true"] .sidebar-nav-chevron {
  transform: rotate(180deg);
}

.sidebar-subnav {
  padding-right: 0.5rem;
  padding-left: 0.25rem;
}

.sidebar-subnav .nav-link {
  padding: 0.5rem 1rem;
  padding-inline-start: 2.25rem;
  font-size: 0.9rem;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  margin-top: auto;
}

.sidebar-footer-title {
  font-weight: 600;
  font-size: 0.95rem;
}

.sidebar-footer-user {
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.sidebar-footer .sidebar-minimize {
  text-decoration: none;
  font-size: 0.8rem;
  padding: 0.35rem 0;
  margin-top: 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.card,
.theme-card {
  padding: 0;
  overflow: hidden;
}

.card-header,
.theme-card-header {
  padding: 1rem 1.25rem;
  font-weight: 600;
  border-radius: var(--radius-base) var(--radius-base) 0 0;
}

.card-body {
  padding: 1.25rem;
}

.card-footer {
  padding: 1rem 1.25rem;
}

.dashboard-body .btn {
  border-radius: var(--radius-base);
  font-weight: 500;
}

.dashboard-body .btn:hover {
  transform: translateY(-1px);
}

.dashboard-body .table {
  border-collapse: separate;
  border-spacing: 0;
}

.dashboard-body .table thead th {
  padding: 0.85rem 1rem;
  font-weight: 600;
}

.dashboard-body .table tbody td {
  padding: 0.85rem 1rem;
  vertical-align: middle;
}

.dashboard-body .form-control,
.dashboard-body .form-select {
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-base);
}

.dashboard-body .badge {
  border-radius: var(--radius-base);
  font-weight: 500;
  padding: 0.35em 0.65em;
}

.breadcrumb-item + .breadcrumb-item::before {
  float: right;
}

.dashboard-body .breadcrumb {
  padding: 0;
  margin-bottom: 0.5rem;
}

.kpi-card {
  padding: 1.25rem;
  border-radius: var(--radius-base);
}

.kpi-card .kpi-num,
.kpi-card .kpi-value {
  font-size: 1.5rem;
  font-weight: 700;
}

.kanban-board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: 400px;
}

.kanban-column {
  border-radius: 20px;
  padding: 15px;
  min-width: 280px;
  max-width: 320px;
  flex-shrink: 0;
}

.kanban-column-title {
  font-weight: 600;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
}

.kanban-card {
  border-radius: var(--radius-base);
  padding: 1rem;
  margin-bottom: 0.75rem;
}

.kanban-card-img {
  max-height: 100px;
  object-fit: cover;
}

.order-form .theme-card {
  border-radius: var(--radius-base);
}

.order-form #itemsTable thead th {
  font-size: 0.875rem;
}

.order-form-summary-sticky {
  position: sticky;
  top: calc(var(--header-height) + 1rem);
}
.order-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.order-summary-total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.75rem;
  margin-top: 0.5rem;
  border-top: 2px solid var(--border-1);
}
.order-summary-total-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.order-attachment-preview-wrap.min-height-80 {
  min-height: 80px;
}

.order-form-attachment-preview {
  width: 80px;
  text-align: center;
}

.order-form-attachment-preview .order-form-preview-img {
  width: 100%;
  height: 60px;
  object-fit: cover;
  display: block;
}

.orders-filter-grid {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
}
.orders-filter-field {
  flex: 0 0 auto;
}
.orders-filter-search {
  min-width: 180px;
  flex: 1 1 220px;
  max-width: 320px;
}
.orders-filter-field .form-control,
.orders-filter-field .form-select {
  min-width: 120px;
  width: 100%;
}
.orders-filter-field input[type="date"] {
  min-width: 130px;
}
.orders-filter-field select.form-select {
  min-width: 130px;
}
.orders-filter-actions {
  flex: 0 0 auto;
  margin-right: auto;
}
.order-row-card {
  flex-wrap: wrap;
}
.order-row-link {
  flex: 1 1 100%;
  min-width: 0;
}
.order-row-controls {
  flex-shrink: 0;
}
@media (min-width: 768px) {
  .order-row-link {
    flex: 1 1 0;
  }
}
@media (max-width: 767.98px) {

  /* ═══ CARD SHELL ═══
     Column: [link area] then [action buttons row] */
  .order-row-card {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0.6rem 0.75rem 0.5rem;
  }

  /* ═══ LINK AREA ═══
     Row: [60px thumb] + [details — fills remaining width]
     overflow: visible is CRITICAL — overflow:hidden on a column-flex parent
     with flex:1 1 0 child causes the center zone to collapse to 0 height */
  .order-row-link {
    flex-direction: row;
    align-items: flex-start;
    gap: 0.65rem;
    order: 1;
    overflow: visible;
    flex: 1;
  }

  /* ═══ THUMBNAIL ═══ */
  .order-row-zone-right {
    flex: 0 0 auto;
    order: 1;
  }
  .order-row-thumb {
    width: 62px;
    height: 62px;
    border-radius: 8px;
  }
  .order-row-thumb-placeholder { font-size: 1.5rem; }

  /* ═══ DETAILS ZONE ═══
     flex:1 1 auto + min-width:0 so it grows without overflowing the card. */
  .order-row-zone-center {
    flex: 1 1 auto;
    overflow: visible;
    min-width: 0;
    max-width: 100%;
    order: 2;
    width: auto;
  }

  /* ═══ PRIMARY ROW: order# + total + quick status ═══ */
  .order-row-primary { gap: 0.35rem; flex-wrap: wrap; }
  .order-row-number  { font-size: 1rem; }
  .order-row-total   { font-size: 0.875rem; }
  .order-quick-status-badge {
    font-size: 0.67rem;
    max-width: 9.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* ═══ CUSTOMER ROW ═══ */
  .order-row-customer-row  { gap: 3px; flex-wrap: wrap; }
  .order-row-customer      { font-size: 0.875rem; }
  .order-row-customer-phone{ font-size: 0.75rem; }

  /* ═══ META / BADGES ═══ */
  .order-row-meta-row    { flex-wrap: wrap; gap: 3px; margin-top: 2px; }
  .order-row-meta-badges { flex-wrap: wrap; gap: 3px; }
  .order-row-meta-badges .badge { font-size: 0.67rem; padding: 2px 5px; }

  /* ═══ SHIPPING / NOTES / PAYMENT ROWS ═══ */
  .order-row-shipping-company  { max-width: 12ch; }
  .order-row-shipping-tracking { max-width: 15ch; }
  .order-row-notes             { font-size: 0.77rem; }
  .order-row-card .text-muted.small { font-size: 0.72rem; }

  /* ═══ ACTION BUTTONS ═══
     Horizontal row of small buttons below the link area */
  .order-row-controls {
    order: 2;
    margin-inline-start: 0;
    padding-inline-start: 0 !important;
    border-inline-start: none !important;
    padding-top: 0.45rem;
    border-top: 1px solid var(--border-1);
    margin-top: 0.45rem;
  }
  .order-row-actions {
    flex-direction: row;
    justify-content: flex-end;
    gap: 0.4rem;
    flex-wrap: wrap;
  }
  .order-row-actions .btn {
    font-size: 0.8rem;
    padding: 3px 12px;
  }

  /* ═══ CHECKBOX (closing mode) ═══ */
  .order-row-checkbox {
    align-self: flex-start;
    margin-top: 2px;
  }
}
.order-view-header-top {
  flex-direction: column;
}
.order-view-header-right {
  width: 100%;
  align-items: flex-start;
}
.order-view-stats {
  width: 100%;
  justify-content: space-between;
}
.order-view-actions {
  width: 100%;
  justify-content: flex-start;
}
@media (min-width: 992px) {
  .order-view-header-top {
    flex-direction: row;
  }
  .order-view-header-right {
    width: auto;
    align-items: flex-end;
  }
  .order-view-stats {
    width: auto;
    justify-content: flex-end;
  }
  .order-view-actions {
    width: auto;
    justify-content: flex-end;
  }
}

.order-view-header .card-body,
.order-detail-header-saas .card-body {
  padding: 1.5rem;
}
.order-detail-image-wrapper,
.order-detail-image-placeholder {
  width: 120px;
  height: 120px;
  flex-shrink: 0;
}
.order-detail-stat {
  display: flex;
  flex-direction: column;
}
.order-info-list {
  display: flex;
  flex-direction: column;
}
.order-info-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
.order-attachments-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}
@media (max-width: 768px) {
  .order-attachments-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
  }
}
.order-attachment-card {
  display: flex;
  flex-direction: column;
}
.order-attachment-thumb-btn {
  position: relative;
  display: block;
}
.order-attachment-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.order-attachment-thumb-img {
  width: 100%;
  height: 120px;
  object-fit: cover;
}
.order-attachment-file-icon {
  display: block;
  margin: 0 auto;
}
.order-summary-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.order-form-products-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.order-form-products-bar .product-search-wrap {
  flex: 1;
  min-width: 200px;
}
.order-card-header h5,
.order-card-header .h5 {
  display: flex;
  align-items: center;
  margin: 0;
}
.order-form .card-header h5 {
  display: flex;
  align-items: center;
  margin: 0;
}

#orderAttachmentPreviewModal #orderPreviewImageWrap {
  padding: 1rem;
}
.order-preview-img {
  max-height: 75vh;
}
.order-preview-iframe {
  width: 100%;
  height: 75vh;
}

.card-form-narrow {
  max-width: 560px;
}

.card-form-medium {
  max-width: 600px;
}

.form-control-color-sq {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0.15rem;
}

.settings-icon {
  width: 2.5rem;
  height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.dashboard-body h1,
.dashboard-body .h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

.dashboard-body h2,
.dashboard-body .h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.dashboard-body h3,
.dashboard-body .h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.dashboard-body .lead-num {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.table-styled {
  border-radius: var(--radius-base);
  overflow: hidden;
}

.app-login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.app-login-card {
  width: 100%;
  max-width: 400px;
  overflow: hidden;
}

.app-login-header {
  padding: 1.5rem;
  text-align: center;
}

.select-width-auto {
  width: auto;
}

html[data-glass="1"] .dashboard-header,
[data-glass="1"] .dashboard-header {
  backdrop-filter: blur(8px);
}
html[data-glass="1"] .dashboard-sidebar,
[data-glass="1"] .dashboard-sidebar {
  backdrop-filter: blur(8px);
}

/* Compact mode: reduced spacing */
html[data-compact="1"] .dashboard-main {
  padding: 0.75rem 1rem;
}
html[data-compact="1"] .card-header,
html[data-compact="1"] .theme-card-header {
  padding: 0.6rem 1rem;
}
html[data-compact="1"] .card-body {
  padding: 0.75rem 1rem;
}
html[data-compact="1"] .card-footer {
  padding: 0.6rem 1rem;
}
html[data-compact="1"] .sidebar-nav .nav-link,
html[data-compact="1"] .sidebar a {
  padding: 0.5rem 1rem;
}
html[data-compact="1"] .sidebar-footer {
  padding: 0.6rem 1rem;
}
html[data-compact="1"] .dashboard-body .table thead th,
html[data-compact="1"] .dashboard-body .table tbody td {
  padding: 0.5rem 0.75rem;
}
html[data-compact="1"] .kpi-card {
  padding: 0.75rem 1rem;
}
html[data-compact="1"] .kanban-column {
  padding: 10px;
}
html[data-compact="1"] .kanban-card {
  padding: 0.6rem;
  margin-bottom: 0.5rem;
}

.theme-toast-wrap {
  z-index: 1100;
}

.maintenance-track-page {
  padding: 1.5rem;
}

@media (min-width: 768px) {
  .dashboard-body .dashboard-sidebar.collapse {
    display: flex;
  }
  .dashboard-body.sidebar-hidden .dashboard-sidebar {
    display: none;
  }
}

@media (max-width: 767.98px) {
  .dashboard-body .dashboard-sidebar {
    position: fixed;
    top: var(--header-height);
    right: 0;
    z-index: 1030;
    height: calc(100vh - var(--header-height));
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.2);
  }
  .dashboard-body .dashboard-sidebar.collapse:not(.show) {
    display: none;
  }
  .dashboard-body .dashboard-sidebar.collapse.show {
    display: flex;
  }
}
