/**
 * ═══════════════════════════════════════════════════════════════════════════
 * ملك الطابون - أنماط التعديل السريع (الكاشير اليدوي)
 * Tab Navigation, Quick Edit Section, Edit Order Modal
 * ═══════════════════════════════════════════════════════════════════════════
 */

/* ═══════════════════════════════════════════════════════════════════════ */
/* التابات (Tab Navigation) */
/* ═══════════════════════════════════════════════════════════════════════ */
.tab-navigation {
    display: flex;
    gap: 0;
    background: var(--bg-card, #fff);
    border-bottom: 2px solid var(--border-color, #e7e5e4);
    padding: 0 1rem;
}
.tab-btn {
    padding: 0.75rem 1.5rem;
    background: none;
    border: none;
    color: var(--text-secondary, #78716c);
    font-size: 1rem;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: all 0.2s;
    font-family: inherit;
    position: relative;
}
.tab-btn.active {
    color: var(--primary, #d97706);
    border-bottom-color: var(--primary, #d97706);
}
.tab-btn:hover {
    color: var(--text-primary, #292524);
}
@keyframes pendingPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}
.pending-edit-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--danger, #ef4444);
    border-radius: 50%;
    margin-inline-start: 6px;
    vertical-align: middle;
    animation: pendingPulse 1.4s ease-in-out infinite;
}

/* ═══════════════════════════════════════════════════════════════════════ */
/* التعديل السريع (Quick Edit) */
/* ═══════════════════════════════════════════════════════════════════════ */
.quick-edit-section {
    padding: 1rem;
}
.quick-edit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}
.quick-edit-header h2 {
    margin: 0;
    font-size: 1.25rem;
}
.quick-edit-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.order-count {
    color: var(--text-secondary, #78716c);
    font-size: 0.9rem;
}

/* فلاتر الحالة */
.quick-edit-filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.filter-btn {
    padding: 0.4rem 1rem;
    border: 1px solid var(--border-color, #e7e5e4);
    background: var(--bg-card, #fff);
    color: var(--text-secondary, #78716c);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
}
.filter-btn.active {
    background: var(--primary, #d97706);
    color: #fff;
    border-color: var(--primary, #d97706);
}

/* شبكة الطلبيات */
.quick-edit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
}

/* بطاقة الطلبية */
.quick-edit-card {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #e7e5e4);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    box-shadow: var(--shadow-sm);
}
.quick-edit-card .card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.quick-edit-card .order-number {
    font-weight: bold;
    font-size: 1.1rem;
}
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}
.status-badge.new { background: #3b82f6; color: #fff; }
.status-badge.preparing { background: #f59e0b; color: #000; }
.status-badge.ready { background: #10b981; color: #fff; }
.status-badge.delivered { background: #6b7280; color: #fff; }
.status-badge.cancelled { background: #ef4444; color: #fff; }

.card-info {
    display: flex;
    gap: 1rem;
    color: var(--text-secondary, #78716c);
    font-size: 0.85rem;
    flex-wrap: wrap;
}
.card-items {
    border-top: 1px solid var(--border-color, #e7e5e4);
    padding-top: 0.5rem;
    max-height: 120px;
    overflow-y: auto;
}
.order-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.2rem 0;
    font-size: 0.85rem;
}
.item-qty {
    color: var(--primary, #d97706);
    min-width: 30px;
}

.card-total {
    text-align: left;
    font-size: 1rem;
    border-top: 1px solid var(--border-color, #e7e5e4);
    padding-top: 0.5rem;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.card-actions button {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
}
.btn-edit { background: var(--primary, #d97706); color: #fff; }
.btn-cancel { background: #ef4444; color: #fff; }
.btn-status { background: var(--bg-main, #fafaf9); color: var(--text-primary, #292524); border: 1px solid var(--border-color, #e7e5e4) !important; }

/* قائمة الحالة */
.status-dropdown { position: relative; }
.status-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #e7e5e4);
    border-radius: 8px;
    overflow: hidden;
    z-index: 50;
    min-width: 140px;
    box-shadow: var(--shadow-md);
}
.status-menu.open { display: block; }
.status-menu button {
    display: block;
    width: 100%;
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    color: var(--text-primary, #292524);
    cursor: pointer;
    text-align: right;
    font-family: inherit;
}
.status-menu button:hover { background: var(--bg-main, #fafaf9); }

/* حالات فارغة/تحميل */
.quick-edit-empty, .quick-edit-loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary, #78716c);
}
.quick-edit-empty i, .quick-edit-loading i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    display: block;
}

/* ═══════════════════════════════════════════════════════════════════════ */
/* نافذة التعديل (Edit Order Modal) */
/* ═══════════════════════════════════════════════════════════════════════ */
.edit-order-modal {
    position: fixed;
    inset: 0;
    background: var(--bg-main, #fafaf9);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.edit-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--bg-card, #fff);
    border-bottom: 1px solid var(--border-color, #e7e5e4);
}
.edit-modal-header h2 { margin: 0; font-size: 1.1rem; }
.btn-close-modal {
    background: none;
    border: none;
    color: var(--text-primary, #292524);
    font-size: 1.5rem;
    cursor: pointer;
}
.edit-modal-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}
.edit-products-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.edit-categories-bar {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    overflow-x: auto;
    flex-shrink: 0;
}
.edit-search-bar {
    padding: 0 1rem 0.5rem;
}
.edit-search-bar input {
    width: 100%;
    padding: 0.6rem 1rem;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #e7e5e4);
    border-radius: 8px;
    color: var(--text-primary, #292524);
    font-family: inherit;
}
.edit-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    padding: 0 1rem 1rem;
    overflow-y: auto;
    flex: 1;
}
.edit-product-card {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #e7e5e4);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    text-align: center;
    transition: border-color 0.2s, box-shadow 0.2s;
    overflow: hidden;
}
.edit-product-card:hover { border-color: var(--primary, #d97706); box-shadow: 0 2px 8px rgba(217,119,6,0.15); }
.edit-product-card .product-name { font-size: 0.82rem; margin-bottom: 0.25rem; line-height: 1.3; }
.edit-product-card .product-price { color: var(--primary, #d97706); font-weight: bold; font-size: 0.85rem; }
.edit-product-img {
    width: 100%;
    height: 70px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 0.4rem;
    display: block;
}
.edit-product-img-placeholder {
    width: 100%;
    height: 70px;
    background: var(--border-light, #f5f5f4);
    border-radius: 6px;
    margin-bottom: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted, #a8a29e);
    font-size: 1.4rem;
}

/* سلة التعديل */
.edit-sidebar {
    width: 320px;
    background: var(--bg-card, #fff);
    border-right: 1px solid var(--border-color, #e7e5e4);
    display: flex;
    flex-direction: column;
    padding: 1rem;
    overflow-y: auto;
}
.edit-sidebar h3 { margin: 0 0 0.75rem; font-size: 1rem; }
.edit-cart-items {
    min-height: 130px;
    max-height: 38vh;
    flex-shrink: 0;
    overflow-y: auto;
    margin-bottom: 0.75rem;
}
.edit-cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color, #e7e5e4);
}
.edit-cart-item .item-info { flex: 1; }
.edit-cart-item .item-name { display: block; font-size: 0.9rem; }
.edit-cart-item .item-price { display: block; font-size: 0.8rem; color: var(--text-secondary); }
.item-controls {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.item-controls button {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color, #e7e5e4);
    background: var(--bg-main, #fafaf9);
    color: var(--text-primary, #292524);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.item-controls .btn-remove { border-color: #ef4444; color: #ef4444; }
.empty-cart-msg { color: var(--text-secondary); text-align: center; padding: 2rem 0; }

/* الخصم والمجموع */
.edit-discount-section { margin: 0.5rem 0; }
.edit-discount-section label { display: block; margin-bottom: 0.3rem; font-size: 0.85rem; }
.discount-row { display: flex; gap: 0.5rem; }
.discount-row input, .discount-row select {
    flex: 1;
    padding: 0.5rem;
    background: var(--bg-main, #fafaf9);
    border: 1px solid var(--border-color, #e7e5e4);
    border-radius: 6px;
    color: var(--text-primary, #292524);
    font-family: inherit;
}
.edit-total-section { padding: 0.75rem 0; border-top: 1px solid var(--border-color, #e7e5e4); }
.subtotal-row, .discount-row-display, .total-row {
    display: flex;
    justify-content: space-between;
    padding: 0.25rem 0;
    font-size: 0.9rem;
}
.total-row { font-size: 1.1rem; margin-top: 0.3rem; }

.btn-apply-edit {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary, #d97706);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    margin-top: 0.5rem;
    font-family: inherit;
    font-weight: 600;
}
.btn-apply-edit:hover { opacity: 0.9; }

/* form groups داخل edit sidebar */
.edit-sidebar .form-group { margin-bottom: 0.5rem; }
.edit-sidebar .form-group label { display: block; font-size: 0.85rem; margin-bottom: 0.3rem; }
.edit-sidebar .form-group input,
.edit-sidebar .form-group textarea {
    width: 100%;
    padding: 0.5rem;
    background: var(--bg-main, #fafaf9);
    border: 1px solid var(--border-color, #e7e5e4);
    border-radius: 6px;
    color: var(--text-primary, #292524);
    font-family: inherit;
}
.edit-sidebar .form-group textarea {
    height: 60px;
    resize: vertical;
}
