/* 
 * نظام POS - أنماط مخصصة
 * Custom CSS for POS System with RTL support
 */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700;800&display=swap');

/* ===== Global Styles ===== */
:root {
    /* Colors from uploaded images */
    --primary: #5b6a9f;
    --primary-dark: #4a5680;
    --success: #4caf50;
    --success-dark: #45a049;
    --danger: #d32f2f;
    --warning: #ff9800;
    --info: #2196f3;
    --light: #f5f7fa;
    --dark: #1a1a1a;

    /* Source/Category Colors */
    --color-brown: #8d6e63;
    --color-orange: #ff9800;
    --color-teal: #00bcd4;
    --color-blue: #2196f3;
    --color-pink: #e91e63;
    --color-purple: #9c27b0;
    --color-deep-purple: #673ab7;
    --color-indigo: #5c6bc0;

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Border radius */
    --border-radius: 8px;
    --border-radius-lg: 12px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    direction: rtl;
    background-color: var(--light);
    color: var(--dark);
    margin: 0;
    padding: 0;
}

/* ===== Header / Navbar ===== */
.navbar {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 0.75rem 1.5rem;
}

.navbar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: white !important;
}

.navbar .badge {
    font-size: 0.9rem;
    padding: 0.35em 0.65em;
    font-weight: 600;
}

/* ===== POS Container ===== */
.pos-container {
    display: flex;
    height: calc(100vh - 70px);
    overflow: hidden;
}

/* ===== Main Content Area ===== */
.pos-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #e8eaf0;
    padding: var(--spacing-lg);
    overflow-y: auto;
}

/* ===== Source Selector (المصادر) ===== */
.sources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.source-card {
    background: white;
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.source-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.source-card.active {
    border-color: currentColor;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.source-card h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: inherit;
}

/* ===== Products Grid ===== */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--spacing-md);
}

.product-card {
    background: white;
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #e0e0e0;
    position: relative;
    overflow: hidden;
}

.product-card:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.product-card.out-of-stock {
    opacity: 0.7;
    cursor: not-allowed;
    background: #f8f9fa;
    pointer-events: none;
}

.stock-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    color: white;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.product-card .product-image {
    width: 80px;
    height: 80px;
    background: #f5f5f5;
    border-radius: var(--border-radius);
    margin: 0 auto var(--spacing-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #999;
    position: relative;
}

.product-card .product-name {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
    color: var(--dark);
}

.product-card .product-price {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}

/* ===== Cart Sidebar ===== */
.cart-sidebar {
    width: 380px;
    background: white;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.05);
}

.cart-header {
    padding: var(--spacing-lg);
    border-bottom: 2px solid var(--light);
}

.cart-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md);
}

.cart-item {
    background: var(--light);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.cart-item-name {
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.cart-item-price {
    color: var(--primary);
    font-size: 0.9rem;
}

.cart-item-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.quantity-control {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.quantity-control button {
    width: 28px;
    height: 28px;
    border: none;
    background: var(--primary);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
}

.quantity-control span {
    min-width: 30px;
    text-align: center;
    font-weight: 600;
}

.remove-item {
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 4px;
    width: 28px;
    height: 28px;
    cursor: pointer;
}

/* ===== Cart Summary ===== */
.cart-summary {
    padding: var(--spacing-lg);
    border-top: 2px solid var(--light);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--spacing-sm);
    font-size: 0.95rem;
}

.summary-row.total {
    font-size: 1.3rem;
    font-weight: 700;
    padding-top: var(--spacing-sm);
    border-top: 2px solid var(--light);
    margin-top: var(--spacing-sm);
}

.checkout-btn {
    width: 100%;
    background: var(--success);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    padding: var(--spacing-lg);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: var(--spacing-md);
    transition: all 0.3s ease;
}

.checkout-btn:hover {
    background: var(--success-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(76, 175, 80, 0.3);
}

.checkout-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* ===== Invoices Page Improvements ===== */
.invoice-list-item {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
}

.invoice-list-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1) !important;
    border-color: var(--primary) !important;
}

.status-indicator {
    width: 45px;
    height: 45px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.status-indicator.paid {
    background-color: rgba(76, 175, 80, 0.1);
    color: #2e7d32;
}

.status-indicator.pending {
    background-color: rgba(255, 152, 0, 0.1);
    color: #ef6c00;
}

.status-indicator.refunded {
    background-color: rgba(211, 47, 47, 0.1);
    color: #c62828;
}

.invoice-main-info {
    flex-grow: 1;
}

.invoice-total {
    min-width: 120px;
}

.btn-group .btn {
    border-width: 1px;
}

.btn-group .btn:hover {
    background-color: var(--primary);
    color: white;
}

.btn-group .btn-outline-danger:hover {
    background-color: var(--danger);
    color: white;
}

.btn-group .btn-outline-secondary:hover {
    background-color: #666;
    color: white;
}

/* ===== Product Form ===== */
.product-form-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--spacing-xl);
}

.form-card {
    background: white;
    border-radius: var(--border-radius-lg);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-lg);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.form-card h3 {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: var(--spacing-lg);
    color: var(--primary);
}

.image-upload-area {
    border: 2px dashed #ddd;
    border-radius: var(--border-radius);
    padding: var(--spacing-xl);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.image-upload-area:hover {
    border-color: var(--primary);
    background-color: rgba(91, 106, 159, 0.05);
}

.profit-margin-display {
    background: linear-gradient(135deg, var(--success) 0%, #66bb6a 100%);
    color: white;
    padding: var(--spacing-lg);
    border-radius: var(--border-radius);
    text-align: center;
    font-size: 1.5rem;
    font-weight: 700;
}

/* ===== Badges ===== */
.badge {
    padding: 0.4em 0.8em;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85rem;
}

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

.badge-danger {
    background-color: var(--danger);
    color: white;
}

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

.badge-info {
    background-color: var(--info);
    color: white;
}

/* ===== Buttons ===== */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: var(--border-radius);
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Cairo', sans-serif;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

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

.btn-success:hover {
    background: var(--success-dark);
}

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

.btn-danger:hover {
    background: #b71c1c;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

/* ===== Form Controls ===== */
.form-control,
.form-select {
    font-family: 'Cairo', sans-serif;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    padding: 0.6rem 1rem;
    width: 100%;
    transition: all 0.3s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(91, 106, 159, 0.25);
    outline: none;
}

.form-label {
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    display: block;
}

/* ===== Utility Classes ===== */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-left {
    text-align: left;
}

.mt-1 {
    margin-top: var(--spacing-sm);
}

.mt-2 {
    margin-top: var(--spacing-md);
}

.mt-3 {
    margin-top: var(--spacing-lg);
}

.mb-1 {
    margin-bottom: var(--spacing-sm);
}

.mb-2 {
    margin-bottom: var(--spacing-md);
}

.mb-3 {
    margin-bottom: var(--spacing-lg);
}

.p-1 {
    padding: var(--spacing-sm);
}

.p-2 {
    padding: var(--spacing-md);
}

.p-3 {
    padding: var(--spacing-lg);
}

/* ===== Toast Notifications ===== */
.toast-container {
    position: fixed !important;
    top: 100px !important;
    bottom: auto !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    z-index: 9999999 !important;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
    width: auto;
    pointer-events: none;
}

.toast-box {
    background: rgba(255, 255, 255, 0.96) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    padding: 1.5rem 2.5rem !important;
    border-radius: 16px !important;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25) !important;
    display: flex !important;
    align-items: center !important;
    gap: 25px !important;
    min-width: 450px !important;
    max-width: 90vw !important;
    animation: toast-entrance 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important;
    border-right: 12px solid transparent !important;
    direction: rtl !important;
    border-left: 1px solid rgba(0, 0, 0, 0.08) !important;
    border-top: 1px solid rgba(0, 0, 0, 0.08) !important;
    pointer-events: auto !important;
}

@keyframes toast-entrance {
    from {
        transform: translateY(-40px) scale(0.9);
        opacity: 0;
    }

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

.toast-box.success {
    border-right-color: #2e7d32 !important;
}

.toast-box.danger {
    border-right-color: #d32f2f !important;
}

.toast-box.warning {
    border-right-color: #f9a825 !important;
}

.toast-box.info {
    border-right-color: #0277bd !important;
}

.toast-icon {
    font-size: 3rem !important;
    flex-shrink: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(0, 0, 0, 0.03);
    width: 60px;
    height: 60px;
    border-radius: 50%;
}

.success .toast-icon {
    color: #2e7d32 !important;
}

.danger .toast-icon {
    color: #d32f2f !important;
}

.warning .toast-icon {
    color: #f9a825 !important;
}

.info .toast-icon {
    color: #0277bd !important;
}

.toast-content {
    flex: 1 !important;
}

.toast-title {
    font-size: 1.4rem !important;
    font-weight: 900 !important;
    margin-bottom: 4px !important;
    display: block !important;
    color: #1a1a1a !important;
}

.toast-message {
    font-size: 1.1rem !important;
    color: #444 !important;
}

/* Specific style for invoice success detail card */
.invoice-toast-details {
    background: rgba(0, 0, 0, 0.05) !important;
    border-radius: 12px !important;
    padding: 15px 22px !important;
    margin-top: 15px !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
}

.invoice-toast-row {
    display: flex !important;
    justify-content: space-between !important;
    font-size: 1.1rem !important;
    margin-bottom: 6px !important;
}

.invoice-toast-label {
    color: #555 !important;
}

.invoice-toast-value {
    font-weight: 900 !important;
    color: #5b6a9f !important;
}

/* Fade out animation */
.toast-box.fade-out {
    animation: toast-exit-top 0.4s ease forwards !important;
}

@keyframes toast-exit-top {
    from {
        transform: translateY(0) scale(1);
        opacity: 1;
    }

    to {
        transform: translateY(-30px) scale(0.95);
        opacity: 0;
    }
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
    .pos-container {
        flex-direction: column;
    }

    .cart-sidebar {
        width: 100%;
        height: 50vh;
    }

    .sources-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}