/* Arabic Fonts Shop - Custom Styles */

/* RTL Support */
[dir="rtl"] {
    text-align: right;
}

[dir="rtl"] .space-x-reverse > * + * {
    margin-right: 0.5rem;
    margin-left: 0;
}

[dir="rtl"] .ml-2 {
    margin-left: 0;
    margin-right: 0.5rem;
}

[dir="rtl"] .mr-2 {
    margin-right: 0;
    margin-left: 0.5rem;
}

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

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

/* Font Preview Styles */
.font-preview-container {
    min-height: 200px;
    border: 2px dashed #e5e7eb;
    border-radius: 0.5rem;
    padding: 1rem;
    background-color: #f9fafb;
    transition: border-color 0.3s ease;
}

.font-preview-container:hover {
    border-color: #3b82f6;
}

.font-preview-text {
    font-size: 1.5rem;
    line-height: 1.6;
    color: #374151;
    text-align: center;
    margin: 0;
}

.font-preview-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.font-size-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.font-size-slider {
    width: 100px;
}

.font-size-display {
    min-width: 40px;
    text-align: center;
    font-weight: 600;
    color: #374151;
}

/* Custom Preview Text Input */
.custom-preview-input {
    flex: 1;
    min-width: 200px;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

/* Font Cards */
.font-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.font-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.font-preview-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
}

.font-placeholder {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1e40af;
    font-size: 3rem;
    font-weight: bold;
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.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 #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Button States */
.btn-loading {
    position: relative;
    color: transparent;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #374151;
}

.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-error {
    color: #dc2626;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* File Upload */
.file-upload-area {
    border: 2px dashed #d1d5db;
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    cursor: pointer;
}

.file-upload-area:hover {
    border-color: #3b82f6;
    background-color: #f8fafc;
}

.file-upload-area.dragover {
    border-color: #3b82f6;
    background-color: #eff6ff;
}

.file-upload-icon {
    font-size: 3rem;
    color: #9ca3af;
    margin-bottom: 1rem;
}

.file-upload-text {
    color: #6b7280;
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.file-upload-hint {
    color: #9ca3af;
    font-size: 0.875rem;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination-item {
    padding: 0.5rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    color: #374151;
    text-decoration: none;
    transition: all 0.2s ease;
}

.pagination-item:hover {
    background-color: #f3f4f6;
    border-color: #9ca3af;
}

.pagination-item.active {
    background-color: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

.pagination-item.disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Search Bar */
.search-container {
    position: relative;
    max-width: 500px;
    margin: 0 auto;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid #d1d5db;
    border-radius: 2rem;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
}

[dir="rtl"] .search-input {
    padding-left: 0.75rem;
    padding-right: 2.5rem;
}

[dir="rtl"] .search-icon {
    left: auto;
    right: 0.75rem;
}

/* Filters */
.filter-section {
    background-color: white;
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.filter-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 1rem;
}

.filter-group {
    margin-bottom: 1rem;
}

.filter-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
}

.filter-select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #d1d5db;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

/* Notifications */
.notification {
    position: fixed;
    top: 1rem;
    right: 1rem;
    padding: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

.notification.success {
    background-color: #10b981;
    color: white;
}

.notification.error {
    background-color: #ef4444;
    color: white;
}

.notification.warning {
    background-color: #f59e0b;
    color: white;
}

.notification.info {
    background-color: #3b82f6;
    color: white;
}

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

/* Mobile App Enhancements */
@media (max-width: 768px) {
    /* Full screen app experience */
    html, body {
        height: 100%;
        overflow-x: hidden;
    }
    
    body {
        position: relative;
    }
    
    /* App-like header */
    header {
        position: sticky;
        top: 0;
        z-index: 50;
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        background: rgba(255, 255, 255, 0.95);
        overflow: visible !important;
    }
    
    /* Better card design for mobile */
    .font-card,
    .bg-white.rounded-lg.shadow {
        border-radius: 1rem;
        margin-bottom: 1rem;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        transition: all 0.2s ease;
    }
    
    .font-card:active,
    .bg-white.rounded-lg.shadow:active {
        transform: scale(0.98);
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
    }
    
    /* Grid improvements */
    .grid {
        gap: 1rem;
    }
    
    /* Better button sizes */
    button, .btn, a.btn {
        min-height: 48px;
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
        border-radius: 0.75rem;
    }
    
    /* Input improvements */
    input, select, textarea {
        min-height: 48px;
        font-size: 16px; /* Prevents zoom on iOS */
        border-radius: 0.75rem;
    }
    
    /* Better spacing */
    section {
        padding: 1.5rem 1rem;
    }
    
    /* Hide scrollbar but keep functionality */
    .mobile-menu-body::-webkit-scrollbar {
        width: 4px;
    }
    
    .mobile-menu-body::-webkit-scrollbar-track {
        background: transparent;
    }
    
    .mobile-menu-body::-webkit-scrollbar-thumb {
        background: #d1d5db;
        border-radius: 2px;
    }
}

/* Mobile Responsive & PWA Styles */
@media (max-width: 768px) {
    .font-preview-container {
        min-height: 150px;
        padding: 0.75rem;
    }
    
    .font-preview-text {
        font-size: 1.25rem;
    }
    
    .font-preview-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .custom-preview-input {
        min-width: auto;
    }
    
    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .pagination-item {
        padding: 0.375rem 0.5rem;
        font-size: 0.875rem;
    }
    
    /* Mobile App-like Styles */
    body {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
        overscroll-behavior-y: contain;
    }
    
    /* Allow text selection in content areas */
    main, p, span, h1, h2, h3, h4, h5, h6 {
        -webkit-user-select: text;
        user-select: text;
    }
    
    /* Safe area for notched devices */
    header {
        padding-top: env(safe-area-inset-top);
    }
    
    footer {
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    /* Touch-friendly buttons */
    button, a.btn, .btn {
        min-height: 44px;
        min-width: 44px;
        touch-action: manipulation;
    }
    
    /* Smooth scrolling */
    * {
        -webkit-overflow-scrolling: touch;
    }
    
    /* Card improvements for mobile */
    .font-card {
        border-radius: 1rem;
        overflow: hidden;
        transition: all 0.2s ease;
    }
    
    .font-card:active {
        transform: scale(0.98);
    }
    
    /* Better spacing on mobile */
    .container, .max-w-7xl {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Grid improvements */
    .grid {
        gap: 1rem;
    }
    
    /* Better font cards on mobile */
    .font-card .aspect-w-16 {
        height: 200px;
    }
    
    /* Full width sections on mobile */
    section {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Better buttons */
    button, .btn {
        min-height: 48px;
        font-size: 1rem;
    }
    
    /* Hide desktop navigation on mobile */
    nav.hidden.md\:flex {
        display: none !important;
    }
}

/* PWA Specific Styles */
@media (display-mode: standalone) {
    /* Styles when app is installed as PWA */
    header {
        padding-top: env(safe-area-inset-top);
    }
    
    body {
        background-color: #ffffff;
    }
    
    /* Hide browser UI elements */
    .pwa-install-banner {
        display: none;
    }
    
    /* Full screen experience */
    .mobile-bottom-nav {
        padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    }
}

/* Additional Mobile App Enhancements */
@media (max-width: 768px) {
    /* Smooth page transitions */
    @keyframes fadeIn {
        from {
            opacity: 0;
        }
        to {
            opacity: 1;
        }
    }
    
    main {
        animation: fadeIn 0.3s ease;
    }
    
    /* Better image loading */
    img {
        loading: lazy;
    }
    
    /* Prevent text selection on UI elements */
    button, .btn, .mobile-nav-item, .mobile-menu-item {
        -webkit-user-select: none;
        user-select: none;
    }
    
    /* Better focus states */
    a:focus, button:focus {
        outline: 2px solid #2563eb;
        outline-offset: 2px;
    }
    
    /* Loading states */
    .loading {
        opacity: 0.6;
        pointer-events: none;
    }
}

/* Safe Area Insets for iOS */
@supports (padding: max(0px)) {
    header {
        padding-top: max(1rem, env(safe-area-inset-top));
    }
    
    footer {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
    
    .mobile-menu {
        padding-left: max(1rem, env(safe-area-inset-left));
        padding-right: max(1rem, env(safe-area-inset-right));
    }
    
    .mobile-bottom-nav {
        padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
    }
}

/* Touch Gestures */
.touch-action-none {
    touch-action: none;
}

.touch-action-pan-x {
    touch-action: pan-x;
}

.touch-action-pan-y {
    touch-action: pan-y;
}

/* Swipe Indicators */
.swipe-indicator {
    position: absolute;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 0.4;
    }
    50% {
        opacity: 1;
    }
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 0.5rem 0;
    padding-bottom: calc(0.5rem + env(safe-area-inset-bottom));
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0.75rem;
    color: #6b7280;
    text-decoration: none;
    font-size: 0.7rem;
    transition: all 0.2s ease;
    position: relative;
    min-width: 60px;
    flex: 1;
}

.mobile-nav-item i {
    font-size: 1.4rem;
    margin-bottom: 0.25rem;
    transition: transform 0.2s ease;
}

.mobile-nav-item span {
    font-weight: 500;
    white-space: nowrap;
}

.mobile-nav-item.active {
    color: #2563eb;
}

.mobile-nav-item.active i {
    transform: scale(1.1);
}

.mobile-nav-item:active {
    transform: scale(0.95);
    opacity: 0.7;
}

.mobile-nav-badge {
    position: absolute;
    top: 0.25rem;
    right: 0.5rem;
    background: #ef4444;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: bold;
    border: 2px solid white;
}

/* Mobile Side Menu */
.mobile-side-menu {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    pointer-events: none;
}

.mobile-side-menu:not(.hidden) {
    pointer-events: all;
}

.mobile-menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-side-menu:not(.hidden) .mobile-menu-overlay {
    opacity: 1;
}

.mobile-menu-content {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 85%;
    max-width: 320px;
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

[dir="rtl"] .mobile-menu-content {
    right: auto;
    left: 0;
    transform: translateX(-100%);
}

.mobile-side-menu:not(.hidden) .mobile-menu-content {
    transform: translateX(0);
}

.mobile-menu-header {
    padding: 1rem;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
}

.mobile-menu-header h3 {
    color: white;
    font-size: 1.125rem;
    margin: 0;
}

.mobile-menu-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.mobile-menu-close:active {
    background: rgba(255, 255, 255, 0.3);
}

.mobile-menu-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
    -webkit-overflow-scrolling: touch;
}

.mobile-menu-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    color: #374151;
    text-decoration: none;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

[dir="rtl"] .mobile-menu-item {
    border-left: none;
    border-right: 3px solid transparent;
}

.mobile-menu-item i {
    width: 24px;
    margin-right: 1rem;
    text-align: center;
    color: #6b7280;
}

[dir="rtl"] .mobile-menu-item i {
    margin-right: 0;
    margin-left: 1rem;
}

.mobile-menu-item:active {
    background: #f3f4f6;
    border-left-color: #2563eb;
}

[dir="rtl"] .mobile-menu-item:active {
    border-left-color: transparent;
    border-right-color: #2563eb;
}

.mobile-menu-item.bg-primary-600 {
    margin: 0.5rem 1rem;
    border-radius: 0.5rem;
    justify-content: center;
}

.mobile-menu-divider {
    margin: 0.5rem 0;
    border: none;
    border-top: 1px solid #e5e7eb;
}

/* Loading Skeleton for Mobile */
.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;
    }
}

/* Pull to Refresh Indicator */
.pull-to-refresh {
    position: fixed;
    top: 1rem;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    border: 3px solid #2563eb;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 1000;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.pull-to-refresh.active {
    opacity: 1;
    top: 2rem;
}

/* Body lock when menu is open */
body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* App-like Page Transitions */
@media (max-width: 768px) {
    main {
        padding-bottom: 80px; /* Space for bottom nav */
        transition: transform 0.3s ease;
    }
    
    /* Card swipe effect */
    .font-card {
        transition: transform 0.2s ease, box-shadow 0.2s ease;
        will-change: transform;
    }
    
    .font-card:active {
        transform: scale(0.98);
    }
    
    /* Better touch targets */
    a, button {
        min-height: 44px;
        min-width: 44px;
        display: inline-flex;
    }
    
    /* Smooth page transitions */
    @keyframes slideIn {
        from {
            opacity: 0;
            transform: translateY(10px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
    
    main > * {
        animation: slideIn 0.3s ease;
    }
    
    /* Full width cards on mobile */
    .font-card,
    .bg-white.rounded-lg {
        margin-left: -1rem;
        margin-right: -1rem;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    /* Better spacing */
    section {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Hide desktop elements */
    .desktop-only {
        display: none !important;
    }
    
    /* Show mobile elements */
    .mobile-only {
        display: block !important;
    }
}

@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .font-preview-container {
        background-color: #1f2937;
        border-color: #374151;
        color: #f9fafb;
    }
    
    .font-preview-text {
        color: #f9fafb;
    }
    
    .font-placeholder {
        background: linear-gradient(135deg, #1e40af 0%, #1e3a8a 100%);
        color: #dbeafe;
    }
}

/* Print Styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .font-card {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #e5e7eb;
    }
}
