@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --secondary: #7c3aed;
    --accent: #ec4899;
    --bg-gradient: linear-gradient(135deg, #eef2f6 0%, #dbe4ea 100%);
}

* {
    -webkit-tap-highlight-color: transparent;
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    overflow-x: hidden;
    width: 100%;
    height: 100%;
}

body { 
    font-family: 'Inter', sans-serif; 
    background: var(--bg-gradient);
    min-height: 100vh;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

#app, .container, main, .max-w-7xl {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

main {
    padding-bottom: 70px;
    padding-top: 60px;
    min-height: 100vh;
}
@media (min-width: 768px) {
    main {
        padding-bottom: 0;
        padding-top: 70px;
    }
}

img, video {
    max-width: 100%;
    height: auto;
    display: block;
}

video {
    background: #000;
    object-fit: cover;
    width: 100%;
    height: auto;
    max-height: 500px;
}

.zoomable-image {
    touch-action: pinch-zoom;
    cursor: zoom-in;
}

.post-card { 
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); 
    will-change: transform;
    contain: layout style paint;
}
.post-card:hover { transform: translateY(-3px); box-shadow: 0 20px 40px rgba(0,0,0,0.12); }
.like-anim { animation: likePop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes likePop { 0% { transform: scale(1); } 50% { transform: scale(1.3); } 100% { transform: scale(1); } }
.slide-in { animation: slideIn 0.4s ease-out; }
@keyframes slideIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
.modal-enter { animation: modalEnter 0.25s cubic-bezier(0.4, 0, 0.2, 1); }
@keyframes modalEnter { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.sold-badge { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.admin-badge { background: linear-gradient(135deg, #ff6b6b 0%, #ee5a6f 100%); }
.seller-badge { background: linear-gradient(135deg, #00d2ff 0%, #3a7bd5 100%); }
.float-anim { animation: float 3s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.btn-press:active { transform: scale(0.96); }
.glass-panel { background: rgba(255,255,255,0.9); backdrop-filter: blur(12px); border: 1px solid rgba(255,255,255,0.5); }
.gradient-text{background:linear-gradient(135deg,#4f46e5 0%,#7c3aed 100%);-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent;color:transparent;}
.shimmer { background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent); background-size: 200% 100%; animation: shimmer 2s infinite; }
@keyframes shimmer { 0% { background-position: -200% 0; } 100% { background-position: 200% 0; } }

/* RTL Support */
[dir="rtl"] .flex-row { flex-direction: row-reverse; }
[dir="rtl"] .text-left { text-align: right; }
[dir="rtl"] .text-right { text-align: left; }
[dir="rtl"] .mr-1 { margin-right: 0; margin-left: 0.25rem; }
[dir="rtl"] .mr-2 { margin-right: 0; margin-left: 0.5rem; }
[dir="rtl"] .ml-1 { margin-left: 0; margin-right: 0.25rem; }
[dir="rtl"] .ml-2 { margin-left: 0; margin-right: 0.5rem; }
[dir="rtl"] .ml-4 { margin-left: 0; margin-right: 1rem; }

.lang-btn {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}
.lang-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.lang-btn:not(.active) {
    background: transparent;
    color: #6b7280;
    border-color: #e5e7eb;
}
.lang-btn:not(.active):hover {
    border-color: var(--primary);
    color: var(--primary);
}

.notif-pulse {
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

.view-count {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: #9ca3af;
    font-size: 12px;
}

button, .btn-press, .lang-btn, .admin-tab, .post-card, 
[onclick], .cursor-pointer, a, .view-count {
    touch-action: manipulation;
    cursor: pointer;
}

#mediaModalContent img, #mediaModalContent video {
    touch-action: pinch-zoom;
}

/* Progress bar */
.progress-bar {
    transition: width 0.3s ease;
}
.upload-progress {
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
}

/* Pull to refresh */
.pull-to-refresh {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    z-index: 1000;
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    transform: translateY(-100%);
    transition: transform 0.2s;
    pointer-events: none;
}
.pull-to-refresh .spinner {
    width: 30px;
    height: 30px;
    border: 3px solid rgba(79, 70, 229, 0.2);
    border-top-color: #4f46e5;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.pull-to-refresh.show {
    transform: translateY(0);
}

/* ===== MOBILE OPTIMIZATIONS ===== */
@media (max-width: 768px) {
    html { font-size: 14px; }
    .max-w-7xl {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    .grid {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    .px-4 {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    .fixed.bottom-0 {
        z-index: 1000;
    }
    body {
        font-size: 14px;
    }
    .post-card .font-bold.text-xl {
        font-size: 1.1rem;
    }
    .overflow-x-hidden {
        overflow-x: hidden !important;
    }
    #app, main, .container {
        overflow-x: hidden;
    }
    /* Fix header on mobile */
    header {
        padding-left: 0.5rem !important;
        padding-right: 0.5rem !important;
    }
    header h1 {
        font-size: 1rem !important;
    }
    /* Fix post card padding */
    .post-card .p-4 {
        padding: 0.75rem !important;
    }
    .post-card .p-5 {
        padding: 0.75rem !important;
    }
    /* Fix buttons */
    .post-card button {
        padding: 0.375rem 0.5rem !important;
        font-size: 0.75rem;
    }
    .post-card .fa-heart,
    .post-card .fa-info-circle,
    .post-card .fa-share-alt {
        font-size: 1.1rem !important;
    }
    /* Fix image/video height */
    .post-card video,
    .post-card img {
        max-height: 350px !important;
    }
    /* Fix modal */
    #modalContent {
        margin: 0.5rem;
        max-height: 95vh;
    }
    /* Fix search */
    #mobileSearchInput {
        padding: 0.75rem 1rem 0.75rem 2.5rem !important;
    }
    /* Fix admin tabs */
    .admin-tab {
        padding: 0.75rem 0.75rem !important;
        font-size: 0.7rem !important;
    }
    .admin-tab i {
        margin-right: 0.25rem !important;
    }
    /* Fix form inputs */
    input, select, textarea {
        padding: 0.625rem 0.75rem !important;
    }
    /* Fix bottom nav */
    nav.fixed.bottom-0 button {
        padding: 0.25rem 0.5rem !important;
    }
    nav.fixed.bottom-0 .text-\[10px\] {
        font-size: 0.6rem !important;
    }
    /* Fix profile */
    .h-48.md\:h-64 {
        height: 120px !important;
    }
    .-mt-16 {
        margin-top: -2.5rem !important;
    }
    .w-32.h-32 {
        width: 5rem !important;
        height: 5rem !important;
    }
    /* Fix auth forms */
    .min-h-\[80vh\] > div {
        padding: 1.5rem !important;
        margin: 0.5rem !important;
    }
    /* Fix seller register */
    #accountSection {
        padding: 0.75rem !important;
    }
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
.post-card {
    contain: layout style paint;
    content-visibility: auto;
    contain-intrinsic-size: 0 500px;
}

.post-card * {
    will-change: auto;
}

/* Reduce motion for performance */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Hardware acceleration for animations */
.like-anim,
.slide-in,
.modal-enter,
.float-anim {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Optimize scrolling */
#feedContainer {
    overscroll-behavior-y: contain;
}

/* Fast tap response */
button, a, [onclick] {
    touch-action: manipulation;
    -webkit-touch-callout: none;
    user-select: none;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}
@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* WhatsApp button blinking/pulse animation */
.whatsapp-pulse {
    animation: whatsappBlink 2s ease-in-out infinite;
    position: relative;
}
.whatsapp-pulse::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: inherit;
    background: rgba(16, 185, 129, 0.3);
    animation: whatsappRing 2s ease-in-out infinite;
    z-index: -1;
}
@keyframes whatsappBlink {
    0%, 100% { 
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4), 0 10px 15px -3px rgba(16, 185, 129, 0.2);
    }
    50% { 
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0), 0 10px 15px -3px rgba(16, 185, 129, 0.3);
    }
}
@keyframes whatsappRing {
    0%, 100% { 
        transform: scale(1);
        opacity: 0.6;
    }
    50% { 
        transform: scale(1.05);
        opacity: 0;
    }
}