/**
 * Menus Application - Custom CSS
 * RTL support and custom styles for bilingual interface
 */

/* ============================================================================
   FONTS
   ============================================================================ */

/* Cairo for Arabic */
.font-arabic {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif !important;
}

/* RTL body font */
html[dir="rtl"] body,
html[lang="ar"] body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* LTR body font */
html[dir="ltr"] body,
html[lang="en"] body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}


/* ============================================================================
   RTL SUPPORT
   ============================================================================ */

/* Flip icons for RTL */
html[dir="rtl"] .rtl\:rotate-180 {
    transform: rotate(180deg);
}

/* Text alignment */
html[dir="rtl"] .text-left {
    text-align: right;
}

html[dir="rtl"] .text-right {
    text-align: left;
}

/* Margins and paddings */
html[dir="rtl"] .ms-auto {
    margin-right: auto;
    margin-left: 0;
}

html[dir="rtl"] .me-auto {
    margin-left: auto;
    margin-right: 0;
}

/* Flex direction */
html[dir="rtl"] .flex-row {
    flex-direction: row-reverse;
}

/* Border radius for RTL */
html[dir="rtl"] .rounded-l {
    border-radius: 0 0.25rem 0.25rem 0;
}

html[dir="rtl"] .rounded-r {
    border-radius: 0.25rem 0 0 0.25rem;
}

/* Position adjustments */
html[dir="rtl"] .left-0 {
    left: auto;
    right: 0;
}

html[dir="rtl"] .right-0 {
    right: auto;
    left: 0;
}


/* ============================================================================
   THEME COLORS
   ============================================================================ */

:root {
    --theme-color: #4ECDC4;
    --theme-color-hover: #3db9b0;
    --theme-color-light: rgba(78, 205, 196, 0.1);
}

/* Theme color utilities */
.bg-theme {
    background-color: var(--theme-color) !important;
}

.text-theme {
    color: var(--theme-color) !important;
}

.border-theme {
    border-color: var(--theme-color) !important;
}

.ring-theme {
    --tw-ring-color: var(--theme-color) !important;
}

.hover\:bg-theme:hover {
    background-color: var(--theme-color) !important;
}

.hover\:text-theme:hover {
    color: var(--theme-color) !important;
}

.hover\:border-theme:hover {
    border-color: var(--theme-color) !important;
}

.bg-theme\/10 {
    background-color: var(--theme-color-light) !important;
}

/* Focus states */
.focus\:ring-theme:focus {
    --tw-ring-color: var(--theme-color) !important;
}

.focus\:border-theme:focus {
    border-color: var(--theme-color) !important;
}


/* ============================================================================
   ANIMATIONS
   ============================================================================ */

/* Smooth transitions */
* {
    transition-property: color, background-color, border-color, text-decoration-color, fill, stroke, opacity, box-shadow, transform, filter, backdrop-filter;
    transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
    transition-duration: 150ms;
}

/* Toast animations */
.toast-enter {
    animation: slideIn 0.3s ease-out forwards;
}

.toast-exit {
    animation: slideOut 0.3s ease-in forwards;
}

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

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

/* RTL toast animations */
html[dir="rtl"] .toast-enter {
    animation: slideInRTL 0.3s ease-out forwards;
}

html[dir="rtl"] .toast-exit {
    animation: slideOutRTL 0.3s ease-in forwards;
}

@keyframes slideInRTL {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRTL {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(-100%);
        opacity: 0;
    }
}

/* Fade animations */
.fade-in {
    animation: fadeIn 0.3s ease-out forwards;
}

.fade-out {
    animation: fadeOut 0.3s ease-in forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Scale animations */
.scale-in {
    animation: scaleIn 0.3s ease-out forwards;
}

@keyframes scaleIn {
    from {
        transform: scale(0.9);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Slide up animation */
.slide-up {
    animation: slideUp 0.3s ease-out forwards;
}

@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Bounce animation */
.bounce-in {
    animation: bounceIn 0.5s ease-out forwards;
}

@keyframes bounceIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}


/* ============================================================================
   LOADING SPINNER
   ============================================================================ */

.spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    animation: spin 0.8s linear infinite;
}

.spinner-dark {
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--theme-color);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Shake animation for validation */
@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 ease-in-out;
}

html[dir="rtl"] .shake {
    animation: shakeRTL 0.5s ease-in-out;
}

@keyframes shakeRTL {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(5px); }
    20%, 40%, 60%, 80% { transform: translateX(-5px); }
}


/* ============================================================================
   SCROLLBAR
   ============================================================================ */

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* Hide scrollbar but allow scrolling */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}

.no-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}


/* ============================================================================
   MODAL BACKDROP
   ============================================================================ */

.modal-backdrop {
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}


/* ============================================================================
   FORM ELEMENTS
   ============================================================================ */

/* Input focus states */
input:focus,
textarea:focus,
select:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--theme-color-light);
}

/* Placeholder styling */
::placeholder {
    color: #9ca3af;
    opacity: 1;
}

html[dir="rtl"] ::placeholder {
    text-align: right;
}

/* OTP input styling */
.otp-input:focus {
    border-color: var(--theme-color);
    box-shadow: 0 0 0 3px var(--theme-color-light);
}

/* Number input - hide arrows */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
}


/* ============================================================================
   BUTTONS
   ============================================================================ */

/* Button hover effects */
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Primary button gradient */
.btn-primary {
    background: linear-gradient(135deg, var(--theme-color) 0%, #3db9b0 100%);
    color: white;
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    border-radius: 0.75rem;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(78, 205, 196, 0.4);
}

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


/* ============================================================================
   CARDS
   ============================================================================ */

/* Card hover effect */
.card-hover {
    transition: all 0.3s ease;
}

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


/* ============================================================================
   TEXT UTILITIES
   ============================================================================ */

/* Line clamp */
.line-clamp-1 {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.line-clamp-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Text truncate */
.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* ============================================================================
   NAVIGATION
   ============================================================================ */

/* Active nav link */
.nav-link.active {
    background-color: rgba(78, 205, 196, 0.1);
    color: var(--theme-color);
}

/* Category tab active state */
.category-tab.active {
    background-color: var(--theme-color);
    color: white;
}


/* ============================================================================
   SIDEBAR
   ============================================================================ */

/* Sidebar transition */
#sidebar {
    transition: transform 0.3s ease;
}

/* RTL sidebar position */
html[dir="rtl"] #sidebar {
    left: auto;
    right: 0;
}


/* ============================================================================
   CART DRAWER
   ============================================================================ */

/* Cart drawer position */
#cart-drawer {
    transition: transform 0.3s ease;
}

html[dir="rtl"] #cart-drawer {
    left: 0;
    right: auto;
}


/* ============================================================================
   IMAGE STYLING
   ============================================================================ */

/* Image placeholder */
.img-placeholder {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Aspect ratios */
.aspect-square {
    aspect-ratio: 1 / 1;
}

.aspect-video {
    aspect-ratio: 16 / 9;
}


/* ============================================================================
   QR CODE
   ============================================================================ */

/* QR code container */
.qr-container {
    background: white;
    padding: 1rem;
    border-radius: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.qr-container img {
    image-rendering: pixelated;
}


/* ============================================================================
   RESPONSIVE ADJUSTMENTS
   ============================================================================ */

/* Mobile adjustments */
@media (max-width: 640px) {
    /* Smaller toast on mobile */
    #toast-container {
        left: 1rem;
        right: 1rem;
        max-width: none;
    }
    
    /* Full width modals on mobile */
    .modal-content {
        margin: 0;
        border-radius: 1.5rem 1.5rem 0 0;
    }
}

/* Tablet and up */
@media (min-width: 768px) {
    /* Hover effects only on non-touch */
    @media (hover: hover) {
        .menu-item:hover {
            transform: translateY(-2px);
        }
    }
}


/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
    /* Hide interactive elements */
    button,
    .no-print,
    #cart-drawer,
    #toast-container,
    #loading-overlay {
        display: none !important;
    }
    
    /* Ensure backgrounds print */
    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}


/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

/* Focus visible for keyboard navigation */
:focus-visible {
    outline: 2px solid var(--theme-color);
    outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .bg-theme {
        background-color: #008080 !important;
    }
    
    .text-theme {
        color: #006666 !important;
    }
}
