/* ─────────────────────────────────────────────────────────────────────────
   ShopOS — ستايل إدارة الورديات وجرد الشفتات والصلاحيات (shifts.css)
   ───────────────────────────────────────────────────────────────────────── */

/* ── شريط الشفت في شاشة POS والهيدر ── */
.pos-tool-btn.pos-shift-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  height: 30px;
  padding: 4px 10px;
  border-radius: var(--r-sm);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  transition: all 0.2s ease;
}

.pos-tool-btn.pos-shift-btn.closed {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--warning);
}

.pos-tool-btn.pos-shift-btn.closed:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--warning);
  transform: translateY(-1px);
}

.pos-tool-btn.pos-shift-btn.open {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.35);
  color: var(--text-1);
}

.pos-tool-btn.pos-shift-btn.open:hover {
  background: rgba(16, 185, 129, 0.18);
  border-color: var(--success);
  transform: translateY(-1px);
}

.pos-shift-divider {
  color: var(--text-3);
  opacity: 0.6;
  font-size: 11px;
}

.pos-shift-cash {
  color: var(--success);
  font-weight: 800;
}

.pos-shift-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  background: var(--success);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
  animation: pulse-dot 2s infinite;
  flex-shrink: 0;
}

.pos-shift-dot.closed {
  background: var(--warning);
  box-shadow: 0 0 5px rgba(245, 158, 11, 0.7);
  animation: none;
}

@keyframes pulse-dot {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.btn-shift-action {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.btn-shift-action:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-shift-action.btn-shift-close {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.btn-shift-action.btn-shift-open {
  background: linear-gradient(135deg, #10b981, #059669);
}

/* ── بطاقة الشفت النشط الرئيسية ── */
.active-shift-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  position: relative;
  overflow: hidden;
}

.active-shift-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--primary), var(--success));
}

.active-shift-card.closed-banner::before {
  background: linear-gradient(90deg, var(--warning), #f97316);
}

.shift-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}

.shift-title-group h3 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-1);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.shift-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}

.shift-metric-box {
  background: var(--bg-2);
  border: 1px solid var(--border-light);
  border-radius: var(--r-sm);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transition: transform 0.2s;
}

.shift-metric-box:hover {
  transform: translateY(-2px);
}

.shift-metric-label {
  font-size: 12px;
  color: var(--text-3);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.shift-metric-value {
  font-size: 20px;
  font-weight: 800;
  color: var(--text-1);
}

.shift-metric-value.primary { color: var(--primary); }
.shift-metric-value.success { color: var(--success); }
.shift-metric-value.warning { color: var(--warning); }
.shift-metric-value.danger  { color: var(--danger); }
.shift-metric-value.purple  { color: #8b5cf6; }

/* ── شبكة الصلاحيات في إدارة الموظفين ── */
.perms-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.perms-presets {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--bg-2);
  padding: 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-light);
}

.perms-preset-btn {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.perms-preset-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.perms-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
  padding: 4px;
}

.perm-card {
  background: var(--bg-2);
  border: 1px solid var(--border-light);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.perm-card:hover {
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.04);
}

.perm-card.active {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--primary);
}

.perm-card-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.perm-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(99, 102, 241, 0.12);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.perm-card-text {
  display: flex;
  flex-direction: column;
}

.perm-card-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-1);
}

.perm-card-sub {
  font-size: 11px;
  color: var(--text-3);
}

.perm-card-checkbox input {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ── إيصال جرد الشفت الحراري (Thermal Shift Receipt) ── */
.shift-receipt {
  max-width: 360px;
  width: 100%;
  box-sizing: border-box;
  margin: 0 auto;
  background: #fff;
  color: #000;
  font-family: 'Cairo', 'Courier New', monospace;
  padding: 14px 12px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.1);
  direction: rtl;
  text-align: right;
  font-size: 12px;
  line-height: 1.4;
}

.shift-receipt-header {
  text-align: center;
  border-bottom: 2px dashed #333;
  padding-bottom: 12px;
  margin-bottom: 12px;
}

.shift-receipt-store {
  font-size: 17px;
  font-weight: 900;
  margin-bottom: 4px;
  color: #000;
}

.shift-receipt-title {
  font-size: 14px;
  font-weight: 800;
  background: #000;
  color: #fff;
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-block;
  margin: 6px 0;
}

.shift-receipt-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 2.5px 0;
  gap: 8px;
  box-sizing: border-box;
}

.shift-receipt-row > span:first-child,
.shift-receipt-row > strong:first-child {
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
  text-align: right;
}

.shift-receipt-row > span:last-child,
.shift-receipt-row > strong:last-child {
  flex: 0 0 auto;
  white-space: nowrap;
  text-align: left;
}

.shift-receipt-row.bold {
  font-weight: 800;
  font-size: 13px;
}

.shift-receipt-row.highlight {
  background: #f4f4f5;
  padding: 6px 8px;
  border-radius: 4px;
  font-weight: 800;
  margin: 4px 0;
}

.shift-receipt-divider {
  border-top: 1px dashed #555;
  margin: 8px 0;
}

.shift-receipt-divider-double {
  border-top: 2px solid #000;
  margin: 10px 0;
}

.shift-receipt-section-title {
  font-weight: 800;
  font-size: 12px;
  color: #444;
  margin: 8px 0 4px 0;
  text-transform: uppercase;
}

.shift-products-table {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0;
  font-size: 11px;
  table-layout: fixed;
  box-sizing: border-box;
}

.shift-products-table th {
  border-bottom: 1.5px solid #000;
  padding: 4px 2px;
  font-size: 11px;
  font-weight: 800;
  color: #000;
}

.shift-products-table td {
  padding: 4px 2px;
  border-bottom: 1px dashed #ddd;
  font-size: 11px;
  vertical-align: top;
  color: #000;
}

.shift-products-table tr:last-child td {
  border-bottom: none;
}

.shift-products-table .col-prod-name {
  width: 50%;
  text-align: right;
  word-break: break-word;
  overflow-wrap: break-word;
}

.shift-products-table .col-prod-qty {
  width: 22%;
  text-align: center;
  white-space: nowrap;
  font-weight: 700;
}

.shift-products-table .col-prod-total {
  width: 28%;
  text-align: left;
  white-space: nowrap;
  font-weight: 800;
}

.shift-diff-box {
  padding: 8px;
  text-align: center;
  border-radius: 6px;
  font-weight: 900;
  font-size: 14px;
  margin: 8px 0;
}

.shift-diff-box.exact {
  background: #dcfce7;
  color: #15803d;
  border: 1px solid #86efac;
}

.shift-diff-box.surplus {
  background: #dbeafe;
  color: #1d4ed8;
  border: 1px solid #93c5fd;
}

.shift-diff-box.shortage {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

/* ── وضع الطباعة الحقيقي ── */
@media print {
  .no-print {
    display: none !important;
  }
  body.modal-open-print .shift-receipt-printable {
    position: static !important;
    width: 100% !important;
    max-width: 100% !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  body.modal-open-print .shift-receipt {
    width: 72mm !important;
    max-width: 72mm !important;
    box-sizing: border-box !important;
    margin: 0 auto !important;
    padding: 1mm 2mm 15mm 2mm !important;
    box-shadow: none !important;
    border: none !important;
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11px !important;
    overflow: visible !important;
  }
  body.modal-open-print .shift-receipt * {
    visibility: visible !important;
    color: #000000 !important;
  }
  body.modal-open-print .shift-receipt-row {
    padding: 2px 0 !important;
    font-size: 11px !important;
  }
  body.modal-open-print .shift-products-table {
    width: 100% !important;
    font-size: 10.5px !important;
  }
  body.modal-open-print .shift-products-table th {
    border-bottom: 1.5px solid #000000 !important;
    color: #000000 !important;
  }
  body.modal-open-print .shift-products-table td {
    border-bottom: 1px dashed #cccccc !important;
    color: #000000 !important;
  }
  body.modal-open-print .shift-diff-box {
    border: 1px solid #000 !important;
    background: #f4f4f5 !important;
    color: #000 !important;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    padding: 4px !important;
    font-size: 11.5px !important;
  }
}
