@import 'https://cdn.jsdelivr.net/npm/tailwindcss@2.2.19/dist/tailwind.min.css';

/* Custom styles */
.post-image {
    max-height: 500px;
    object-fit: cover;
}

/* Global three-dot menu positioning for all devices */
.three-dot-menu {
    position: absolute !important;
    top: 1px !important;
    right: 1px !important;
    z-index: 30 !important;
    background-color: rgba(0, 0, 0, 0.6) !important;
    border-radius: 50% !important;
    padding: 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: all 0.2s ease !important;
}

.three-dot-menu:hover {
    background-color: rgba(0, 0, 0, 0.8) !important;
    transform: scale(1.1) !important;
}

.three-dot-menu:active {
    background-color: rgba(0, 0, 0, 0.9) !important;
    transform: scale(1.05) !important;
}

/* Mobile responsive post cards */
@media (max-width: 768px) {
    /* Remove container padding for full width on mobile */
    .container {
        padding-left: 0 !important;
        padding-right: 0 !important;
        max-width: 100% !important;
    }
    
    /* Post card improvements - full width no margins */
    .post {
        margin: 0 !important;
        border-radius: 0;
        box-shadow: none;
        border-bottom: 8px solid #f3f4f6;
        width: 100vw !important;
        margin-left: calc(-50vw + 50%) !important;
    }
    
    /* Video and image - full height display */
    .post-image, .post-video {
        max-height: none !important;
        height: auto !important;
        object-fit: contain !important;
        border-radius: 0;
        width: 100% !important;
    }
    
    /* Better spacing for mobile */
    .post .p-4 {
        padding: 1rem;
    }
    
    /* Improved text sizing for mobile */
    .post p {
        font-size: 0.9rem;
        line-height: 1.4;
    }
    
    /* Better button sizing for mobile */
    .post button {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Full width cards on mobile */
    .space-y-4 > * {
        width: 100% !important;
    }
    
    /* Mobile navigation search */
    .max-w-7xl {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    /* Search input responsive */
    form input[type="text"] {
        width: 100%;
        max-width: 200px;
    }
    
    /* Mobile-specific improvements for three-dot menu */
    .three-dot-menu {
        min-height: 20px !important;
        min-width: 20px !important;
    }
    
    /* Improved audio toggle button positioning */
    .audio-toggle {
        position: absolute !important;
        bottom: 12px !important;
        right: 12px !important;
        z-index: 30 !important;
        background-color: rgba(0, 0, 0, 0.6) !important;
        border-radius: 50% !important;
        padding: 8px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Remove space between posts on mobile */
    .space-y-4 {
        gap: 0 !important;
    }
    
    .space-y-4 > * + * {
        margin-top: 0 !important;
    }
    
    /* Create post form full width on mobile */
    .mb-6 {
        margin-left: calc(-50vw + 50%) !important;
        width: 100vw !important;
        border-radius: 0 !important;
        margin-bottom: 0 !important;
        border-bottom: 8px solid #f3f4f6;
    }
    
    /* Floating action buttons responsive positioning */
    .fixed.bottom-4.left-4,
    .fixed.bottom-4.right-4 {
        bottom: 16px !important;
        z-index: 60 !important;
    }
    
    .fixed.bottom-4.left-4 {
        left: 16px !important;
    }
    
    .fixed.bottom-4.right-4 {
        right: 16px !important;
    }
    
    /* Profile page specific mobile styles */
    .post-section {
        gap: 0 !important;
    }
    
    .post-section > * {
        width: 100vw !important;
        margin-left: calc(-50vw + 50%) !important;
        border-radius: 0 !important;
        border-bottom: 8px solid #f3f4f6;
        box-shadow: none !important;
    }
    
    /* Video controls enhancement */
    .audio-toggle svg,
    .three-dot-menu svg {
        color: white !important;
        filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
    }
    
    /* Better post image/video container */
    .post .relative {
        position: relative !important;
        overflow: hidden;
    }
}

.like-button {
    cursor: pointer;
    transition: color 0.3s ease;
}

.like-button.liked {
    color: red;
}

.comment-form textarea {
    resize: vertical;
}

/* Three-dot menu styles */
.three-dot-menu {
    transition: opacity 0.3s ease;
}

.three-dot-menu:hover {
    opacity: 0.8;
}

/* Delete confirmation modal styles */
#deleteConfirmModal {
    background-color: rgba(0, 0, 0, 0.5);
}

#deleteConfirmModal .bg-white {
    border-radius: 0.5rem;
}

#confirmDelete:hover {
    background-color: #dc2626;
}

#cancelDelete:hover {
    background-color: #f3f4f6;
}

/* Dropdown menu z-index and positioning */
.dropdown-menu {
    z-index: 50;
    position: absolute;
    right: 0;
    margin-top: 0.5rem;
    min-width: 10rem;
    border-radius: 0.375rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Ensure dropdown container has proper positioning */
.relative {
    position: relative;
}

/* Map container styles */
.map-container {
    width: 100%;
    height: 300px;
    border-radius: 0.5rem;
    overflow: hidden;
    margin-bottom: 2rem;  /* Reduced margin while still avoiding overlap with floating icons */
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    position: relative;
    z-index: 10;  /* Lower than floating icons */
}

/* Video play/pause icon styles */
.video-play-pause-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 32px;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: 20;
}

.video-play-pause-icon.show {
    opacity: 1;
}

.video-play-pause-icon.fade-out {
    opacity: 0;
}

/* Video performance optimizations */
.post-video {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    /* Optimized buffering */
    preload: metadata;
    /* Prevent stuttering */
    object-fit: cover;
    image-rendering: optimizeSpeed;
    /* Hardware acceleration */
    -webkit-transform: translate3d(0, 0, 0);
    transform: translate3d(0, 0, 0);
    /* Smooth playback */
    -webkit-filter: blur(0);
    filter: blur(0);
}

.post-video::-webkit-media-controls {
    display: none !important;
}

.post-video::-webkit-media-controls-enclosure {
    display: none !important;
}

/* Container optimization for videos */
.relative {
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

#map {
    width: 100%;
    height: 100%;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Reduce search bar width for mobile */
    #search-input {
        width: 120px;
    }
    
    #search-input:focus {
        width: 180px;
    }

    /* Adjust modal for mobile devices */
    #postModal .sm\:max-w-lg {
        max-width: 90%;
        margin-left: auto;
        margin-right: auto;
    }

    #postModal .sm\:w-full {
        width: 100%;
    }

    #postModal .sm\:my-8 {
        margin-top: 1rem;
        margin-bottom: 1rem;
    }

    #postModal .sm\:align-middle {
        align-items: flex-start;
    }

    #modalPostCaption {
        font-size: 0.875rem;
        line-height: 1.25rem;
    }

    #modalCommentsList {
        max-height: 60vh;
        overflow-y: auto;
    }

    /* Adjust map container margin for mobile */
    .map-container {
        margin-bottom: 3rem;  /* Reduced margin while maintaining space for floating icons */
    }

    /* Checkout modal mobile adjustments */
    #checkoutModal:not(.hidden) {
        padding: 0.125rem !important;
        display: flex !important;
        align-items: flex-start !important;
        justify-content: center !important;
        min-height: 100vh !important;
        padding-top: 15vh !important;
    }
    
    #checkoutModal.hidden {
        display: none !important;
    }

    #checkoutModal .relative {
        width: 100% !important;
        max-width: 96vw !important;
        max-height: 85vh !important;
        margin: 0 auto !important;
        overflow-y: auto !important;
    }

    #checkoutModal h3 {
        font-size: 0.9rem !important;
        margin-bottom: 0.75rem !important;
        text-align: center !important;
    }

    #checkoutModal .mb-4 {
        margin-bottom: 0.75rem !important;
    }

    #checkoutModal .mb-3 {
        margin-bottom: 0.5rem !important;
    }

    #checkoutModal .space-y-1 > div {
        margin-bottom: 0.25rem !important;
    }

    #checkoutModal input[type="radio"] {
        transform: scale(1.1) !important;
        margin-right: 0.5rem !important;
    }

    #checkoutModal label {
        font-size: 0.85rem !important;
        line-height: 1.2 !important;
        cursor: pointer !important;
        margin-bottom: 0.25rem !important;
    }

    #checkoutModal .flex.items-center {
        min-height: 2rem !important;
        align-items: center !important;
        cursor: pointer !important;
        padding: 0.1rem 0 !important;
    }

    #checkoutModal .flex.items-center label {
        margin-bottom: 0 !important;
        font-size: 0.8rem !important;
    }

    #checkoutModal button {
        min-height: 2.25rem !important;
        font-size: 0.85rem !important;
        padding: 0.5rem 0.75rem !important;
    }

    #checkoutModal .bg-gray-50 {
        padding: 0.5rem !important;
    }

    #checkoutModal #delivery-message p {
        font-size: 0.75rem !important;
        margin-top: 0.25rem !important;
    }
}

/* General z-index hierarchy */
.post-card {
    z-index: 10;
}

.cart-button, .messages-button {
    z-index: 40;
}

/* Search bar styles */
#search-input {
    transition: all 0.3s ease;
    width: 160px;
}

#search-input:focus {
    width: 240px;
}

.ui-autocomplete {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
}

.ui-menu-item {
    padding: 8px 12px;
    cursor: pointer;
}

.ui-menu-item:hover {
    background-color: #f3f4f6;
}

.ui-menu-item-wrapper {
    display: flex;
    align-items: center;
}

.ui-menu-item-wrapper svg {
    margin-right: 8px;
}

/* Profile page styles */
.post-card {
    transition: transform 0.3s ease;
}

.post-card:hover {
    transform: translateY(-5px);
}

.post-card img {
    transition: opacity 0.3s ease;
}

.post-card img:hover {
    opacity: 0.8;
}

/* Profile avatar placeholder */
.profile-avatar-placeholder {
    width: 6rem;
    height: 6rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    color: #ffffff;
    background-color: #4a5568;
}

/* Responsive adjustments for profile page */
@media (max-width: 640px) {
    .profile-header {
        flex-direction: column;
        align-items: center;
    }

    .profile-avatar-placeholder {
        margin-bottom: 1rem;
    }

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

    .profile-stats {
        flex-wrap: wrap;
        justify-content: center;
    }

    .profile-stat {
        flex-basis: 33.333%;
        margin-bottom: 1rem;
    }
}

/* Full-width store/catalog on desktop screens */
@media (min-width: 1024px) {
    html {
        overflow-x: hidden;
    }
    
    body main.container {
        max-width: none !important;
        width: 100vw !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: calc(-50vw + 50%) !important;
        margin-right: calc(-50vw + 50%) !important;
    }
    
    body main.container > .container,
    body main.container > div,
    body main.container > .store-content-wrapper {
        max-width: 100% !important;
        width: 100% !important;
        padding-left: 2rem !important;
        padding-right: 2rem !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Store-specific: remove border radius and make elements full width */
    body main.container .free-shipping-banner {
        border-radius: 0 !important;
        margin-left: -2rem !important;
        margin-right: -2rem !important;
        padding-left: 2rem !important;
        padding-right: 2rem !important;
        width: calc(100% + 4rem) !important;
    }
    
    body main.container .store-slider {
        border-radius: 0 !important;
        margin-left: -2rem !important;
        margin-right: -2rem !important;
        width: calc(100% + 4rem) !important;
    }
    
    /* Ensure nav also extends full width */
    nav .max-w-7xl {
        max-width: 100% !important;
    }
}

/* Full-width store pages on desktop */
@media (min-width: 1024px) {
    body.store-page {
        background-color: inherit !important;
    }
    
    body.store-page main.container {
        max-width: 100% !important;
        width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    body.store-page .store-content-wrapper {
        max-width: 100% !important;
        width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
}

/* ==================== AUTH PAGES - MOBILE IMPROVEMENTS ==================== */

/* Auth container base styles */
.auth-container {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: calc(100vh - 64px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1rem;
}

.auth-card {
    background: white;
    border-radius: 1.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 400px;
    overflow: hidden;
}

.auth-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 2rem 1.5rem;
    text-align: center;
    color: white;
}

.auth-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.auth-header p {
    opacity: 0.9;
    font-size: 0.95rem;
}

.auth-body {
    padding: 1.5rem;
}

.auth-form-group {
    margin-bottom: 1.25rem;
}

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

.auth-input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    font-size: 1rem;
    transition: all 0.2s ease;
    background-color: #f9fafb;
}

.auth-input:focus {
    outline: none;
    border-color: #667eea;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.auth-input::placeholder {
    color: #9ca3af;
}

.auth-btn-primary {
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 14px 0 rgba(102, 126, 234, 0.39);
}

.auth-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(102, 126, 234, 0.5);
}

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

.auth-btn-biometric {
    width: 100%;
    padding: 0.875rem 1.5rem;
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: white;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.auth-btn-biometric:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px 0 rgba(79, 70, 229, 0.5);
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: 1.5rem 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid #e5e7eb;
}

.auth-divider span {
    padding: 0 1rem;
    color: #6b7280;
    font-size: 0.875rem;
}

.auth-checkbox-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.auth-checkbox-group input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    border-radius: 0.25rem;
    accent-color: #667eea;
}

.auth-checkbox-group label {
    color: #4b5563;
    font-size: 0.875rem;
}

.auth-link {
    color: #667eea;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.2s ease;
}

.auth-link:hover {
    color: #764ba2;
    text-decoration: underline;
}

.auth-footer {
    padding: 1rem 1.5rem 1.5rem;
    text-align: center;
    background: #f9fafb;
    border-top: 1px solid #e5e7eb;
}

.auth-footer p {
    color: #6b7280;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.auth-security-notice {
    background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
    border: 1px solid #bfdbfe;
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1.25rem;
}

.auth-security-notice h4 {
    color: #1e40af;
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.auth-security-notice p {
    color: #3b82f6;
    font-size: 0.8rem;
    line-height: 1.4;
}

.auth-success-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    background: #dcfce7;
    color: #166534;
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.auth-phone-group {
    display: flex;
    gap: 0.5rem;
}

.auth-phone-group select {
    width: 40%;
    padding: 0.875rem 0.5rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    background-color: #f9fafb;
    cursor: pointer;
}

.auth-phone-group select:focus {
    outline: none;
    border-color: #667eea;
    background-color: white;
}

.auth-phone-group input {
    flex: 1;
}

.auth-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: white;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    opacity: 0.9;
    transition: opacity 0.2s ease;
}

.auth-back-link:hover {
    opacity: 1;
}

.auth-legal-links {
    font-size: 0.75rem;
    color: #9ca3af;
    line-height: 1.6;
}

.auth-legal-links a {
    color: #667eea;
    text-decoration: none;
}

.auth-legal-links a:hover {
    text-decoration: underline;
}

/* Mobile-specific auth adjustments */
@media (max-width: 640px) {
    .auth-container {
        padding: 0.75rem;
        align-items: flex-start;
        padding-top: 1rem;
    }
    
    .auth-card {
        border-radius: 1.25rem;
        margin-top: 0;
    }
    
    .auth-header {
        padding: 1.5rem 1.25rem;
    }
    
    .auth-header h2 {
        font-size: 1.5rem;
    }
    
    .auth-body {
        padding: 1.25rem;
    }
    
    .auth-input {
        padding: 0.75rem 0.875rem;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .auth-btn-primary,
    .auth-btn-biometric {
        padding: 0.875rem 1.25rem;
        font-size: 0.95rem;
    }
    
    .auth-phone-group {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .auth-phone-group select {
        width: 100%;
    }
    
    .auth-footer {
        padding: 1rem;
    }
    
    .auth-security-notice {
        padding: 0.875rem;
    }
}
