/* Design Tokens & Theme Setup */
:root {
  --bg-dark: hsl(222, 25%, 8%);
  --bg-darker: hsl(222, 30%, 6%);
  --bg-card: hsla(223, 20%, 14%, 0.65);
  --bg-input: hsla(223, 25%, 10%, 0.8);
  
  --primary: hsl(263, 80%, 62%);
  --primary-hover: hsl(263, 85%, 68%);
  --primary-glow: hsla(263, 80%, 62%, 0.35);
  
  --secondary: hsl(215, 15%, 22%);
  --secondary-hover: hsl(215, 15%, 28%);
  
  --accent-cyan: hsl(190, 85%, 50%);
  --accent-green: hsl(142, 75%, 48%);
  --accent-green-glow: hsla(142, 75%, 48%, 0.25);
  --accent-orange: hsl(36, 95%, 52%);
  --accent-orange-glow: hsla(36, 95%, 52%, 0.25);
  --accent-red: hsl(350, 80%, 55%);
  --accent-red-glow: hsla(350, 80%, 55%, 0.25);
  --accent-blue: hsl(210, 80%, 60%);
  --accent-blue-glow: hsla(210, 80%, 60%, 0.25);
  
  --border-color: hsla(223, 15%, 30%, 0.3);
  --border-focus: hsla(263, 80%, 62%, 0.6);
  
  --text-main: hsl(210, 25%, 96%);
  --text-muted: hsl(215, 12%, 68%);
  --text-dark: hsl(220, 15%, 15%);
  
  --font-main: 'Outfit', sans-serif;
  --transition-speed: 0.25s;
}

/* Global Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  font-family: var(--font-main);
  overflow-x: hidden;
  height: 100vh;
}

/* Scrollbar Customization */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-darker);
}
::-webkit-scrollbar-thumb {
  background: var(--secondary);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--primary);
}

/* Layout App Container */
.app-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

/* Sidebar Styling */
.sidebar {
  width: 260px;
  background-color: var(--bg-darker);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  flex-shrink: 0;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 40px;
  padding: 0 8px;
}

.logo-icon {
  font-size: 24px;
  color: var(--primary);
  filter: drop-shadow(0 0 8px var(--primary-glow));
}

.logo-text {
  display: flex;
  flex-direction: column;
}

.logo-title {
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.5px;
}

.logo-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 12px 16px;
  border-radius: 8px;
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-speed) ease;
  width: 100%;
  text-align: left;
}

.nav-item:hover {
  color: var(--text-main);
  background-color: hsla(223, 15%, 30%, 0.15);
}

.nav-item.active {
  color: var(--text-main);
  background-color: var(--primary);
  box-shadow: 0 4px 15px var(--primary-glow);
}

.nav-item i {
  font-size: 16px;
  width: 20px;
}

.external-link-icon {
  font-size: 11px !important;
  margin-left: auto;
  opacity: 0.6;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 8px;
  border-top: 1px solid var(--border-color);
  font-size: 12px;
  color: var(--text-muted);
}

.footer-status-item, .footer-commit-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.footer-commit-item {
  font-family: monospace;
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  font-size: 11px;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-indicator.online {
  background-color: var(--accent-green);
  box-shadow: 0 0 8px var(--accent-green);
}

/* Main Content Wrapper */
.main-content {
  flex-grow: 1;
  padding: 32px;
  overflow-y: auto;
  background-image: radial-gradient(circle at 80% 10%, hsla(263, 80%, 62%, 0.05), transparent 50%);
}

/* Tab Management */
.tab-content {
  display: none;
  animation: fadeIn 0.4s ease;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Header Areas */
.content-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 28px;
}

.content-header h1 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}

.content-header p {
  color: var(--text-muted);
  font-size: 14px;
}

.header-actions {
  display: flex;
  gap: 12px;
}

/* Premium Buttons styling */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 14px;
  padding: 10px 20px;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
}

.btn-primary {
  background-color: var(--primary);
  color: var(--text-main);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 18px var(--primary-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--secondary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--secondary-hover);
  transform: translateY(-1px);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: 6px;
}

.btn-danger {
  background-color: hsla(350, 80%, 55%, 0.15);
  color: var(--accent-red);
  border: 1px solid hsla(350, 80%, 55%, 0.3);
}

.btn-danger:hover {
  background-color: var(--accent-red);
  color: var(--text-main);
  box-shadow: 0 4px 12px var(--accent-red-glow);
}

/* Glassmorphism Panel Wrapper */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.25);
  margin-bottom: 24px;
}

/* Filters Bar styling */
.filters-bar {
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  background-color: var(--bg-darker);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0 16px;
  height: 42px;
  flex-grow: 1;
  max-width: 480px;
  transition: all var(--transition-speed) ease;
}

.search-box:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-box i {
  color: var(--text-muted);
  margin-right: 12px;
}

.search-box input {
  background: none;
  border: none;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 14px;
  outline: none;
  width: 100%;
}

.filter-group {
  display: flex;
  gap: 12px;
}

.filter-group select,
.form-group select,
.form-group input:not([type="checkbox"]),
.form-group textarea {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 14px;
  padding: 0 16px;
  height: 42px;
  outline: none;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
}

.filter-group select:focus,
.form-group select:focus,
.form-group input:not([type="checkbox"]):focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Orders Table Styling */
.orders-table-wrapper {
  overflow-x: auto;
  padding: 12px;
}

.orders-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.orders-table th {
  padding: 16px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.orders-table td {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
  color: var(--text-main);
}

.orders-table tbody tr {
  transition: background-color var(--transition-speed) ease;
}

.orders-table tbody tr:hover {
  background-color: hsla(223, 15%, 30%, 0.1);
}

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

/* Order Fields details */
.order-num {
  font-weight: 700;
  color: var(--accent-cyan);
}

.order-date {
  font-size: 12px;
  color: var(--text-muted);
}

.customer-info {
  display: flex;
  flex-direction: column;
}

.customer-name {
  font-weight: 600;
}

.customer-phone {
  font-size: 12px;
  color: var(--text-muted);
}

.delivery-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--secondary);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}

.order-total {
  font-weight: 700;
}

/* Badges systems */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-paid {
  background-color: hsla(142, 75%, 48%, 0.15);
  color: var(--accent-green);
  border: 1px solid hsla(142, 75%, 48%, 0.3);
}

.badge-unpaid {
  background-color: hsla(350, 80%, 55%, 0.15);
  color: var(--accent-red);
  border: 1px solid hsla(350, 80%, 55%, 0.3);
}

/* Status Code Badges mapping */
.status-new {
  background-color: hsla(210, 80%, 60%, 0.15);
  color: var(--accent-blue);
  border: 1px solid hsla(210, 80%, 60%, 0.3);
  box-shadow: 0 0 10px var(--accent-blue-glow);
}

.status-processing, .status-processing_hold {
  background-color: hsla(270, 75%, 60%, 0.15);
  color: #a855f7;
  border: 1px solid hsla(270, 75%, 60%, 0.3);
}

.status-confirmed, .status-confirmed_by_merchant {
  background-color: hsla(190, 85%, 50%, 0.15);
  color: var(--accent-cyan);
  border: 1px solid hsla(190, 85%, 50%, 0.3);
}

.status-packed, .status-packing {
  background-color: hsla(170, 75%, 45%, 0.15);
  color: #14b8a6;
  border: 1px solid hsla(170, 75%, 45%, 0.3);
}

.status-sent {
  background-color: hsla(36, 95%, 52%, 0.15);
  color: var(--accent-orange);
  border: 1px solid hsla(36, 95%, 52%, 0.3);
  box-shadow: 0 0 10px var(--accent-orange-glow);
}

.status-completed, .status-received, .status-delivered {
  background-color: hsla(142, 75%, 48%, 0.15);
  color: var(--accent-green);
  border: 1px solid hsla(142, 75%, 48%, 0.3);
  box-shadow: 0 0 10px var(--accent-green-glow);
}

.status-canceled, .status-canceled_by_merchant, .status-completed_merchant_rejection, .status-closed_merchant_rejection {
  background-color: hsla(350, 80%, 55%, 0.15);
  color: var(--accent-red);
  border: 1px solid hsla(350, 80%, 55%, 0.3);
}

.status-closed, .status-returned, .status-return_requested {
  background-color: hsla(215, 15%, 22%, 0.5);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.actions-col {
  text-align: right !important;
}

.actions-cell {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.action-btn {
  background: none;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-speed) ease;
}

.action-btn:hover {
  color: var(--text-main);
  background-color: var(--secondary);
}

.action-btn.edit-btn:hover {
  border-color: var(--primary);
  color: var(--primary-hover);
}

.action-btn.delete-btn:hover {
  border-color: var(--accent-red);
  color: var(--accent-red);
}

.loading-state, .empty-state {
  text-align: center !important;
  padding: 40px !important;
  color: var(--text-muted) !important;
  font-size: 16px !important;
}

.loading-state i, .empty-state i {
  font-size: 24px;
  margin-bottom: 12px;
  display: block;
}

/* Raw JSON Textarea styling (bulk view + per-order modals) */
.json-editor-container {
  height: calc(100vh - 160px);
  padding: 16px;
  box-sizing: border-box;
}

.modal-container.json-mode .modal-body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.modal-container.json-mode .json-editor-container {
  height: auto;
  min-height: min(65vh, 640px);
  padding: 0;
  flex: 1 1 auto;
  min-width: 0;
}

.modal-container.json-mode .modal-footer {
  flex-shrink: 0;
}

.json-editor-container textarea {
  width: 100%;
  height: 100%;
  min-height: inherit;
  box-sizing: border-box;
  background-color: var(--bg-darker);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--accent-cyan);
  font-family: 'Courier New', Courier, monospace;
  font-size: 13px;
  line-height: 1.5;
  padding: 16px;
  resize: none;
  outline: none;
  transition: all var(--transition-speed) ease;
}

.modal-container.json-mode .json-editor-container textarea {
  min-height: min(65vh, 640px);
}

.json-editor-container textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 15px var(--primary-glow);
}

/* Modal Overlay & Drawer Layout */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-speed) ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform var(--transition-speed) ease, max-width var(--transition-speed) ease;
  overflow: hidden;
}

.modal-container.json-mode {
  max-width: min(1100px, 96vw);
}

.modal-overlay.active .modal-container {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h2 {
  font-size: 20px;
  font-weight: 700;
}

.close-modal-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 28px;
  cursor: pointer;
  transition: color var(--transition-speed) ease;
  line-height: 1;
}

.close-modal-btn:hover {
  color: var(--text-main);
}

.modal-body {
  overflow-y: auto;
  padding: 24px;
  flex-grow: 1;
}

.modal-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Form Tabs and Layouts inside modal */
.form-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
  padding-bottom: 2px;
}

.form-tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 10px 16px;
  font-family: var(--font-main);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-speed) ease;
}

.form-tab-btn:hover {
  color: var(--text-main);
}

.form-tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.form-tab-content {
  display: none;
}

.form-tab-content.active {
  display: block;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

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

.form-group.full-width {
  grid-column: span 2;
}

.form-group.flex-row {
  flex-direction: row;
  align-items: center;
  gap: 24px;
  height: 42px;
  margin-top: 26px;
}

.border-top {
  border-top: 1px solid var(--border-color);
  padding-top: 20px;
}

.pt-2 {
  padding-top: 8px;
}

.form-group label {
  font-size: 13px;
  font-weight: 550;
  color: var(--text-muted);
}

.form-group input:not([type="checkbox"]), .form-group select {
  width: 100%;
}

.form-group textarea {
  padding: 12px 16px;
  height: auto;
}

/* Checkbox specific styling */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  height: 42px;
  margin-top: 26px;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex-shrink: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.checkbox-group span,
.checkbox-group label {
  color: var(--text-main);
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  line-height: 1.2;
}

.items-section {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.items-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.items-section-header label {
  font-size: 13px;
  font-weight: 550;
  color: var(--text-muted);
  margin: 0;
}

.items-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.item-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 90px 40px;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: hsla(223, 20%, 6%, 0.35);
}

.item-row .form-group {
  gap: 6px;
  margin: 0;
}

.item-row .form-group label {
  font-size: 12px;
}

.item-remove-btn {
  height: 42px;
  width: 40px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-speed) ease;
}

.item-remove-btn:hover {
  color: #ff6b6b;
  border-color: #ff6b6b;
}

.btn-sm {
  padding: 8px 12px;
  font-size: 13px;
  height: auto;
}

/* Alternate receiver details drawer block */
.alternate-fields {
  background-color: hsla(223, 20%, 6%, 0.4);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  padding: 16px 20px 20px 20px;
  margin-top: 8px;
}

.alternate-fields h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-cyan);
  margin-bottom: 12px;
}

.hidden {
  display: none !important;
}

/* Dynamic products form table */
.products-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.products-list-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.products-table-container {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
  max-height: 240px;
  overflow-y: auto;
}

.products-form-table {
  width: 100%;
  border-collapse: collapse;
}

.products-form-table th {
  background-color: var(--bg-darker);
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.products-form-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color);
}

.products-form-table tbody tr:last-child td {
  border-bottom: none;
}

.products-form-table input {
  height: 34px !important;
  padding: 0 10px !important;
  font-size: 13px !important;
  border-radius: 6px !important;
}

.order-summary-panel {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background-color: hsla(263, 80%, 62%, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 8px;
}

.summary-label {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

.summary-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-green);
  text-shadow: 0 0 8px var(--accent-green-glow);
}

/* Inline Table Controls styling */
.inline-status-select {
  border-radius: 20px !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: 0.5px !important;
  padding: 0 8px !important;
  height: 28px !important;
  text-align: center !important;
  width: auto !important;
  min-width: 170px;
}

.inline-status-select option {
  background-color: var(--bg-darker) !important;
  color: var(--text-main) !important;
  font-weight: normal !important;
}

