/* ==========================================
   تم قرمز آرامش‌بخش برای کاربران حرفه‌ای - نسخه اصلاح‌شده
   ========================================== */

:root {
  /* رنگ‌های برند قرمز ملایم */
  --color-primary: #D32F2F;
  --color-primary-dark: #B71C1C;
  --color-secondary: #F5F5F5;
  --color-accent: #FF6B6B;
  --color-success: #4CAF50;
  --color-warning: #FF9800;
  --color-error: #F44336;
  
  /* رنگ‌های پس‌زمینه تیره */
  --bg-main: #121212;
  --bg-surface: #1E1E1E;
  --bg-surface-light: #2D2D2D;
  --bg-header: #0A0A0A;
  
  /* رنگ متن */
  --text-primary: #E0E0E0;
  --text-secondary: #B0B0B0;
  --text-disabled: #757575;
  
  /* سایه‌ها */
  --shadow-light: 0 2px 8px rgba(211, 47, 47, 0.15);
  --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.3);
  --shadow-heavy: 0 8px 32px rgba(0, 0, 0, 0.4);
  
  /* فواصل */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 24px;
  
  /* شعاع گوشه‌ها */
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  
  /* انیمیشن */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
}

/* ریست و فونت */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Vazirmatn', system-ui, -apple-system, sans-serif;
  background: var(--bg-main);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
}

.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 100%;
}

/* ==========================================
   هدر برند
   ========================================== */
.brand-header {
  background: var(--bg-header);
  padding: var(--spacing-lg) var(--spacing-xl);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 2px solid var(--color-primary);
  box-shadow: var(--shadow-medium);
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
  color: var(--color-primary);
}

.brand-logo i {
  font-size: 32px;
}

.brand-logo h1 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: var(--spacing-md);
}

.status-indicator {
  background: var(--bg-surface);
  color: var(--text-primary);
  padding: var(--spacing-sm) var(--spacing-lg);
  border-radius: var(--radius-md);
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--bg-surface-light);
}

/* ==========================================
   نوار ابزار اصلی
   ========================================== */
.main-toolbar {
  background: var(--bg-surface);
  padding: var(--spacing-lg) var(--spacing-xl);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-lg);
  border-bottom: 1px solid var(--bg-surface-light);
}

.toolbar-section {
  display: flex;
  gap: var(--spacing-md);
  flex-wrap: wrap;
}

/* دکمه‌ها */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md) var(--spacing-lg);
  border: none;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  user-select: none;
}

.btn i {
  font-size: 14px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* انواع دکمه */
.btn-primary {
  background: var(--color-primary);
  color: white;
  box-shadow: var(--shadow-light);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(211, 47, 47, 0.25);
}

.btn-success {
  background: var(--color-success);
  color: white;
}

.btn-success:hover:not(:disabled) {
  background: #43A047;
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-surface-light);
  color: var(--text-primary);
  border: 1px solid #444;
}

.btn-secondary:hover:not(:disabled) {
  background: #3D3D3D;
  transform: translateY(-1px);
}

.btn-warning {
  background: var(--color-warning);
  color: white;
}

.btn-warning:hover:not(:disabled) {
  background: #F57C00;
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--color-primary);
}

.btn-outline:hover:not(:disabled) {
  background: rgba(211, 47, 47, 0.1);
}

/* دکمه آیکونی */
.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface-light);
  color: var(--text-primary);
  border: 1px solid #444;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-icon:hover:not(:disabled) {
  background: var(--color-primary);
  color: white;
  transform: scale(1.1);
}

/* نشانگر تعداد تغییرات */
.badge {
  background: white;
  color: var(--color-primary);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: bold;
  min-width: 18px;
  text-align: center;
}

/* ==========================================
   نوار فرعی (صفحه‌بندی)
   ========================================== */
.sub-toolbar {
  background: var(--bg-surface);
  padding: var(--spacing-md) var(--spacing-xl);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--spacing-md);
  border-bottom: 1px solid var(--bg-surface-light);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.page-info {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 0 var(--spacing-md);
  min-width: 120px;
  text-align: center;
}

/* ==========================================
   بخش جدول
   ========================================== */
.table-container {
  flex: 1;
  overflow: hidden;
  padding: var(--spacing-lg) var(--spacing-xl);
}

.table-wrapper {
  height: 100%;
  overflow-x: auto;
  overflow-y: auto;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-heavy);
  border: 1px solid var(--bg-surface-light);
}

#ordersTable {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

#ordersTable th,
#ordersTable td {
  padding: var(--spacing-md) var(--spacing-sm);
  white-space: nowrap;
  border-bottom: 1px solid var(--bg-surface-light);
}

/* هدر چسبنده */
#ordersTable thead {
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-row th {
  background: var(--color-primary);
  color: white;
  font-weight: 700;
  text-align: center;
  padding: var(--spacing-lg) var(--spacing-sm);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.filter-row th {
  background: var(--color-primary-dark);
  padding: var(--spacing-md) var(--spacing-sm);
  position: sticky;
  top: 48px;
  z-index: 9;
}

/* فیلترها */
.filter-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  color: white;
  padding: var(--spacing-sm);
  font-size: 12px;
  transition: all var(--transition-fast);
}

.filter-input::placeholder {
  color: rgba(255, 255, 255, 0.7);
}

.filter-input:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.2);
  border-color: white;
}

/* ستون شماره ردیف */
.col-rownum {
  width: 50px;
  text-align: center;
  background: var(--bg-surface-light) !important;
  font-weight: 600;
  color: var(--color-primary);
}

/* ردیف‌های جدول */
#ordersTable tbody tr {
  transition: background-color var(--transition-fast);
}

#ordersTable tbody tr:nth-child(odd) td {
  background: var(--bg-surface);
}

#ordersTable tbody tr:nth-child(even) td {
  background: var(--bg-surface-light);
}

#ordersTable tbody tr:hover td {
  background: rgba(211, 47, 47, 0.1);
}

/* ردیف تغییر یافته */
.dirty-row td {
  background: rgba(255, 193, 7, 0.2) !important;
  border-left: 3px solid var(--color-warning);
}

/* انتخاب سلولی شبیه اکسل */
td.cell-selected {
  background: rgba(211, 47, 47, 0.25) !important;
  box-shadow: inset 0 0 0 2px var(--color-primary);
}

td.cell-anchor {
  box-shadow: inset 0 0 0 3px var(--color-primary);
}

/* ==========================================
   استایل مشترک برای select و textarea
   ========================================== */
select,
textarea {
  width: 100%;
  background: var(--bg-surface-light) !important;
  color: var(--text-primary) !important;
  border: 1px solid #444;
  border-radius: var(--radius-sm);
  padding: 4px;
  font-size: 12px;
  font-family: 'Vazirmatn', sans-serif;
  transition: all var(--transition-fast);
}

select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary) !important;
  box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.3);
}

select:hover,
textarea:hover {
  border-color: #666 !important;
}

/* استایل برای گزینه‌های select */
select option {
  background: var(--bg-surface) !important;
  color: var(--text-primary) !important;
  padding: 4px;
}

/* ==========================================
   رنگ‌بندی خاص سلول‌های Result
   ========================================== */
th.col-monitoring, 
td.col-monitoring {
    min-width: 100px;
}

th.col-problem, 
td.col-problem {
    min-width: 200px;
}

th.col-store_comment, 
td.col-store_comment {
    min-width: 210px;
}

th.col-snapp_comment, 
td.col-snapp_comment {
    min-width: 180px;
}

th.col-return_status, 
td.col-return_status {
    min-width: 140px;
}
th.col-product, 
td.col-product {
    width: 150px;
    max-width: 150px;
    white-space: nowrap; /* جلوگیری از شکستن متن */
    overflow: hidden; /* مخفی کردن اضافی */
    text-overflow: ellipsis; /* نقطه نقطه کردن اضافی */
}
th.col-product_change_title	, 
td.col-product_change_title	 {
    width: 150px;
    max-width: 150px;
    white-space: nowrap; /* جلوگیری از شکستن متن */
    overflow: hidden; /* مخفی کردن اضافی */
    text-overflow: ellipsis; /* نقطه نقطه کردن اضافی */
}
th.col-store_name, 
td.col-store_name {
    width: 250px !important;  /* عرض ثابت */
    max-width: 250px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* ==========================================
   پنجره اختلاف‌ها (Conflicts)
   ========================================== */
.conflict-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  direction: rtl;
  font-family: 'Vazirmatn', sans-serif;
}

.conflict-panel {
  background: var(--bg-surface);
  border: 1px solid var(--bg-surface-light);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  max-width: 1100px;
  width: 95%;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
  box-shadow: var(--shadow-heavy);
}

.conflict-header h3 {
  color: var(--color-primary);
  margin-bottom: var(--spacing-xs);
}

.conflict-header p {
  color: var(--text-secondary);
  font-size: 12px;
  margin-bottom: var(--spacing-md);
}

.conflict-table-wrapper {
  overflow: auto;
  border: 1px solid var(--bg-surface-light);
  border-radius: var(--radius-sm);
  flex: 1;
}

.conflict-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.conflict-table th {
  background: var(--color-primary);
  color: white;
  padding: 8px;
  position: sticky;
  top: 0;
  text-align: center;
}

.conflict-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--bg-surface-light);
}

.conflict-select {
  width: 100%;
  background: var(--bg-surface-light);
  color: var(--text-primary);
  border: 1px solid #444;
  border-radius: var(--radius-sm);
  padding: 2px 4px;
  font-size: 11px;
}

.conflict-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--spacing-sm);
  flex-wrap: wrap;
}

/* ==========================================
   نوتیفیکیشن کوچیک و گوشه‌ای - نسخه اصلاح‌شده
   ========================================== */
.notification {
  position: fixed;
  bottom: 10px; /* پایین گوشه */
  right: 10px; /* راست گوشه */
  background: rgba(0, 0, 0, 0.85); /* پس‌زمینه تیره‌تر */
  color: white;
  padding: 6px 10px; /* خیلی کوچیک */
  border-radius: 4px;
  font-size: 10px; /* فونت خیلی کوچیک */
  font-weight: 500;
  z-index: 10000;
  transform: translateY(100px); /* از پایین میاد */
  opacity: 0;
  transition: transform 0.2s ease, opacity 0.2s ease;
  max-width: 180px; /* عرض خیلی کم */
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  pointer-events: none; /* کلیک نخوره */
}

.notification.show {
  transform: translateY(0);
  opacity: 1;
}

.notification.success {
  background: rgba(76, 175, 80, 0.9);
  border-left: 2px solid var(--color-success);
}

.notification.warning {
  background: rgba(255, 152, 0, 0.9);
  border-left: 2px solid var(--color-warning);
}

.notification.error {
  background: rgba(244, 67, 54, 0.9);
  border-left: 2px solid var(--color-error);
}

/* ==========================================
   ریسپانسیو
   ========================================== */
@media (max-width: 768px) {
  .brand-header {
    padding: var(--spacing-md) var(--spacing-lg);
  }
  
  .brand-logo h1 {
    font-size: 16px;
  }
  
  .main-toolbar,
  .sub-toolbar {
    padding: var(--spacing-md) var(--spacing-lg);
  }
  
  .toolbar-section {
    width: 100%;
    justify-content: center;
  }
  
  .btn {
    font-size: 12px;
    padding: var(--spacing-sm) var(--spacing-md);
  }
  
  .table-container {
    padding: var(--spacing-md) var(--spacing-lg);
  }
  
  #ordersTable {
    font-size: 11px;
  }
  
  #ordersTable th,
  #ordersTable td {
    padding: var(--spacing-sm) var(--spacing-xs);
  }
  
  .notification {
    bottom: 5px;
    right: 5px;
    font-size: 9px;
    padding: 4px 8px;
  }
}
.divider {
  margin: 30px 0;
  border: none;
  border-top: 1px dashed #ccc;
}

.danger-title {
  color: #b71c1c;
  margin-bottom: 5px;
}

.danger-note {
  color: #666;
  font-size: 13px;
}

.delete-box {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.delete-input {
  flex: 1;
  padding: 8px;
  font-size: 14px;
}

.btn-danger {
  background: #c62828;
  color: #fff;
  border: none;
  padding: 8px 14px;
  cursor: pointer;
  border-radius: 4px;
}
/* ==========================================
   LIGHT THEME (Table = White / #F2F2F2, Text = Black)
   فعال‌سازی با: document.documentElement.dataset.theme = "light"
   ========================================== */

:root[data-theme="light"]{
  /* Brand stays the same */
  --bg-main: #F6F7F9;
  --bg-surface: #FFFFFF;
  --bg-surface-light: #F2F2F2;
  --bg-header: #FFFFFF;

  --text-primary: #111111;
  --text-secondary: #444444;
  --text-disabled: #888888;

  --shadow-light: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-medium: 0 6px 18px rgba(0,0,0,0.10);
  --shadow-heavy: 0 10px 30px rgba(0,0,0,0.12);
}

/* جدول: ردیف‌های سفید / F2F2F2 + متن تیره */
:root[data-theme="light"] #ordersTable tbody tr:nth-child(odd) td{
  background: #FFFFFF !important;
  color: var(--text-primary) !important;
}
:root[data-theme="light"] #ordersTable tbody tr:nth-child(even) td{
  background: #F2F2F2 !important;
  color: var(--text-primary) !important;
}

/* خطوط و جداکننده‌ها در لایت */
:root[data-theme="light"] .table-wrapper{
  border: 1px solid rgba(0,0,0,0.10);
}
:root[data-theme="light"] #ordersTable th,
:root[data-theme="light"] #ordersTable td{
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

/* ستون شماره ردیف (به خاطر !important باید override شود) */
:root[data-theme="light"] #ordersTable td.col-rownum{
  background: #EAEAEA !important;
  color: #111 !important;
}

/* فیلترهای هدر قرمز */
:root[data-theme="light"] #ordersTable thead tr.filters td{
  background: rgba(0,0,0,0.03);
}
:root[data-theme="light"] .filter-input{
  background: rgba(255,255,255,0.95) !important;
  color: #111 !important;
  border: 1px solid rgba(0,0,0,0.18) !important;
}
:root[data-theme="light"] .filter-input::placeholder{
  color: rgba(0,0,0,0.55) !important;
}

/* کنترل‌ها */
:root[data-theme="light"] select,
:root[data-theme="light"] textarea{
  background: #FFFFFF !important;
  color: #111111 !important;
  border: 1px solid rgba(0,0,0,0.18) !important;
}
:root[data-theme="light"] select:hover,
:root[data-theme="light"] textarea:hover{
  border-color: rgba(0,0,0,0.28) !important;
}
:root[data-theme="light"] select:focus,
:root[data-theme="light"] textarea:focus{
  border-color: var(--color-primary) !important;
  box-shadow: 0 0 0 3px rgba(211,47,47,0.18) !important;
}

/* Hover / انتخاب سلول / سطر تغییر کرده */
:root[data-theme="light"] #ordersTable tbody tr:hover td{
  background: rgba(211,47,47,0.06) !important;
}
:root[data-theme="light"] #ordersTable td.selected-cell{
  background: rgba(211,47,47,0.10) !important;
  color: #111 !important;
}
:root[data-theme="light"] #ordersTable tr.dirty-row td{
  background: rgba(255, 213, 79, 0.20) !important;
}
/* ======================================================
   THEME SYSTEM (Dark default / Light override)
   ====================================================== */

/* ---------- LIGHT MODE ---------- */
:root[data-theme="light"] {
  --bg-main: #F6F7F9;
  --bg-surface: #FFFFFF;
  --bg-surface-light: #F2F2F2;

  --text-primary: #111111;
  --text-secondary: #444444;
  --text-disabled: #888888;

  --shadow-light: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-medium: 0 6px 18px rgba(0,0,0,0.10);
}

/* جدول */
:root[data-theme="light"] #ordersTable tbody tr:nth-child(odd) td {
  background: #FFFFFF !important;
  color: #111 !important;
}
:root[data-theme="light"] #ordersTable tbody tr:nth-child(even) td {
  background: #F2F2F2 !important;
  color: #111 !important;
}

/* شماره ردیف */
:root[data-theme="light"] td.col-rownum {
  background: #EAEAEA !important;
  color: #111 !important;
}

/* hover */
:root[data-theme="light"] #ordersTable tbody tr:hover td {
  background: rgba(211, 47, 47, 0.06) !important;
}

/* سلول انتخاب شده */
:root[data-theme="light"] td.cell-selected {
  background: rgba(211,47,47,0.12) !important;
}

/* سطر تغییر کرده */
:root[data-theme="light"] tr.dirty-row td {
  background: rgba(255,213,79,0.22) !important;
}

/* فیلترها */
:root[data-theme="light"] .filter-input {
  background: #FFFFFF !important;
  color: #111 !important;
  border: 1px solid rgba(0,0,0,0.2) !important;
}
:root[data-theme="light"] .filter-input::placeholder {
  color: #666 !important;
}

/* select / textarea */
:root[data-theme="light"] select,
:root[data-theme="light"] textarea {
  background: #FFFFFF !important;
  color: #111 !important;
  border: 1px solid rgba(0,0,0,0.25) !important;
}

