/* ==============================================================================
   سترة (SUTRA) - الهوية البصرية ونظام التصميم المحاسبي الفاخر
   سِتْرٌ يَلِيقُ بِكِ | إشراف أ/عبدالرحمن مجدي
   ============================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Amiri:ital,wght@0,400;0,700;1,400&family=Tajawal:wght@300;400;500;700;800;900&display=swap');

:root {
  --primary: #5C3A21;           /* بني موكا فخم مستوحى من خط لوجو سترة */
  --primary-hover: #482D18;
  --primary-dark: #372111;
  --primary-light: #F7F1EA;     /* بيج كريمي هادئ */
  --primary-tint: #E8D8C8;

  --secondary: #A67538;         /* برونزي وذهبي معتق */
  --secondary-hover: #8C5E28;
  --secondary-light: #F9F2E7;

  --accent-gold: #C59B27;
  --bg-body: #FAF6F0;           /* خلفية رقيقة دافئة */
  --bg-card: #FFFFFF;
  --bg-subtle: #F3ECE2;
  
  --text-main: #261910;
  --text-body: #4A3A2F;
  --text-muted: #807064;
  --text-light: #A5968A;

  --border: #E8DDD2;
  --border-strong: #D5C2B1;

  --success: #2E7D32;
  --success-bg: #E8F5E9;
  --warning: #D97706;
  --warning-bg: #FEF3C7;
  --danger: #B91C1C;
  --danger-bg: #FEE2E2;
  --info: #1E6091;
  --info-bg: #E0F2FE;

  --shadow-sm: 0 1px 3px rgba(92, 58, 33, 0.06);
  --shadow-md: 0 4px 14px rgba(92, 58, 33, 0.08);
  --shadow-lg: 0 10px 25px rgba(92, 58, 33, 0.12);
  --shadow-float: 0 15px 35px rgba(92, 58, 33, 0.16);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --sidebar-width: 260px;
  --header-height: 70px;
  --bottom-nav-height: 64px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* إعادة الضبط والقواعد الأساسية */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Tajawal', sans-serif;
  background-color: var(--bg-body);
  color: var(--text-body);
  direction: rtl;
  text-align: right;
  line-height: 1.6;
  overflow-x: hidden;
  font-size: 15px;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.3;
}

.brand-font {
  font-family: 'Amiri', serif;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: var(--transition);
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* تخطيط التطبيق الرئيسي */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* الشريط الجانبي (Sidebar) */
.sidebar {
  width: var(--sidebar-width);
  background: #FFFFFF;
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  right: 0;
  z-index: 100;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.sidebar-brand {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #FFFFFF 0%, var(--primary-light) 100%);
}

.sidebar-brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  background: #FFFFFF;
  padding: 2px;
}

.brand-info h1 {
  font-size: 1.25rem;
  color: var(--primary);
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.brand-info p {
  font-size: 0.75rem;
  color: var(--secondary);
  font-weight: 500;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-section-title {
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-light);
  padding: 10px 12px 4px;
  letter-spacing: 0.5px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  color: var(--text-body);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
}

.nav-item i, .nav-item svg {
  width: 20px;
  height: 20px;
  stroke-width: 2;
  color: var(--text-muted);
  transition: var(--transition);
}

.nav-item:hover {
  background-color: var(--primary-light);
  color: var(--primary);
}

.nav-item:hover i, .nav-item:hover svg {
  color: var(--primary);
}

.nav-item.active {
  background-color: var(--primary);
  color: #FFFFFF;
  font-weight: 700;
  box-shadow: 0 4px 10px rgba(92, 58, 33, 0.25);
}

.nav-item.active i, .nav-item.active svg {
  color: #FFFFFF;
}

.nav-badge {
  margin-right: auto;
  background-color: var(--danger);
  color: #FFFFFF;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.nav-badge.warning {
  background-color: var(--warning);
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-body);
  text-align: center;
}

.supervisor-credit {
  font-size: 0.78rem;
  color: var(--primary-hover);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.supervisor-credit::before, .supervisor-credit::after {
  content: "•";
  color: var(--secondary);
}

.version-tag {
  font-size: 0.7rem;
  color: var(--text-light);
  margin-top: 3px;
}

/* المنطقة الرئيسية (Main Area) */
.main-wrapper {
  flex: 1;
  margin-right: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: var(--transition);
}

/* الهيدر العلوي (Top Header) */
.top-header {
  height: var(--header-height);
  background: #FFFFFF;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 90;
  box-shadow: var(--shadow-sm);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--primary);
  cursor: pointer;
  padding: 6px;
}

.page-title-box h2 {
  font-size: 1.25rem;
  color: var(--primary);
}

.page-title-box p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

/* مؤشر السحابة وجوجل شيت */
.cloud-status-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--bg-body);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: var(--transition);
}

.cloud-status-pill:hover {
  background: var(--primary-light);
  border-color: var(--border-strong);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background-color: #9CA3AF;
}

.status-dot.connected {
  background-color: var(--success);
  box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.2);
  animation: pulse 2s infinite;
}

.status-dot.local {
  background-color: var(--warning);
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* شارات التنبيه السريع */
.quick-alert-btn {
  position: relative;
  background: var(--bg-body);
  border: 1px solid var(--border);
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--primary);
  transition: var(--transition);
}

.quick-alert-btn:hover {
  background: var(--primary-light);
  color: var(--primary-hover);
}

.alert-badge {
  position: absolute;
  top: -4px;
  left: -4px;
  background-color: var(--danger);
  color: #FFFFFF;
  font-size: 0.65rem;
  font-weight: 800;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #FFFFFF;
}

/* زر المستخدم الحالي */
.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 6px;
  background: var(--primary-light);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  cursor: pointer;
}

.user-avatar {
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: #FFFFFF;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}

.user-meta {
  text-align: right;
  line-height: 1.2;
}

.user-meta .user-name {
  font-weight: 700;
  font-size: 0.82rem;
  color: var(--primary-dark);
}

.user-meta .user-role {
  font-size: 0.68rem;
  color: var(--secondary);
}

/* مساحة المحتوى (Content Area) */
.content-body {
  flex: 1;
  padding: 24px;
}

/* الصفحات (Views) */
.view-panel {
  display: none;
  animation: fadeIn 0.3s ease;
}

.view-panel.active {
  display: block;
}

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

/* بطاقات الإحصائيات (Stat Cards) */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.stat-card::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: var(--primary);
}

.stat-card.gold::after { background: var(--secondary); }
.stat-card.green::after { background: var(--success); }
.stat-card.red::after { background: var(--danger); }
.stat-card.blue::after { background: var(--info); }

.stat-content p {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.stat-content h3 {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
}

.stat-content .stat-sub {
  font-size: 0.72rem;
  color: var(--text-light);
  margin-top: 4px;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  background: var(--primary-light);
  color: var(--primary);
}

.stat-card.gold .stat-icon { background: var(--secondary-light); color: var(--secondary); }
.stat-card.green .stat-icon { background: var(--success-bg); color: var(--success); }
.stat-card.red .stat-icon { background: var(--danger-bg); color: var(--danger); }
.stat-card.blue .stat-icon { background: var(--info-bg); color: var(--info); }

/* البطاقات العامة (Generic Cards) */
.card {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  background: #FFFFFF;
}

.card-header h3 {
  font-size: 1.1rem;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.card-body {
  padding: 20px;
}

/* الأزرار (Buttons) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary);
  color: #FFFFFF;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 10px rgba(92, 58, 33, 0.25);
}

.btn-secondary {
  background-color: var(--secondary);
  color: #FFFFFF;
}

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

.btn-outline {
  background-color: transparent;
  border-color: var(--border-strong);
  color: var(--text-body);
}

.btn-outline:hover {
  background-color: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-excel {
  background-color: #107C41;
  color: #FFFFFF;
}

.btn-excel:hover {
  background-color: #0B5C30;
}

.btn-whatsapp {
  background-color: #25D366;
  color: #FFFFFF;
}

.btn-whatsapp:hover {
  background-color: #1EBE5D;
}

.btn-danger {
  background-color: var(--danger);
  color: #FFFFFF;
}

.btn-danger:hover {
  background-color: #991B1B;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* الجداول (Data Tables) */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: right;
}

.data-table th {
  background-color: var(--bg-subtle);
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 0.82rem;
  padding: 12px 16px;
  border-bottom: 2px solid var(--border-strong);
  white-space: nowrap;
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  color: var(--text-body);
  vertical-align: middle;
}

.data-table tr:hover td {
  background-color: var(--primary-light);
}

/* الشارات والأوسمة (Pills & Badges) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-primary { background: var(--primary-light); color: var(--primary); }

/* شاشة إنشاء الطلب والمبيعات (POS Layout) */
.pos-container {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 20px;
  align-items: start;
}

.pos-products-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pos-search-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.search-input-box {
  flex: 1;
  position: relative;
  min-width: 220px;
}

.search-input-box input {
  width: 100%;
  padding: 10px 38px 10px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: #FFFFFF;
  outline: none;
  transition: var(--transition);
}

.search-input-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(92, 58, 33, 0.12);
}

.search-input-box .search-icon {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
}

/* فئات المنتجات */
.pos-categories {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.cat-pill {
  padding: 6px 16px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
  color: var(--text-body);
}

.cat-pill:hover, .cat-pill.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
}

/* شبكة المنتجات */
.pos-products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}

.pos-product-card {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.pos-product-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.pos-product-card .stock-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}

.pos-product-card .sku-text {
  font-size: 0.7rem;
  color: var(--text-light);
  margin-bottom: 4px;
  font-family: monospace;
}

.pos-product-card h4 {
  font-size: 0.92rem;
  color: var(--text-main);
  margin-bottom: 8px;
  line-height: 1.4;
  height: 42px;
  overflow: hidden;
}

.pos-product-card .price-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 8px;
}

.pos-product-card .price-val {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
}

.pos-product-card .price-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.pos-product-card .add-btn {
  background: var(--primary-light);
  color: var(--primary);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 1.1rem;
}

.pos-product-card:hover .add-btn {
  background: var(--primary);
  color: #FFFFFF;
}

/* سلة البيع (Cart Sidebar) */
.pos-cart-panel {
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: calc(var(--header-height) + 16px);
  max-height: calc(100vh - var(--header-height) - 32px);
}

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

.cart-customer-select {
  padding: 14px 16px;
  background: var(--bg-body);
  border-bottom: 1px solid var(--border);
}

.cart-customer-select label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.customer-picker-row {
  display: flex;
  gap: 8px;
}

.customer-picker-row select {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: #FFFFFF;
}

.cart-items-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 180px;
  max-height: 320px;
}

.cart-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px;
  background: var(--bg-body);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.cart-item-info {
  flex: 1;
}

.cart-item-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 2px;
}

.cart-item-price {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.cart-item-qty {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 10px;
}

.qty-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: bold;
}

.qty-btn:hover {
  background: var(--primary);
  color: #FFFFFF;
}

.qty-num {
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 20px;
  text-align: center;
}

.cart-item-subtotal {
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--primary);
  min-width: 60px;
  text-align: left;
}

.cart-item-del {
  color: var(--danger);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
}

.cart-empty-msg {
  text-align: center;
  color: var(--text-light);
  padding: 40px 10px;
  font-size: 0.9rem;
}

/* ملخص وأسعار السلة */
.cart-summary {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-body);
}

.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: var(--text-body);
}

.summary-row.total {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--primary-dark);
  border-top: 2px dashed var(--border-strong);
  padding-top: 8px;
  margin-top: 8px;
}

.cart-notes-input {
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-top: 8px;
  font-size: 0.8rem;
  resize: none;
}

.cart-checkout-btn {
  width: 100%;
  margin-top: 12px;
  padding: 13px;
  font-size: 1rem;
  font-weight: 800;
  border-radius: var(--radius-md);
}

/* نافذة المودال (Modals) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(38, 25, 16, 0.65);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.active {
  display: flex;
}

.modal-content {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-float);
  border: 1px solid var(--border);
  animation: slideUp 0.25s ease;
}

.modal-content.modal-lg {
  max-width: 850px;
}

.modal-content.modal-xl {
  max-width: 1050px;
}

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

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

.modal-header h3 {
  font-size: 1.15rem;
  color: var(--primary);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg-body);
}

/* حقول النماذج (Form Controls) */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

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

.form-group label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
}

.form-group input, .form-group select, .form-group textarea {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: #FFFFFF;
  color: var(--text-main);
  outline: none;
  transition: var(--transition);
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(92, 58, 33, 0.12);
}

/* تتبع الطلبات (Order Tracking Timeline) */
.tracking-timeline {
  display: flex;
  justify-content: space-between;
  position: relative;
  margin: 24px 0 16px;
}

.tracking-timeline::before {
  content: "";
  position: absolute;
  top: 18px;
  right: 20px;
  left: 20px;
  height: 4px;
  background: var(--border-strong);
  z-index: 1;
}

.timeline-step {
  position: relative;
  z-index: 2;
  text-align: center;
  flex: 1;
}

.step-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #FFFFFF;
  border: 3px solid var(--border-strong);
  color: var(--text-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 8px;
  font-weight: 800;
  transition: var(--transition);
}

.timeline-step.completed .step-circle {
  background: var(--success);
  border-color: var(--success);
  color: #FFFFFF;
}

.timeline-step.current .step-circle {
  background: var(--primary);
  border-color: var(--secondary);
  color: #FFFFFF;
  box-shadow: 0 0 0 4px rgba(92, 58, 33, 0.2);
}

.step-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
}

.timeline-step.completed .step-label, .timeline-step.current .step-label {
  color: var(--primary-dark);
}

/* فاتورة الطباعة (Printable Invoice Layout) */
.invoice-print-area {
  padding: 30px;
  background: #FFFFFF;
  border-radius: var(--radius-md);
  color: #000000;
  font-size: 14px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.invoice-print-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.invoice-logo-container {
  display: flex;
  align-items: center;
  gap: 14px;
}

.invoice-logo-container img {
  height: 70px;
  object-fit: contain;
}

.invoice-meta-box {
  text-align: left;
}

.invoice-meta-box h2 {
  font-size: 1.4rem;
  color: var(--primary);
  margin-bottom: 4px;
}

.invoice-meta-box p {
  font-size: 0.85rem;
  color: #555555;
}

.invoice-customer-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  background: var(--primary-light);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

.invoice-table th {
  background: var(--primary);
  color: #FFFFFF;
  padding: 10px 14px;
  font-size: 0.85rem;
  text-align: right;
}

.invoice-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #DDDDDD;
  font-size: 0.9rem;
}

.invoice-totals-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-top: 14px;
}

.invoice-qr-code {
  width: 110px;
  height: 110px;
  border: 1px solid #DDDDDD;
  padding: 5px;
  background: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
}

.invoice-totals-table {
  width: 280px;
}

.invoice-totals-table tr td {
  padding: 6px 10px;
  border-bottom: 1px solid #EEEEEE;
  font-size: 0.9rem;
}

.invoice-totals-table tr.grand-total td {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
  border-top: 2px solid var(--primary);
}

.invoice-print-footer {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid #CCCCCC;
  text-align: center;
  font-size: 0.8rem;
  color: #666666;
}

.invoice-print-footer .supervisor-tag {
  font-weight: 700;
  color: var(--primary);
  margin-top: 4px;
}

/* شريط التنقل السفلي للجوال (Mobile Bottom Nav) */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-height);
  background: #FFFFFF;
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 14px rgba(92, 58, 33, 0.08);
  z-index: 999;
  justify-content: space-around;
  align-items: center;
  padding: 0 4px;
}

.mobile-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-muted);
  background: none;
  border: none;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  padding: 6px;
  flex: 1;
  transition: var(--transition);
  position: relative;
}

.mobile-nav-btn i, .mobile-nav-btn svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
}

.mobile-nav-btn.active {
  color: var(--primary);
  font-weight: 800;
}

.mobile-nav-btn.active::after {
  content: "";
  position: absolute;
  top: 0;
  width: 32px;
  height: 3px;
  background: var(--primary);
  border-radius: var(--radius-full);
}

/* شاشة الإشعارات السريعة (Toast) */
.toast-container {
  position: fixed;
  bottom: 80px;
  left: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: var(--primary-dark);
  color: #FFFFFF;
  font-size: 0.88rem;
  font-weight: 600;
  box-shadow: var(--shadow-float);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideRight 0.3s ease;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

@keyframes slideRight {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* صندوق كود جوجل شيت (Google Apps Script Box) */
.gas-code-box {
  background: #1E1E1E;
  color: #D4D4D4;
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: monospace;
  font-size: 0.82rem;
  direction: ltr;
  text-align: left;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid #333333;
}

/* ==============================================================================
   التجاوب مع شاشات الجوال والتابلت (Mobile Responsiveness)
   ============================================================================== */
@media (max-width: 1024px) {
  .pos-container {
    grid-template-columns: 1fr;
  }

  .pos-cart-panel {
    position: static;
    max-height: none;
  }
}

@media (max-width: 820px) {
  .sidebar {
    transform: translateX(100%);
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-float);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 95;
  }

  .sidebar-backdrop.active {
    display: block;
  }

  .main-wrapper {
    margin-right: 0;
    padding-bottom: var(--bottom-nav-height);
  }

  .mobile-menu-toggle {
    display: block;
  }

  .mobile-bottom-nav {
    display: flex;
  }

  .content-body {
    padding: 14px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .pos-products-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .card-header {
    flex-direction: column;
    align-items: stretch;
  }

  .card-actions {
    justify-content: flex-start;
  }

  .user-meta {
    display: none;
  }

  .invoice-customer-details {
    grid-template-columns: 1fr;
  }

  .invoice-totals-wrapper {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 16px;
  }

  .invoice-totals-table {
    width: 100%;
  }

  .invoice-qr-code {
    margin: 0 auto;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .pos-products-grid {
    grid-template-columns: 1fr;
  }

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

  .form-group.col-span-2 {
    grid-column: span 1;
  }
}

/* ==============================================================================
   أنماط الطباعة الفاخرة (ورقة رسمية A4 وحراري 80mm وكشف حساب العميل)
   ============================================================================== */

/* فاتورة الطباعة الفاخرة A4 */
.invoice-print-area {
  padding: 35px 40px;
  background: #FFFFFF;
  border-radius: var(--radius-md);
  color: #261910;
  font-size: 14px;
  border: 2px solid var(--primary);
  margin-bottom: 16px;
  position: relative;
  box-shadow: 0 0 0 4px var(--primary-light);
}

.invoice-print-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 18px;
  margin-bottom: 20px;
}

.invoice-logo-container {
  display: flex;
  align-items: center;
  gap: 16px;
}

.invoice-logo-container img {
  height: 80px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--border);
  padding: 3px;
  background: #FFFFFF;
}

.invoice-meta-box {
  text-align: left;
}

.invoice-meta-box h2 {
  font-size: 1.5rem;
  color: var(--primary);
  margin-bottom: 4px;
}

.invoice-meta-box p {
  font-size: 0.88rem;
  color: #4A3A2F;
  margin: 2px 0;
}

.invoice-customer-details {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  background: var(--primary-light);
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin-bottom: 22px;
  border: 1px solid var(--border);
}

.invoice-customer-details p {
  margin-bottom: 4px;
  font-size: 0.92rem;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
}

.invoice-table th {
  background: var(--primary);
  color: #FFFFFF;
  padding: 12px 14px;
  font-size: 0.88rem;
  text-align: right;
  border: 1px solid var(--primary);
}

.invoice-table td {
  padding: 11px 14px;
  border-bottom: 1px solid #E5DCD2;
  font-size: 0.92rem;
  border-right: 1px solid #F0E8DF;
  border-left: 1px solid #F0E8DF;
}

.invoice-table tr:nth-child(even) td {
  background-color: #FDFBF8;
}

.invoice-totals-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-top: 18px;
  gap: 20px;
}

.invoice-qr-code {
  width: 130px;
  border: 1px solid var(--border-strong);
  padding: 8px;
  background: #FFFFFF;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.invoice-totals-table {
  width: 320px;
  border-collapse: collapse;
}

.invoice-totals-table tr td {
  padding: 7px 12px;
  border-bottom: 1px solid #EEE5DB;
  font-size: 0.92rem;
}

.invoice-totals-table tr.grand-total td {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--primary);
  border-top: 2px solid var(--primary);
  background: var(--primary-light);
}

.invoice-signatures {
  display: flex;
  justify-content: space-between;
  margin-top: 28px;
  padding: 16px 20px 0;
  border-top: 1px dashed var(--border-strong);
}

.signature-box {
  width: 200px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.signature-line {
  margin-top: 36px;
  border-top: 1px solid #999999;
}

.invoice-print-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 2px solid var(--primary-light);
  text-align: center;
  font-size: 0.82rem;
  color: #666666;
  line-height: 1.6;
}

.invoice-print-footer .supervisor-tag {
  font-weight: 800;
  color: var(--primary);
  font-size: 0.95rem;
  margin-top: 6px;
}

/* ورقة كشف حساب العميل الفاخرة للطباعة A4 */
.ledger-print-sheet {
  background: #FFFFFF;
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.ledger-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 14px;
  margin-bottom: 18px;
}

.ledger-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.ledger-kpi-card {
  background: var(--bg-body);
  border: 1px solid var(--border);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  text-align: center;
}

.ledger-kpi-card p {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 2px;
}

.ledger-kpi-card h4 {
  font-size: 1.15rem;
  color: var(--primary);
  font-weight: 800;
}

/* ==============================================================================
   شاشة تسجيل الدخول المستقلة الفاخرة (Login Screen)
   ============================================================================== */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #FAF6F0 0%, #EFE5D8 100%);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.3s ease;
}

.login-card {
  background: #FFFFFF;
  width: 100%;
  max-width: 420px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border-strong);
  box-shadow: var(--shadow-float);
  padding: 36px 30px;
  text-align: center;
  position: relative;
}

.login-logo {
  width: 90px;
  height: 90px;
  object-fit: contain;
  margin: 0 auto 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 4px;
  background: #FFFFFF;
  box-shadow: var(--shadow-sm);
}

.login-card h2 {
  font-size: 1.8rem;
  color: var(--primary);
  margin-bottom: 2px;
}

.login-card .login-slogan {
  font-size: 0.95rem;
  color: var(--secondary);
  font-weight: 700;
  margin-bottom: 22px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: right;
}

.login-hint-box {
  background: var(--primary-light);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.8rem;
  color: var(--primary-dark);
  margin-top: 16px;
  text-align: center;
}

/* زر الحذف باللون الأحمر */
.btn-del {
  background: #FEE2E2;
  color: #B91C1C;
  border: 1px solid #FCA5A5;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.9rem;
}

.btn-del:hover {
  background: #B91C1C;
  color: #FFFFFF;
  border-color: #B91C1C;
}

/* شريط السلة العائم للجوال */
.mobile-cart-float-bar {
  display: none;
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + 12px);
  left: 14px;
  right: 14px;
  background: var(--primary);
  color: #FFFFFF;
  padding: 13px 20px;
  border-radius: var(--radius-full);
  box-shadow: 0 8px 25px rgba(92, 58, 33, 0.4);
  z-index: 950;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-weight: 700;
}

@media (max-width: 1024px) {
  .mobile-cart-float-bar.has-items {
    display: flex;
  }
}

/* شريط فلترة التواريخ بالتقارير */
.report-date-filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--primary-light);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.date-preset-btn {
  padding: 6px 14px;
  background: #FFFFFF;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-body);
  transition: var(--transition);
}

.date-preset-btn:hover, .date-preset-btn.active {
  background: var(--primary);
  color: #FFFFFF;
  border-color: var(--primary);
}

@media print {
  body {
    visibility: hidden !important;
    background: #FFFFFF !important;
  }

  .sidebar, .top-header, .mobile-bottom-nav, .card-actions, .btn, .modal-footer, .modal-header, .mobile-cart-float-bar, .no-print {
    display: none !important;
  }

  /* جعل مستند الفاتورة فقط هو المرئي */
  .modal-overlay.active #invoicePrintableContainer,
  .modal-overlay.active #invoicePrintableContainer * {
    visibility: visible !important;
  }

  .modal-overlay.active #invoicePrintableContainer {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 15px !important;
    border: 2px solid #5C3A21 !important;
    box-shadow: none !important;
  }

  /* كشف حساب العميل للطباعة */
  .modal-overlay.active #customerLedgerPrintContainer,
  .modal-overlay.active #customerLedgerPrintContainer * {
    visibility: visible !important;
  }

  .modal-overlay.active #customerLedgerPrintContainer {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 15px !important;
  }
}

/* تنسيق الطابعة الحرارية 80mm */
.thermal-mode .invoice-print-area {
  width: 78mm;
  margin: 0 auto;
  padding: 10px;
  font-size: 11px;
}

.thermal-mode .invoice-logo-container img {
  height: 50px;
}

.thermal-mode .invoice-meta-box h2 {
  font-size: 1.1rem;
}

.thermal-mode .invoice-customer-details {
  grid-template-columns: 1fr;
  padding: 8px;
  font-size: 11px;
}

.thermal-mode .invoice-table th, .thermal-mode .invoice-table td {
  padding: 6px 4px;
  font-size: 10px;
}
