/* نظام إدارة المنتجات - ملف CSS */

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

:root {
    --color-primary: #2563eb;
    --color-primary-dark: #1d4ed8;
    --color-success: #10b981;
    --color-success-dark: #059669;
    --color-danger: #ef4444;
    --color-info: #06b6d4;
    --color-bg-body: #f8fafc;
    --color-bg-card: #ffffff;
    --color-bg-secondary: #f1f5f9;
    --color-text-primary: #0f172a;
    --color-text-secondary: #475569;
    --color-text-muted: #94a3b8;
    --color-border: #e2e8f0;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --font-family: 'Cairo', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: var(--spacing-lg);
    direction: rtl;
    color: var(--color-text-primary);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
}

header {
    background: var(--color-bg-card);
    border-radius: var(--radius-xl);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    box-shadow: var(--shadow-lg);
    text-align: center;
    position: relative;
}

header h1 {
    font-size: 2rem;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

header p {
    color: var(--color-text-secondary);
    font-size: 1.125rem;
}

.btn-back {
    position: absolute;
    top: var(--spacing-lg);
    left: var(--spacing-lg);
    padding: 0.5rem 1rem;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--color-text-primary);
    font-weight: 600;
    transition: all 0.3s;
}

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

.card {
    background: var(--color-bg-card);
    border-radius: var(--radius-lg);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-lg);
    box-shadow: var(--shadow-md);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 2px solid var(--color-border);
}

/* عنوان البطاقة مع المجموع */
.card-header-with-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-md);
    border-bottom: 2px solid var(--color-border);
}

.card-header-with-total .card-title {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.total-price-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    padding: 10px 20px;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
    animation: pulse-scale 2s ease-in-out infinite;
}

.total-label {
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
}

.total-value {
    color: white;
    font-weight: 700;
    font-size: 1.2rem;
    letter-spacing: 0.5px;
}

@keyframes pulse-scale {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.03);
    }
}

/* صفحة الاختيار */
.selection-screen {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--spacing-xl);
    margin-top: var(--spacing-xl);
}

.choice-card {
    cursor: pointer;
    text-align: center;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}

.choice-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.choice-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
}

.choice-badge {
    display: inline-block;
    padding: 0.25rem 1rem;
    background: var(--color-primary);
    color: white;
    border-radius: 999px;
    font-size: 0.875rem;
    margin-top: var(--spacing-md);
}

/* البحث */
.search-container {
    position: relative;
}

input[type="text"],
input[type="number"],
select {
    width: 100%;
    padding: var(--spacing-md) var(--spacing-lg);
    font-family: var(--font-family);
    font-size: 1rem;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    transition: all 0.3s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.input-lg {
    font-size: 1.125rem;
    padding: var(--spacing-lg) var(--spacing-xl);
    font-weight: 600;
    text-align: center;
}

.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-top: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow-lg);
}

.search-result-item {
    padding: var(--spacing-md);
    cursor: pointer;
    border-bottom: 1px solid var(--color-border);
    transition: background 0.2s;
}

.search-result-item:hover {
    background: var(--color-bg-secondary);
}

.search-result-item:last-child {
    border-bottom: none;
}

.result-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.result-category {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.hint {
    padding: var(--spacing-md);
    background: rgba(6, 182, 212, 0.1);
    border-right: 4px solid var(--color-info);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-top: var(--spacing-sm);
}

/* المنتجات المختارة */
.selected-products-list {
    max-height: 400px;
    overflow-y: auto;
}

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

.product-info {
    flex: 1;
}

.product-name {
    font-weight: 600;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.quantity-badge {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 700;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.product-price-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.product-price {
    color: var(--color-success);
    font-weight: 600;
}

.btn-edit-price {
    padding: 4px 10px;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

.btn-edit-price:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(245, 158, 11, 0.3);
}

.btn-edit-price:active {
    transform: translateY(0);
}

.btn-remove {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--color-danger);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    transition: all 0.3s;
}

.btn-remove:hover {
    transform: scale(1.1);
}

/* الأزرار */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: var(--spacing-md) var(--spacing-xl);
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: var(--color-primary);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s;
}

.btn:hover:not(:disabled) {
    background: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

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

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

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

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

.button-group {
    display: flex;
    gap: var(--spacing-md);
    flex-wrap: wrap;
    justify-content: center;
}

/* عرض المشتري */
.list-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.info-item {
    padding: var(--spacing-md);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
    text-align: center;
}

.info-label {
    display: block;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 0.25rem;
}

.info-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
}

.product-view-item {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-sm);
}

.product-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--color-primary);
    color: white;
    border-radius: 50%;
    font-weight: 700;
    flex-shrink: 0;
}

.product-details {
    flex: 1;
}

.previous-list-item {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    padding: var(--spacing-md);
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-sm);
    cursor: pointer;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.previous-list-item:hover {
    background: var(--color-primary);
    color: white;
    transform: translateX(-5px);
    border-color: var(--color-primary);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.previous-list-item.active-list {
    background: var(--color-success);
    color: white;
    border-color: var(--color-success);
    box-shadow: 0 4px 12px rgba(46, 204, 113, 0.3);
}

.previous-list-item.active-list:hover {
    background: #27ae60;
    border-color: #27ae60;
}

.list-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.9em;
    opacity: 0.9;
}

.previous-list-item:hover .list-stats,
.previous-list-item.active-list .list-stats {
    opacity: 1;
}

/* النوافذ المنبثقة */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: var(--spacing-xl);
    border-radius: var(--radius-xl);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.close {
    float: left;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: var(--color-text-muted);
    transition: color 0.3s;
}

.close:hover {
    color: var(--color-danger);
}

.form-group {
    margin-bottom: var(--spacing-lg);
}

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

/* التحكم بالكمية */
.quantity-control {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-sm);
}

.btn-quantity {
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    font-weight: bold;
    border: 2px solid var(--color-primary);
    background: white;
    color: var(--color-primary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-quantity:hover {
    background: var(--color-primary);
    color: white;
    transform: scale(1.1);
}

.btn-quantity:active {
    transform: scale(0.95);
}

.input-quantity {
    width: 100px;
    height: 50px;
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-sm);
}

.input-quantity:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* الإشعارات */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: var(--spacing-md) var(--spacing-xl);
    background: var(--color-success);
    color: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    animation: slideIn 0.3s;
}

.notification.hidden {
    display: none;
}

@keyframes slideIn {
    from {
        transform: translateX(100px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* الحالات الفارغة */
.empty-state,
.loading,
.error-state {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--color-text-muted);
}

/* أدوات مساعدة */
.hidden {
    display: none !important;
}

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

.text-muted {
    color: var(--color-text-muted);
}

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }

/* استجابة الشاشات */
@media (max-width: 768px) {
    body {
        padding: var(--spacing-sm);
    }
    
    header {
        padding: var(--spacing-lg);
    }
    
    header h1 {
        font-size: 1.5rem;
    }
    
    .btn-back {
        position: static;
        margin-bottom: var(--spacing-md);
    }
    
    .button-group {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .modal-content {
        width: 95%;
    }
}

/* ===================================
   تحسينات خاصة للهاتف
=================================== */

/* شاشات الهواتف الصغيرة */
@media (max-width: 768px) {
    body {
        padding: 0.5rem;
    }
    
    .container {
        padding: 0;
    }
    
    header {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 0.75rem;
    }
    
    header h1 {
        font-size: 1.5rem;
        margin-bottom: 0.25rem;
    }
    
    header p {
        font-size: 0.875rem;
    }
    
    .btn-back {
        position: static;
        display: block;
        margin-bottom: 0.75rem;
        text-align: center;
    }
    
    /* البطاقات */
    .card {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 0.75rem;
    }
    
    .card-title {
        font-size: 1.125rem;
        margin-bottom: 1rem;
    }
    
    /* البحث - تكبير الخط للهاتف */
    .search-container input {
        font-size: 16px !important; /* منع التكبير التلقائي في iOS */
        padding: 1rem;
    }
    
    .input-lg {
        font-size: 16px !important;
        padding: 1rem;
    }
    
    /* قائمة نتائج البحث */
    .search-dropdown {
        max-height: 60vh; /* أكبر مساحة على الهاتف */
        font-size: 0.95rem;
    }
    
    .search-result-item {
        padding: 1rem;
        touch-action: manipulation; /* تحسين اللمس */
    }
    
    .result-name {
        font-size: 1rem;
        font-weight: 600;
    }
    
    .result-category {
        font-size: 0.875rem;
        margin-top: 0.25rem;
    }
    
    /* المنتجات المختارة */
    .selected-product-item {
        padding: 1rem;
        margin-bottom: 0.75rem;
        font-size: 0.95rem;
    }
    
    .product-name {
        font-size: 0.95rem;
        line-height: 1.4;
    }
    
    .product-price {
        font-size: 1rem;
        margin-top: 0.25rem;
    }
    
    .btn-remove {
        width: 36px;
        height: 36px;
        font-size: 1.75rem;
        min-width: 36px; /* منع التقلص */
        flex-shrink: 0;
    }
    
    /* الأزرار */
    .btn {
        width: 100%;
        padding: 1rem;
        font-size: 1rem;
        touch-action: manipulation;
        min-height: 48px; /* سهل الضغط */
    }
    
    .button-group {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    /* المجموع للموبايل */
    .card-header-with-total {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .total-price-badge {
        width: 100%;
        justify-content: center;
        padding: 12px 20px;
    }
    
    .total-value {
        font-size: 1.4rem;
    }
    
    /* النوافذ المنبثقة */
    .modal-content {
        width: 95%;
        max-width: none;
        padding: 1.5rem;
        max-height: 85vh;
    }
    
    .modal h3 {
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }
    
    .form-group input,
    .form-group select {
        font-size: 16px !important; /* منع التكبير التلقائي */
        padding: 1rem;
        min-height: 48px;
    }
    
    .form-group label {
        font-size: 0.95rem;
        margin-bottom: 0.5rem;
    }
    
    /* واجهة المشتري */
    .list-info {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .info-item {
        padding: 0.75rem;
    }
    
    .info-label {
        font-size: 0.875rem;
    }
    
    .info-value {
        font-size: 1.125rem;
    }
    
    .product-view-item {
        padding: 1rem;
        gap: 0.75rem;
    }
    
    .product-number {
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
    }
    
    .product-details .product-name {
        font-size: 0.95rem;
    }
    
    .product-details .product-price {
        font-size: 1rem;
    }
    
    /* القوائم السابقة */
    .previous-list-item {
        padding: 1rem;
        font-size: 0.95rem;
    }
    
    /* صفحة الاختيار الرئيسية */
    .selection-screen {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .choice-card {
        padding: 1.5rem;
        min-height: 180px;
    }
    
    .choice-icon {
        font-size: 3.5rem;
        margin-bottom: 1rem;
    }
    
    .choice-card h2 {
        font-size: 1.5rem;
    }
    
    .choice-card p {
        font-size: 0.95rem;
    }
    
    /* الإشعارات */
    .notification {
        top: 10px;
        right: 10px;
        left: 10px;
        width: auto;
        font-size: 0.95rem;
    }
    
    /* تحسين التمرير */
    .selected-products-list {
        max-height: 50vh;
        -webkit-overflow-scrolling: touch; /* تمرير سلس في iOS */
    }
    
    .search-dropdown {
        -webkit-overflow-scrolling: touch;
    }
}

/* شاشات الهواتف الصغيرة جداً */
@media (max-width: 375px) {
    header h1 {
        font-size: 1.25rem;
    }
    
    .card {
        padding: 0.75rem;
    }
    
    .btn {
        font-size: 0.95rem;
        padding: 0.875rem;
    }
    
    .choice-icon {
        font-size: 3rem;
    }
}

/* منع التكبير عند الضغط على input في iOS */
input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
    font-size: 16px !important;
}

/* تحسين سرعة الضغط على الأزرار */
.btn,
.search-result-item,
.choice-card,
.previous-list-item,
.btn-remove {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
}

/* زر الإضافة السريعة في نتائج البحث */
.search-result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.result-info {
    flex: 1;
    cursor: pointer;
}

.btn-quick-add {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--color-success);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    font-weight: bold;
    line-height: 1;
    transition: all 0.3s;
    flex-shrink: 0;
}

.btn-quick-add:hover {
    transform: scale(1.1);
    background: var(--color-success-dark);
}

.btn-quick-add:active {
    transform: scale(0.95);
}

/* منتج بدون سعر */
.selected-product-item.no-price {
    border-right: 4px solid var(--color-warning);
    background: rgba(245, 158, 11, 0.1);
}

/* زر إضافة السعر - واضح ومرئي */
.btn-add-price {
    padding: 0.75rem 1.25rem;
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff;
    border: 2px solid #f59e0b;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.btn-add-price:hover {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.btn-add-price:active {
    transform: translateY(0);
}

/* منتج بدون سعر - تمييز أوضح */
.selected-product-item.no-price {
    border-right: 5px solid #f59e0b;
    background: linear-gradient(90deg, rgba(245, 158, 11, 0.15) 0%, rgba(245, 158, 11, 0.05) 100%);
}

.selected-product-item.no-price .product-info {
    background: transparent;
}

.selected-product-item.no-price .product-price {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.5rem;
}

/* للهاتف */
@media (max-width: 768px) {
    .btn-add-price {
        width: 100%;
        padding: 1rem;
        font-size: 1.125rem;
    }
}

.dialog-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.dialog-options .btn {
    text-align: right;
    padding: 1.5rem;
}

.dialog-options .btn small {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    font-weight: normal;
    opacity: 0.8;
}

.old-name {
    padding: 1rem;
    background: var(--color-bg-secondary);
    border-radius: var(--radius-md);
    font-weight: 600;
    color: var(--color-text-secondary);
}

.warning-box {
    padding: 1rem;
    background: rgba(245, 158, 11, 0.1);
    border-right: 4px solid var(--color-warning);
    border-radius: var(--radius-md);
    margin: 1rem 0;
    font-size: 0.875rem;
}

/* منع تسلسل التمرير للنافذة المنبثقة */
.search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    margin-top: 0.5rem;
    max-height: 500px; /* أكبر من القديم */
    overflow-y: auto;
    z-index: 100;
    box-shadow: var(--shadow-lg);
    
    /* ✅ الحل - منع الانتقال للصفحة */
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y; /* السماح بالتمرير العمودي فقط داخل القائمة */
}

/* تحسينات إضافية للهاتف */
@media (max-width: 768px) {
    .search-dropdown {
        max-height: 75vh; /* أكبر مساحة */
        overscroll-behavior: contain;
    }
}

/* ==================== صفحة تسجيل الدخول ==================== */

.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
}

.login-card {
    max-width: 450px;
    width: 100%;
    margin: 0 auto;
}

.login-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.login-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.login-header h1 {
    font-size: 1.75rem;
    color: var(--color-primary);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--color-text-secondary);
    font-size: 1rem;
}

.login-form {
    margin-top: var(--spacing-xl);
}

.login-form .form-group {
    margin-bottom: var(--spacing-lg);
    position: relative;
}

.login-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--color-text-primary);
    font-size: 1rem;
}

.password-toggle {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    font-size: 1.25rem;
    user-select: none;
    padding: 5px;
    transition: transform 0.2s;
}

.password-toggle:hover {
    transform: translateY(-50%) scale(1.1);
}

.login-form .form-group {
    position: relative;
}

.error-message {
    background: #fee2e2;
    color: #dc2626;
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-md);
    font-weight: 600;
    text-align: center;
    border: 2px solid #fca5a5;
}

.error-message.hidden {
    display: none;
}

.btn-block {
    width: 100%;
}

.login-footer {
    margin-top: var(--spacing-xl);
    text-align: center;
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--color-border);
}

/* تأثير الاهتزاز عند الخطأ */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.shake {
    animation: shake 0.5s;
}

/* زر تسجيل الخروج */
.btn-logout {
    position: absolute;
    top: var(--spacing-lg);
    right: var(--spacing-lg);
    padding: 0.5rem 1rem;
    background: var(--color-danger);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-family);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.btn-logout:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* ==================== مؤشر الحفظ التلقائي ==================== */

.auto-save-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
    z-index: 10000;
    transition: all 0.4s ease;
    opacity: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.auto-save-indicator.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.auto-save-indicator::before {
    content: '';
    width: 8px;
    height: 8px;
    background: white;
    border-radius: 50%;
    animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

/* تحذير عدم حفظ البيانات */
.unsaved-warning {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: #fef3c7;
    border: 2px solid #f59e0b;
    color: #92400e;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 600;
    box-shadow: var(--shadow-md);
    z-index: 9999;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateX(-50%) translateY(-20px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}

/* تحسينات للموبايل */
@media (max-width: 768px) {
    .login-card {
        margin: var(--spacing-md);
    }
    
    .login-icon {
        font-size: 3rem;
    }
    
    .login-header h1 {
        font-size: 1.5rem;
    }
    
    .btn-logout {
        top: 10px;
        right: 10px;
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
}

