/* تحسينات على تصميم الموقع */

/* منع الوميض عند تحميل بيانات المطعم */
#restaurant-logo,
#footer-logo,
.logo-text h1,
.logo-text p,
.menu-header h2,
.menu-header p,
.footer-logo h3 {
    opacity: 0;
    transition: opacity 0.25s ease;
}
.data-loaded #restaurant-logo,
.data-loaded #footer-logo,
.data-loaded .logo-text h1,
.data-loaded .logo-text p,
.data-loaded .menu-header h2,
.data-loaded .menu-header p,
.data-loaded .footer-logo h3 {
    opacity: 1;
}

/* إضافة تأثيرات تفاعلية محسّنة */
.menu-item {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-item:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

/* تحسين تصميم الأزرار */
.btn, button {
    transition: all 0.3s ease;
    cursor: pointer;
}

.btn:active, button:active {
    transform: scale(0.98);
}

/* تحسين تصميم المدخلات */
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(195, 33, 44, 0.1);
}

/* تأثير التحميل */
.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* تحسينات الاستجابة للهاتف المحمول */

/* إصلاح ارتفاع رأس الصفحة على الشاشات الصغيرة */
@media (max-width: 576px) {
    :root { --header-height: 60px; }
    .nav-menu {
        top: 60px !important;
        height: calc(100vh - 60px) !important;
    }
}

/* مسافة سفلية للمحتوى لتجنب تداخل زر العربة */
@media (max-width: 768px) {
    main.container {
        padding-bottom: 90px;
    }
}

/* فلتر التصنيفات - تمرير أفقي على الموبايل */
@media (max-width: 640px) {
    .category-filter {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        justify-content: flex-start !important;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 5px 15px 12px 15px;
        margin: 0 -15px 20px -15px;
        width: auto !important;
        border-radius: 0 !important;
        box-shadow: 0 2px 10px rgba(0,0,0,0.05) !important;
    }
    .category-filter::-webkit-scrollbar { display: none; }
    .category-btn { flex-shrink: 0; }
}

/* تحسين عرض الصور */
.menu-item img {
    object-fit: cover;
    width: 100%;
    height: 200px;
}

/* تحسين تصميم البطاقات */
.menu-item .item-content {
    padding: 20px;
}

/* تحسين الأيقونات */
.fa, .fas, .far, .fab {
    display: inline-block;
    font-style: normal;
    font-variant: normal;
    text-rendering: auto;
    line-height: 1;
}

/* تحسين رسائل التنبيه */
.alert {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* تحسين تصميم الجداول */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 20px;
}

table th,
table td {
    padding: 12px;
    text-align: right;
    border-bottom: 1px solid #ddd;
}

table th {
    background-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

table tr:hover {
    background-color: #f5f5f5;
}

/* تحسين شريط البحث */
.search-box {
    position: relative;
    margin-bottom: 20px;
}

.search-box input {
    width: 100%;
    padding: 12px 45px 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 15px;
    transition: all 0.3s;
}

.search-box input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(195, 33, 44, 0.1);
}

.search-box i {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

/* تحسين Skeleton Loading */
.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e0e0e0 50%,
        #f0f0f0 75%
    );
    background-size: 200% 100%;
    animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.skeleton-text {
    height: 16px;
    margin-bottom: 8px;
    border-radius: 4px;
}

.skeleton-title {
    height: 24px;
    margin-bottom: 12px;
    border-radius: 4px;
}

.skeleton-image {
    height: 200px;
    border-radius: 8px;
    margin-bottom: 12px;
}

/* تحسين Badge */
.badge {
    display: inline-block;
    padding: 4px 8px;
    background-color: var(--secondary-color);
    color: var(--text-color);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    margin-right: 5px;
}

.badge-primary {
    background-color: var(--primary-color);
    color: white;
}

.badge-success {
    background-color: #2ecc71;
    color: white;
}

.badge-warning {
    background-color: #f39c12;
    color: white;
}

.badge-danger {
    background-color: #e74c3c;
    color: white;
}

/* تحسين Tooltips */
[data-tooltip] {
    position: relative;
    cursor: help;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-5px);
    padding: 8px 12px;
    background-color: rgba(0, 0, 0, 0.9);
    color: white;
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 1000;
}

[data-tooltip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(-8px);
}

/* تحسين Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* تحسين النص المحدد */
::selection {
    background-color: var(--primary-color);
    color: white;
}

::-moz-selection {
    background-color: var(--primary-color);
    color: white;
}

/* تحسين الرسوم المتحركة */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease;
}

.fade-in-up {
    animation: fadeInUp 0.5s ease;
}

.fade-in-down {
    animation: fadeInDown 0.5s ease;
}

.scale-in {
    animation: scaleIn 0.3s ease;
}

/* تحسين الأزرار المعطلة */
button:disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* تحسين Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 24px;
    margin-bottom: 10px;
    color: #666;
}

.empty-state p {
    font-size: 16px;
    margin-bottom: 20px;
}

/* تحسين الاستجابة للشاشات الصغيرة */
@media (max-width: 576px) {
    .container {
        padding: 0 15px;
    }
    
    .menu-container {
        grid-template-columns: 1fr;
    }
    
    .cart-sidebar {
        max-width: 100%;
    }
}

/* نافذة تفاصيل الصنف - تصميم bottom-sheet على الهواتف الصغيرة */
@media (max-width: 380px) {
    .item-detail-modal {
        align-items: flex-end;
        padding: 0;
    }
    .modal-content {
        border-radius: 20px 20px 0 0;
        max-height: 92vh;
        width: 100%;
    }
    .modal-image-section {
        flex: 0 0 200px !important;
        min-height: 200px !important;
    }
    .modal-info-section {
        padding: 18px 16px !important;
        gap: 14px !important;
    }
    .modal-header h2 {
        font-size: 1.2rem !important;
    }
    .modal-price {
        font-size: 1.4rem !important;
    }
    .modal-price-section {
        padding: 18px !important;
    }
    .modal-add-btn {
        padding: 14px !important;
        font-size: 0.95rem !important;
    }
}

/* أنيميشن دخول لأقسام المنيو */
@keyframes sectionFadeIn {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

.category-section {
    animation: sectionFadeIn 0.5s ease both;
}

.category-section:nth-child(2) { animation-delay: 0.08s; }
.category-section:nth-child(3) { animation-delay: 0.16s; }
.category-section:nth-child(4) { animation-delay: 0.24s; }
.category-section:nth-child(5) { animation-delay: 0.32s; }

/* تحسين اللمس لعرض المعرض الأفقي */
.category-items-gallery,
.items-gallery-single {
    -webkit-overflow-scrolling: touch;
}

/* تحسين تجربة اللمس لزر إضافة للعربة */
@media (hover: none) and (pointer: coarse) {
    .add-to-cart-btn:active {
        transform: scale(0.96);
        opacity: 0.9;
    }
    .modal-add-btn:active {
        transform: scale(0.98);
    }
}

/* Print Styles */
@media print {
    .header,
    .cart-wrapper,
    .admin-link,
    .btn,
    button {
        display: none !important;
    }
    
    .invoice-content {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* تحسين الوضع الداكن (اختياري) */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1a1a1a;
        --text-color: #ffffff;
        --white: #2d2d2d;
    }
    
    body {
        background-color: var(--bg-color);
        color: var(--text-color);
    }
    
    .menu-item,
    .cart-sidebar {
        background-color: var(--white);
    }
    
    input,
    textarea,
    select {
        background-color: #2d2d2d;
        color: white;
        border-color: #444;
    }
}
