/* ============================================================
   Iraq Pack Phase 3 — shared styles for:
   - Cashbox Movements
   - End-of-Day (X/Z Report)
   - Loyalty Program
   - Stocktake
   ============================================================ */

/* ============== Segmented buttons (for movement type) ============== */
.seg-btns {
    display: flex;
    gap: 8px;
}

.seg-btn {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--c-border);
    background: var(--c-card-bg);
    color: var(--c-text-muted);
    border-radius: 10px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 700;
    font-size: 15px;
    transition: all 0.2s;
}

.seg-btn:hover {
    border-color: var(--c-primary);
    color: var(--c-text);
}

.seg-btn.active {
    background: linear-gradient(135deg, var(--c-primary), #5b4cd6);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(124, 108, 255, 0.35);
}

.seg-btn.active.success {
    background: linear-gradient(135deg, #16a34a, #15803d);
    box-shadow: 0 4px 14px rgba(22, 163, 74, 0.35);
}

.seg-btn.active.danger {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.35);
}

/* ============== Toggle switch ============== */
.toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
}

.toggle input[type="checkbox"] {
    display: none;
}

.toggle-slider {
    width: 44px;
    height: 24px;
    background: #ccc;
    border-radius: 12px;
    position: relative;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle input[type="checkbox"]:checked + .toggle-slider {
    background: var(--c-primary);
}

.toggle input[type="checkbox"]:checked + .toggle-slider::before {
    transform: translateX(20px);
}

/* ============== Progress bar (used in EOD payment breakdown + stocktake) ============== */
.prog {
    position: relative;
    width: 100%;
    height: 22px;
    background: var(--c-border);
    border-radius: 12px;
    overflow: hidden;
}

.prog-bar {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, var(--c-primary), #5b4cd6);
    border-radius: 12px;
    transition: width 0.3s;
}

.prog span {
    position: relative;
    z-index: 1;
    display: block;
    text-align: center;
    line-height: 22px;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

/* ============== Modal backdrop (reused across features) ============== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(3px);
}

.modal-card {
    background: var(--c-card-bg);
    border-radius: 16px;
    padding: 24px 28px;
    max-width: 560px;
    width: 90%;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    animation: modal-pop 0.18s ease-out;
}

@keyframes modal-pop {
    from {
        opacity: 0;
        transform: scale(0.92);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============== Input with currency suffix ============== */
.input-with-suffix {
    display: flex;
    align-items: stretch;
    gap: 0;
}

.input-with-suffix input,
.input-with-suffix select {
    flex: 1;
    border-radius: 8px 0 0 8px;
}

.input-with-suffix .suffix {
    display: inline-flex;
    align-items: center;
    padding: 0 14px;
    background: var(--c-border);
    color: var(--c-text-muted);
    border-radius: 0 8px 8px 0;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}

[dir="rtl"] .input-with-suffix input,
[dir="rtl"] .input-with-suffix select {
    border-radius: 0 8px 8px 0;
}

[dir="rtl"] .input-with-suffix .suffix {
    border-radius: 8px 0 0 8px;
}

/* ============== EOD specific ============== */
.eod-status {
    padding: 14px 18px;
    border-radius: 10px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.eod-status.open {
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.12), rgba(245, 158, 11, 0.05));
    border-right: 4px solid #f59e0b;
    color: #92400e;
}

.eod-status.closed {
    background: linear-gradient(90deg, rgba(22, 163, 74, 0.12), rgba(22, 163, 74, 0.05));
    border-right: 4px solid #16a34a;
    color: #14532d;
}

.eod-status .material-symbols-rounded {
    font-size: 24px;
}

.eod-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-top: 16px;
}

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

.cur-line {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px dashed var(--c-border);
    font-size: 15px;
}

.cur-line:last-child {
    border-bottom: 0;
}

/* ============== Stocktake variance row highlights ============== */
.stk-surplus {
    background: rgba(245, 158, 11, 0.06);
}

.stk-shortage {
    background: rgba(220, 38, 38, 0.06);
}

/* ============== Two-column grid (loyalty) ============== */
.two-col-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 980px) {
    .two-col-grid {
        grid-template-columns: 1fr;
    }
}

/* ============== Alert variants ============== */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-weight: 500;
}

.alert-error {
    background: rgba(220, 38, 38, 0.1);
    color: #b91c1c;
    border-right: 4px solid #dc2626;
}

.alert-success {
    background: rgba(22, 163, 74, 0.1);
    color: #15803d;
    border-right: 4px solid #16a34a;
}

/* ============== Pill variants we use ============== */
.pill.muted {
    background: var(--c-border);
    color: var(--c-text-muted);
}

/* ============== Iconify btn-icon (small action buttons in tables) ============== */
.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--c-border);
    background: var(--c-card-bg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--c-text-muted);
    transition: all 0.15s;
}

.btn-icon:hover {
    background: var(--c-primary);
    color: #fff;
    border-color: var(--c-primary);
}

.btn-icon .material-symbols-rounded {
    font-size: 18px;
}

/* ============== KPI variants ============== */
.kpi-card.success .kpi-value {
    color: #16a34a;
}

.kpi-card.danger .kpi-value {
    color: #dc2626;
}

.kpi-card.warn .kpi-value {
    color: #f59e0b;
}

/* ===================================================================
   Barcode labels printing
   =================================================================== */
.lbl-layout {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 16px;
    margin-top: 12px;
}

@media (max-width: 980px) {
    .lbl-layout {
        grid-template-columns: 1fr;
    }
}

.lbl-search {
    width: 100%;
    margin-bottom: 12px;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid var(--c-border);
}

.lbl-prod-list {
    max-height: 480px;
    overflow-y: auto;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    background: var(--c-bg);
}

.lbl-prod-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid var(--c-border);
}

.lbl-prod-row:last-child {
    border-bottom: 0;
}

.lbl-prod-row:hover {
    background: rgba(124, 108, 255, 0.05);
}

.lbl-prod-info strong {
    display: block;
    font-size: 14px;
}

.lbl-prod-info small {
    font-size: 11px;
}

.lbl-prod-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.lbl-summary {
    margin-top: 16px;
    padding: 12px;
    background: rgba(124, 108, 255, 0.06);
    border-radius: 8px;
}

/* ============ The actual printable sheet ============ */
.lbl-sheet {
    display: grid;
    gap: 1mm;
    padding: 4mm;
    margin: 0 auto;
    background: #fff;
    width: 210mm;
    page-break-after: always;
    margin-top: 18px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

.lbl-sheet.\33 x8 { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 33mm; }
.lbl-sheet.\33 x10 { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 26mm; }
.lbl-sheet.\34 x10 { grid-template-columns: repeat(4, 1fr); grid-auto-rows: 26mm; }
.lbl-sheet.\32 x6 { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 45mm; }

.lbl {
    border: 1px dashed #ccc;
    text-align: center;
    padding: 3px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    color: #000;
    background: #fff;
}

.lbl-name {
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 2px;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

.lbl-bc {
    width: 100%;
    height: 38px;
}

.lbl-code {
    font-family: 'Courier New', monospace;
    font-size: 10px;
    letter-spacing: 0.5px;
}

.lbl-price {
    font-size: 14px;
    font-weight: 800;
    color: #000;
    margin-top: 2px;
}

/* ===================================================================
   Advanced Reports — Peak Hours bars
   =================================================================== */
.peak-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px dashed var(--c-border);
}

.peak-row:last-child {
    border-bottom: 0;
}

.peak-label {
    width: 70px;
    font-weight: 700;
    direction: ltr;
    text-align: center;
}

.peak-count {
    width: 50px;
    text-align: center;
    color: var(--c-text-muted);
    font-size: 12px;
}

/* ===================================================================
   Bill of Materials (BOM) form
   =================================================================== */
.bom-add-row {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 12px;
    background: rgba(124, 108, 255, 0.04);
    border: 1px dashed rgba(124, 108, 255, 0.3);
    border-radius: 10px;
    margin-bottom: 8px;
}

.bom-add-row input[type="number"],
.bom-add-row input[type="text"] {
    padding: 10px;
}

.bom-search-results {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    left: 0;
    background: var(--c-card-bg);
    border: 1px solid var(--c-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    max-height: 260px;
    overflow-y: auto;
    z-index: 100;
}

.bom-search-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--c-border);
    transition: background 0.15s;
}

.bom-search-item:last-child {
    border-bottom: 0;
}

.bom-search-item:hover {
    background: rgba(124, 108, 255, 0.08);
}

.bom-search-item strong {
    display: block;
    font-size: 14px;
}

.bom-search-item small {
    font-size: 11px;
}

.bom-selected {
    padding: 10px 12px;
    background: rgba(22, 163, 74, 0.08);
    border-right: 4px solid #16a34a;
    border-radius: 6px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.bom-selected button {
    margin-right: auto;
}

/* ===================================================================
   Multi-level BOM tree visualization
   =================================================================== */
.bom-sub-badge {
    display: inline-block;
    padding: 2px 8px;
    margin-right: 6px;
    background: linear-gradient(135deg, #7c6cff, #5b4cd6);
    color: #fff;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    vertical-align: middle;
}

.bom-tree-summary {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px;
    background: rgba(124, 108, 255, 0.06);
    border-radius: 8px;
}

.bom-tree {
    border: 1px solid var(--c-border);
    border-radius: 10px;
    overflow: hidden;
    background: var(--c-card-bg);
}

.bom-tree-row {
    border-bottom: 1px solid var(--c-border);
    transition: background 0.15s;
}

.bom-tree-row:last-child {
    border-bottom: 0;
}

.bom-tree-row:hover {
    background: rgba(124, 108, 255, 0.04);
}

.bom-tree-line {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    position: relative;
}

/* خط شجري أحمر فاتح للإزاحة */
.bom-tree-row[style*="padding-right"] .bom-tree-line::before {
    content: "";
    position: absolute;
    right: -12px;
    top: 0;
    bottom: 50%;
    width: 12px;
    border-right: 2px solid #ddd;
    border-bottom: 2px solid #ddd;
    border-bottom-right-radius: 6px;
}

.bom-tree-icon {
    font-size: 22px;
    width: 26px;
}

.bom-tree-icon.sub {
    color: var(--c-primary);
}

.bom-tree-icon.leaf {
    color: var(--c-text-muted);
}

.bom-tree-name {
    flex: 1;
    min-width: 200px;
}

.bom-tree-qty {
    width: 120px;
    text-align: center;
    color: var(--c-text-muted);
    font-size: 13px;
}

.bom-tree-cost {
    min-width: 200px;
    text-align: left;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

/* ===================================================================
   POS Loyalty card + customer select
   =================================================================== */
.pos-customer-select {
    flex: 1;
    padding: 6px 10px;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    background: var(--c-card-bg);
    font-weight: 600;
}

.pos-loyalty-card {
    margin: 8px 0 12px;
    padding: 10px 12px;
    background: linear-gradient(135deg, rgba(124, 108, 255, 0.08), rgba(91, 76, 214, 0.05));
    border: 1px solid rgba(124, 108, 255, 0.2);
    border-radius: 10px;
    font-size: 13px;
}

.pos-loyalty-card .ll-balance {
    font-weight: 600;
    color: var(--c-text);
}

.pos-loyalty-card .ll-balance strong {
    color: var(--c-primary);
    font-size: 16px;
}

.pos-loyalty-card .ll-balance small {
    color: var(--c-text-muted);
    margin-right: 6px;
    font-weight: 400;
}

.pos-loyalty-card .ll-redeem {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px dashed rgba(124, 108, 255, 0.2);
}

.pos-loyalty-card .ll-redeem strong {
    color: var(--c-green);
}

/* ===================================================================
   Receipt loyalty section
   =================================================================== */
.rcp-loyalty {
    padding: 8px 12px;
    background: rgba(124, 108, 255, 0.05);
    border-radius: 4px;
}

.rcp-loyalty-title {
    text-align: center;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--c-primary);
}

/* ===================================================================
   Pagination bar
   =================================================================== */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
    padding: 14px 18px;
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
    border-radius: 0 0 12px 12px;
    margin-top: -2px;
}

.pagination-info {
    color: var(--c-text-muted);
    font-size: 13px;
}

.pagination-info strong {
    color: var(--c-text);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pagination-page {
    padding: 0 12px;
    color: var(--c-text-muted);
    font-size: 13px;
}

.pagination-page strong {
    color: var(--c-primary);
    font-size: 15px;
}

.pagination-size {
    color: var(--c-text-muted);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pagination-size select {
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--c-border);
    background: var(--c-surface);
    color: var(--c-text);
}

/* ===================================================================
   Notification bell pulse animation (live SignalR updates)
   =================================================================== */
.icon-btn.pulse {
    animation: bell-shake 0.6s ease-in-out;
}

.badge.pulse {
    animation: bell-glow 2.4s ease-in-out infinite;
}

@keyframes bell-shake {
    0%, 100% { transform: rotate(0deg); }
    20%, 60% { transform: rotate(-15deg); }
    40%, 80% { transform: rotate(15deg); }
}

@keyframes bell-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 82, 82, 0.7); }
    50% { box-shadow: 0 0 0 8px rgba(255, 82, 82, 0); }
}

.pill.expired {
    background: rgba(220, 38, 38, 0.2);
    color: #991b1b;
    font-weight: 800;
}

.pill.danger {
    background: rgba(220, 38, 38, 0.15);
    color: #b91c1c;
}

.pill.warn {
    background: rgba(245, 158, 11, 0.15);
    color: #b45309;
}

.pill.success {
    background: rgba(22, 163, 74, 0.15);
    color: #15803d;
}

.pill.info {
    background: rgba(59, 130, 246, 0.15);
    color: #1d4ed8;
}

/* ============ Print mode ============ */
@media print {
    body { margin: 0; padding: 0; background: #fff !important; }
    .sidebar, .header, .nav-items, .page-head, .form-card, .no-print { display: none !important; }
    .lbl-sheet { box-shadow: none; margin: 0; }
    .lbl { border: 1px solid #eee; }
    @page { size: A4; margin: 0; }
}
