/* Enhanced Mobile Responsiveness for all devices */

/* Extra Small Devices (320px - 374px) */
@media (max-width: 374px) {
    :root {
        --radius-sm: 4px;
        --radius: 6px;
        --radius-lg: 8px;
    }
    
    body {
        font-size: 14px;
    }
    
    .container {
        padding: 0 8px;
    }
    
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
    
    h3 {
        font-size: 1.1rem;
    }
    
    .btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    .chat-header {
        padding: 8px 8px !important;
        gap: 8px !important;
    }
    
    .logo-container img {
        max-height: 35px;
    }
    
    .unimart-logo {
        max-height: 35px;
        width: auto;
    }
    
    /* Admin dashboard stats grid */
    .admin-dashboard .stats-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }
    
    .stat-card {
        padding: 16px;
    }
    
    /* Sidebar narrower for small screens */
    .sidebar {
        position: fixed;
        left: -260px;
        width: 260px;
        height: 100vh;
        transition: left 0.3s ease;
        z-index: 999;
    }
}

/* Small Devices (375px - 599px) */
@media (max-width: 599px) {
    .product-card {
        max-width: 100%;
    }
    
    .marketplace-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    
    .hero-grid {
        display: flex !important;
        flex-direction: column !important;
        gap: 24px !important;
    }
    
    .toggle-sidebar {
        display: block !important;
    }
    
    .sidebar {
        position: fixed;
        left: -280px;
        width: 280px;
        height: 100vh;
        transition: left 0.3s ease;
        z-index: 999;
    }
    
    .sidebar.open {
        left: 0;
    }
    
    
    /* Announcement ticker - readable and not too fast */
    .announcement-ticker {
        padding: 8px 0;
    }
    
    .ticker-item {
        padding: 0 20px;
        font-size: 0.85rem;
    }
    
    /* Contact panel adjustments */
    .contact-panel {
        right: auto !important;
        left: 8px !important;
        top: 60px !important;
        min-width: 150px !important;
        min-height: auto !important;
    }
    
    /* Admin dashboard stats grid */
    .admin-dashboard .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 16px;
    }
}

/* Medium Devices (600px - 767px) */
@media (min-width: 600px) and (max-width: 767px) {
    .marketplace-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .product-card {
        border-radius: var(--radius);
    }
    
    /* Admin dashboard stats grid */
    .admin-dashboard .stats-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 20px;
    }
}

/* Tablets and larger (768px+) */
@media (min-width: 768px) {
    .marketplace-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 24px;
    }
    
    .product-card {
        transition: transform 0.3s ease, box-shadow 0.3s ease;
    }
    
    .product-card:hover {
        transform: translateY(-4px);
        box-shadow: var(--shadow-lg);
    }
}

/* Chat responsiveness handled by chat.css */

/* Emoji fixes for all screens */
p.message-text {
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
    vertical-align: baseline;
}

/* Ensure logo displays properly on all screens */
.unimart-logo {
    max-height: 40px;
    width: auto;
    display: block;
    object-fit: contain;
}

.logo-container {
    display: flex;
    align-items: center;
    padding: 8px 0;
}

/* Fix announcement ticker on mobile */
@media (max-width: 480px) {
    .announcement-ticker {
        padding: 10px 0;
    }
    
    .ticker-content {
        animation: ticker 14s linear infinite;
    }
}

/* Ensure readable font sizes across all devices */
@media (max-width: 599px) {
    body {
        font-size: 14px;
    }
    
    .message-text {
        font-size: 0.95rem;
    }
    
    .btn-sm {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
}

/* Fix flex layouts on mobile */
@media (max-width: 599px) {
    .flex {
        flex-direction: column;
        gap: 12px;
    }
    
    .grid {
        grid-template-columns: 1fr;
    }
    
    .gap-4 {
        gap: 12px;
    }
}

/* Contact info visibility on chat */
.contact-panel {
    position: absolute !important;
    background: white !important;
    border-radius: var(--radius-lg) !important;
    box-shadow: var(--shadow-lg) !important;
    padding: 16px !important;
    z-index: 1000 !important;
    min-width: 200px !important;
    max-width: 90vw !important;
}

[data-theme="dark"] .contact-panel {
    background: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}
