/* Order Planning Styles */

/* =====================================================
   Order Planning Tab - Full Width Override
   ===================================================== */

#order-planning {
  margin: -1.5rem;
  padding: 1.5rem;
  width: calc(100% + 3rem);
  max-width: none;
}

/* =====================================================
   Order Planning Layout
   ===================================================== */

.order-planning-layout {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
  max-width: none;
}

.order-planning-main {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

.order-planning-sidebar {
  display: block;
  width: 100%;
  max-width: 100%;
}

/* =====================================================
   Order Grid Container
   ===================================================== */

.order-grid-container {
  background: white;
  border-radius: 8px;
  border: 1px solid #f0f0f0;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.order-grid-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #f0f0f0;
  background: #fafafa;
  flex-shrink: 0;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.toolbar-left h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #1a1a1a;
}

.month-badge {
  background: #3b82f6;
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  cursor: pointer;
}

.sort-select {
  padding: 0.5rem 0.75rem;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  font-size: 0.875rem;
  background: white;
  cursor: pointer;
}

.icon-btn {
  background: white;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: #f8f8f8;
  border-color: #d0d0d0;
}

/* =====================================================
   Order Grid Table
   ===================================================== */

.order-grid-scroll {
  flex: 1;
  overflow: auto;
  min-height: 0;
}

.order-grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  table-layout: fixed;
}

.order-grid-table thead {
  position: sticky;
  top: 0;
  background: #fafafa;
  z-index: 10;
}

.order-grid-table th {
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-weight: 600;
  color: #666;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 2px solid #e5e5e5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order-grid-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order-row:hover {
  background: #fafafa;
}

.order-row.phase-out {
  background: #fff9e6;
}

.order-row.phase-out:hover {
  background: #fff5d6;
}

/* Column widths - optimized to fit without scrolling */
.col-flavor { width: 15%; min-width: 120px; }
.col-status { width: 10%; min-width: 80px; }
.col-stock { width: 10%; min-width: 80px; }
.col-days { width: 8%; min-width: 70px; }
.col-consumption { width: 12%; min-width: 90px; }
.col-seasonal { width: 8%; min-width: 70px; }
.col-open-po { width: 8%; min-width: 70px; }
.col-recommended { width: 10%; min-width: 80px; }
.col-order { width: 12%; min-width: 100px; }
.col-warnings { width: 7%; min-width: 60px; }

/* =====================================================
   Table Cell Content
   ===================================================== */

.flavor-name {
  font-weight: 500;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.phase-out-badge {
  background: #fff3cd;
  color: #856404;
  padding: 0.125rem 0.5rem;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 600;
  border: 1px solid #ffeaa7;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

.stock-info,
.consumption-info,
.open-po-info,
.recommended-info {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.text-muted {
  color: #999;
  font-size: 0.8125rem;
}

.text-danger {
  color: #ef4444;
  font-weight: 600;
}

.text-warning {
  color: #f59e0b;
  font-weight: 600;
}

.text-success {
  color: #10b981;
  font-weight: 600;
}

/* =====================================================
   Order Input
   ===================================================== */

.order-input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.order-input {
  width: 70px;
  padding: 0.5rem;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  font-size: 0.875rem;
  text-align: center;
  transition: all 0.15s ease;
}

.order-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.order-input.edited {
  border-color: #f59e0b;
  background: #fffbeb;
  font-weight: 600;
}

.pan-size-badge {
  background: #e5e5e5;
  color: #666;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
}

.reset-btn {
  background: transparent;
  border: none;
  color: #666;
  cursor: pointer;
  padding: 0.25rem;
  transition: color 0.15s ease;
}

.reset-btn:hover {
  color: #3b82f6;
}

/* =====================================================
   Warnings
   ===================================================== */

.warnings-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.warning-item {
  font-size: 0.75rem;
  color: #666;
  line-height: 1.4;
}

/* =====================================================
   Order Summary Container
   ===================================================== */

.order-summary-container {
  background: white;
  border-radius: 8px;
  border: 1px solid #f0f0f0;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
  max-width: 100%;
}

.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.summary-header h3 {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.validation-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
}

.validation-status.valid {
  background: #d1fae5;
  color: #065f46;
}

.validation-status.invalid {
  background: #fee2e2;
  color: #991b1b;
}

/* =====================================================
   Summary Grid
   ===================================================== */

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: 0.5rem;
  width: 100%;
}

.summary-card {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.6rem;
  background: #fafafa;
  border-radius: 6px;
  border: 1px solid #f0f0f0;
  min-width: 0;
}

.summary-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border-radius: 5px;
  color: #666;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.summary-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.summary-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1.2;
  white-space: nowrap;
}

.summary-label {
  font-size: 0.75rem;
  color: #666;
  margin-top: 0.2rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.summary-sublabel {
  font-size: 0.7rem;
  margin-top: 0.15rem;
  color: #999;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* =====================================================
   Capacity Section
   ===================================================== */

.capacity-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.capacity-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.875rem;
}

.capacity-label {
  font-weight: 600;
  color: #666;
}

.capacity-value {
  font-weight: 600;
}

.capacity-bar {
  height: 24px;
  background: #f0f0f0;
  border-radius: 12px;
  overflow: hidden;
}

.capacity-fill {
  height: 100%;
  transition: width 0.3s ease;
  border-radius: 12px;
}

.capacity-remaining {
  font-size: 0.75rem;
  color: #666;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

/* =====================================================
   Stock Alerts & Validation
   ===================================================== */

.stock-alerts-section,
.config-info {
  padding-top: 1rem;
  border-top: 1px solid #f0f0f0;
}

.stock-alerts-section h4,
.config-info h4,
.validation-messages h4 {
  margin: 0 0 0.75rem 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: #666;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.alert-items {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.alert-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem;
  background: #fafafa;
  border-radius: 6px;
  font-size: 0.875rem;
}

.alert-badge {
  font-weight: 600;
}

.validation-messages {
  padding: 1rem;
  border-radius: 6px;
  font-size: 0.875rem;
}

.validation-messages.errors {
  background: #fee2e2;
  border: 1px solid #fecaca;
}

.validation-messages.warnings {
  background: #fef3c7;
  border: 1px solid #fde68a;
}

.validation-messages ul {
  margin: 0.5rem 0 0 1.5rem;
  padding: 0;
}

.validation-messages li {
  margin: 0.25rem 0;
}

/* =====================================================
   Config Grid
   ===================================================== */

.config-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.config-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
  padding: 0.5rem;
  background: #fafafa;
  border-radius: 4px;
}

.config-label {
  color: #666;
}

.config-value {
  font-weight: 600;
  color: #1a1a1a;
}

/* =====================================================
   Action Buttons
   ===================================================== */

.summary-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid #f0f0f0;
}

.btn-primary,
.btn-secondary {
  padding: 0.65rem 1rem;
  border: none;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 140px;
  white-space: nowrap;
}

.btn-primary {
  background: #3b82f6;
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #2563eb;
}

.btn-primary:disabled {
  background: #d1d5db;
  cursor: not-allowed;
}

.btn-secondary {
  background: white;
  color: #666;
  border: 1px solid #e5e5e5;
}

.btn-secondary:hover {
  background: #f8f8f8;
  border-color: #d0d0d0;
}

.btn-sm {
  padding: 0.5rem 0.75rem;
  font-size: 0.8125rem;
}

/* =====================================================
   Loading & Error States
   ===================================================== */

.loading-state,
.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  text-align: center;
  color: #666;
}

.loading-state i,
.error-state i {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.loading-state i {
  color: #3b82f6;
}

.error-state i {
  color: #ef4444;
}

/* =====================================================
   Responsive
   ===================================================== */

@media (max-width: 768px) {
  .order-grid-toolbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .toolbar-right {
    width: 100%;
    flex-wrap: wrap;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .summary-actions {
    flex-direction: column;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
  }

  .order-grid-table {
    font-size: 0.75rem;
  }

  .order-grid-table th,
  .order-grid-table td {
    padding: 0.4rem 0.5rem;
  }
}

/* =====================================================
   Configuration Modal Overrides
   ===================================================== */

.config-input {
  pointer-events: auto !important;
  background: white !important;
  cursor: text !important;
}

.config-input:focus {
  outline: none;
  border-color: #1a1a1a !important;
}

input[type="checkbox"].config-input {
  cursor: pointer !important;
}

/* =====================================================
   Multi-Store Order Planning Styles
   ===================================================== */

/* Store Selector Header */
.order-planning-header {
  background: white;
  border-radius: 8px;
  border: 1px solid #f0f0f0;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.store-selector-container {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.store-selector-container label {
  font-weight: 600;
  font-size: 0.95rem;
  color: #1a1a1a;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.store-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.store-selector {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  flex: 1;
}

.store-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.9rem;
}

.store-checkbox-label:hover {
  background: #e9ecef;
  border-color: #1a1a1a;
}

.store-checkbox-label input[type="checkbox"] {
  cursor: pointer;
  width: 16px;
  height: 16px;
}

.store-checkbox-label input[type="checkbox"]:checked + span {
  font-weight: 600;
  color: #1a1a1a;
}

.btn-sm {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
}

#toggleMultiStoreMode.active {
  background: #1a1a1a;
  color: white;
}

/* Multi-Store Grid */
.multi-store-grid-container {
  background: white;
  border-radius: 8px;
  border: 1px solid #f0f0f0;
  padding: 1.5rem;
}

.multi-store-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #f0f0f0;
}

.multi-store-header h3 {
  margin: 0;
  font-size: 1.25rem;
}

.store-count {
  font-size: 0.875rem;
  color: #666;
  margin-top: 0.25rem;
}

.target-coverage {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: #e8f5e9;
  border-radius: 6px;
  font-size: 0.9rem;
}

.target-coverage i {
  color: #2e7d32;
}

.target-coverage-editable {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem;
  background: #e8f5e9;
  border-radius: 6px;
  font-size: 0.9rem;
}

.target-coverage-editable label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  color: #2e7d32;
  margin: 0;
}

.target-date-input {
  padding: 0.5rem;
  border: 1px solid #2e7d32;
  border-radius: 4px;
  font-size: 0.875rem;
  background: white;
}

.store-names-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.store-name-badge {
  padding: 0.5rem 1rem;
  background: #1a1a1a;
  color: white;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 600;
}

/* Multi-Store Grid Table */
.multi-store-grid-scroll {
  overflow-x: auto;
  margin-top: 1rem;
}

.multi-store-grid-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.multi-store-grid-table thead th {
  background: #f8f9fa;
  padding: 0.75rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid #dee2e6;
  position: sticky;
  top: 0;
  z-index: 10;
}

.multi-store-grid-table .sticky-col {
  position: sticky;
  left: 0;
  background: white;
  z-index: 5;
  border-right: 2px solid #dee2e6;
}

.multi-store-grid-table thead .sticky-col {
  z-index: 15;
  background: #f8f9fa;
}

.multi-store-grid-table tbody tr {
  border-bottom: 1px solid #f0f0f0;
}

.multi-store-grid-table tbody tr:hover {
  background: #f8f9fa;
}

.multi-store-grid-table td {
  padding: 0.75rem;
}

.flavor-name-cell {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.stores-ordering-badge {
  font-size: 0.75rem;
  color: #666;
  font-weight: normal;
}

.store-order-cell {
  text-align: center;
}

.order-input-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.store-order-input {
  width: 70px;
  padding: 0.4rem;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  text-align: center;
  font-size: 0.875rem;
}

.store-order-input.edited {
  background: #fff3cd;
  border-color: #ffc107;
}

.pan-size-label {
  font-size: 0.75rem;
  color: #666;
}

.critical-badge {
  font-size: 0.75rem;
}

.no-order {
  text-align: center;
  color: #999;
}

.col-total {
  font-weight: 600;
  text-align: center;
  background: #f8f9fa;
}

.col-total-liters {
  font-weight: 600;
  text-align: center;
  background: #f8f9fa;
}

.totals-row {
  background: #e9ecef !important;
  font-weight: 700;
}

.totals-row td {
  padding: 1rem 0.75rem;
  border-top: 2px solid #dee2e6;
}

/* Multi-Store Summary */
.multi-store-summary-container {
  background: white;
  border-radius: 8px;
  border: 1px solid #f0f0f0;
  padding: 1.5rem;
}

.per-store-breakdown {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid #f0f0f0;
}

.per-store-breakdown h4 {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.store-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.store-breakdown-card {
  background: #f8f9fa;
  border-radius: 6px;
  padding: 1rem;
  border: 1px solid #e0e0e0;
}

.store-breakdown-header {
  font-weight: 600;
  margin-bottom: 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #dee2e6;
}

.store-breakdown-stats {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.stat-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.875rem;
}

.stat-label {
  color: #666;
}

.stat-value {
  font-weight: 600;
  color: #1a1a1a;
}

/* Liter-based ordering styles */
.order-input-wrapper-vertical {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.current-stock-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.35rem 0.5rem;
  background: #e3f2fd;
  border-radius: 4px;
  font-size: 0.75rem;
  width: 100%;
  border: 1px solid #bbdefb;
}

.stock-label {
  color: #1976d2;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.stock-value {
  color: #0d47a1;
  font-weight: 700;
  font-size: 0.8rem;
}

.liter-input-group {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.store-liter-input {
  width: 60px;
  padding: 0.4rem;
  border: 1px solid #dee2e6;
  border-radius: 4px;
  text-align: center;
  font-size: 0.875rem;
  font-weight: 600;
}

.store-liter-input.edited {
  background: #fff3cd;
  border-color: #ffc107;
}

.liter-label {
  font-size: 0.75rem;
  color: #666;
  font-weight: 600;
}

.pan-breakdown {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
  padding: 0.25rem;
  background: #f8f9fa;
  border-radius: 4px;
  min-height: 30px;
}

.pan-breakdown-empty {
  color: #999;
  font-size: 0.75rem;
}

.pan-size-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  background: white;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  padding: 0.15rem 0.4rem;
}

.pan-count-input {
  width: 35px;
  padding: 0.2rem;
  border: 1px solid #dee2e6;
  border-radius: 3px;
  text-align: center;
  font-size: 0.75rem;
}

.pan-size-label-small {
  font-size: 0.7rem;
  color: #666;
  font-weight: 600;
}

/* Multi-Store Orders Tab Styles */
.store-selector-multi {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem;
  background: #f8f9fa;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.store-selector-multi label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: white;
  border: 2px solid #dee2e6;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.store-selector-multi label:hover {
  border-color: #007bff;
  background: #f0f8ff;
}

.store-selector-multi input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

.store-selector-multi input[type="checkbox"]:checked + span {
  color: #007bff;
  font-weight: 600;
}
