/* ==========================================================================
   LowGrocery - Main Stylesheet
   Mobile-first, Notion-inspired minimalist design
   ========================================================================== */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --secondary: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --dark: #1f2937;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-50);
    color: var(--gray-900);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.2;
}

.text-gradient {
    background: linear-gradient(135deg, var(--primary) 0%, #7c3aed 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Header Styles */
.header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--gray-200);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--gray-900);
    text-decoration: none;
}

.logo i {
    color: var(--primary);
    font-size: 1.5rem;
}

/* Navigation */
.nav-desktop {
    display: none;
}

.nav-desktop a {
    color: var(--gray-600);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    transition: color 0.2s;
}

.nav-desktop a:hover {
    color: var(--primary);
}

.nav-desktop .stores-btn {
    background: var(--gray-100);
    color: var(--gray-700);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-desktop .stores-btn:hover {
    background: var(--gray-200);
    color: var(--gray-900);
}

.menu-btn {
    display: block;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-600);
    cursor: pointer;
    padding: 0.5rem;
}

/* Mobile Menu */
.mobile-menu {
    display: none;
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    background: white;
    z-index: 40;
    padding: 1.5rem;
}

.mobile-menu.active {
    display: block;
}

.mobile-menu a {
    display: block;
    padding: 1rem;
    color: var(--gray-700);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid var(--gray-100);
}

.mobile-menu a i {
    width: 24px;
    color: var(--primary);
}

/* Hero Section */
.hero {
    padding: 2rem 0 1.5rem;
    background: linear-gradient(to bottom, white, var(--gray-50));
}

.hero-title {
    font-size: 1.875rem;
    font-weight: 700;
    text-align: center;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

.hero-subtitle {
    text-align: center;
    color: var(--gray-600);
    margin-bottom: 2rem;
    font-size: 1rem;
}

/* Search Section */
.search-section {
    max-width: 600px;
    margin: 0 auto;
}

.search-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--gray-200);
    margin-bottom: 1rem;
}

.search-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    background: var(--gray-100);
    padding: 0.25rem;
    border-radius: var(--radius-lg);
}

.tab-btn {
    flex: 1;
    padding: 0.75rem;
    border: none;
    background: transparent;
    border-radius: var(--radius);
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.tab-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Search Box */
.search-box {
    display: flex;
    align-items: center;
    background: var(--gray-100);
    border-radius: var(--radius-lg);
    padding: 0.25rem;
    border: 1px solid var(--gray-200);
}

.search-icon {
    padding: 0 1rem;
    color: var(--gray-400);
}

.search-input {
    flex: 1;
    padding: 0.875rem 0;
    border: none;
    background: transparent;
    font-size: 1rem;
    outline: none;
}

.search-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.875rem 1.5rem;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

.search-btn:hover {
    background: var(--primary-dark);
}

.search-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.suggestion-chip {
    padding: 0.5rem 1rem;
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    border-radius: 9999px;
    font-size: 0.875rem;
    color: var(--gray-700);
    cursor: pointer;
    transition: all 0.2s;
}

.suggestion-chip:hover {
    background: var(--gray-200);
    border-color: var(--gray-300);
}

/* Find Stores CTA Button */
.stores-cta-btn {
    width: 100%;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 1.125rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    box-shadow: var(--shadow-lg);
    transition: transform 0.2s, box-shadow 0.2s;
    margin-top: 1rem;
}

.stores-cta-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.stores-cta-btn i:first-child {
    font-size: 1.25rem;
}
/* Action Buttons Row */
.action-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    flex-direction: column;
}

@media (min-width: 480px) {
    .action-buttons {
        flex-direction: row;
    }
}

.action-btn {
    flex: 1;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.action-btn.primary {
    background: linear-gradient(135deg, var(--primary) 0%, #4f46e5 100%);
    color: white;
    box-shadow: var(--shadow-lg);
}

.action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.action-btn.secondary {
    background: white;
    color: var(--gray-800);
    border: 2px solid var(--gray-200);
    box-shadow: var(--shadow);
}

.action-btn.secondary:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Header Shopping List Button */
.header-list-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: white;
    color: var(--gray-800);
    border: 2px solid var(--gray-200);
    padding: 0.5rem 1.25rem;
    border-radius: 9999px;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.header-list-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.header-list-btn i {
    font-size: 1rem;
    color: var(--primary);
}

/* Update nav-desktop to accommodate new button */
.nav-desktop {
    display: none;
    align-items: center;
    gap: 0.75rem;
}

@media (min-width: 768px) {
    .nav-desktop {
        display: flex;
    }
}

/* Sticky Header Button */
.header-stores-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.2s;
    white-space: nowrap;
}

.header-stores-btn:hover {
    background: var(--primary-dark);
}

.header-stores-btn i {
    font-size: 1rem;
}

/* Nearby Stores Section */
.nearby-stores-section {
    padding: 2rem 0;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.section-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-800);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.refresh-btn {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 9999px;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: var(--gray-100);
    color: var(--primary);
}

.stores-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.store-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.store-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.store-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.store-logo {
    width: 48px;
    height: 48px;
    background: var(--gray-100);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--primary);
}

.store-details h3 {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.store-distance {
    font-size: 0.875rem;
    color: var(--gray-500);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.store-actions {
    display: flex;
    gap: 0.5rem;
}

.map-link {
    padding: 0.5rem;
    background: var(--gray-100);
    border-radius: 9999px;
    color: var(--gray-600);
    text-decoration: none;
    transition: all 0.2s;
}

.map-link:hover {
    background: var(--primary);
    color: white;
}

/* Results Grid */
.results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

.result-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    position: relative;
    transition: all 0.2s;
}

.result-card.best-value {
    border: 2px solid var(--secondary);
}

.best-badge {
    position: absolute;
    top: -10px;
    left: 1rem;
    background: var(--secondary);
    color: white;
    padding: 0.25rem 1rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.store-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
}

.store-badge {
    width: 32px;
    height: 32px;
    background: var(--gray-100);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--primary);
}

.price-container {
    margin-bottom: 0.75rem;
}

.price-main {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
}

.price-unit {
    font-size: 0.875rem;
    color: var(--gray-500);
    margin-left: 0.25rem;
}

.price-per-unit {
    font-size: 0.875rem;
    color: var(--secondary);
    font-weight: 500;
}

.result-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

.add-btn {
    flex: 1;
    padding: 0.75rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: background 0.2s;
}

.add-btn:hover {
    background: var(--primary-dark);
}

.details-btn {
    padding: 0.75rem 1rem;
    background: var(--gray-100);
    border: none;
    border-radius: var(--radius);
    color: var(--gray-700);
    cursor: pointer;
    transition: background 0.2s;
}

.details-btn:hover {
    background: var(--gray-200);
}

.source-link {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--gray-400);
    text-decoration: none;
}

.source-link:hover {
    color: var(--primary);
}

/* Quick Compare */
.quick-compare {
    padding: 3rem 0;
}

.popular-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.popular-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--gray-200);
    cursor: pointer;
    transition: all 0.2s;
}

.popular-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.popular-icon {
    font-size: 2rem;
}

.popular-info h3 {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.popular-info p {
    font-size: 0.875rem;
    color: var(--secondary);
    font-weight: 500;
}

/* Shopping List */
.shopping-list {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    max-width: 380px;
    background: white;
    box-shadow: var(--shadow-lg);
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
}

.shopping-list.active {
    transform: translateX(0);
}

.shopping-list-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.shopping-list-header h3 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.125rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.5rem;
}

.shopping-list-items {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
}

.list-item-info {
    flex: 1;
}

.list-item-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.list-item-price {
    font-size: 0.875rem;
    color: var(--gray-600);
}

.list-item-remove {
    color: var(--danger);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.list-item-remove:hover {
    opacity: 1;
}

.shopping-list-footer {
    padding: 1rem;
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: 0.5rem;
}

.footer-btn {
    flex: 1;
    padding: 0.75rem;
    background: var(--gray-100);
    border: none;
    border-radius: var(--radius);
    font-weight: 500;
    color: var(--gray-700);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.footer-btn:hover {
    background: var(--gray-200);
}

/* Floating Action Button */
.fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 56px;
    height: 56px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 9999px;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    transition: all 0.2s;
    z-index: 90;
}

.fab:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

.fab-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: var(--danger);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.25rem;
}

/* Loading States */
.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 3rem;
    color: var(--gray-500);
}

.loading-spinner i {
    font-size: 1.5rem;
}

/* Error Messages */
.error-message {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: #fee2e2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    color: #991b1b;
    margin: 1rem 0;
}

/* Footer */
.footer {
    background: white;
    border-top: 1px solid var(--gray-200);
    padding: 3rem 0 2rem;
    margin-top: 4rem;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-brand p {
    color: var(--gray-600);
    margin-top: 1rem;
    font-size: 0.875rem;
}

.social-links {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.social-links a {
    color: var(--gray-400);
    font-size: 1.25rem;
    transition: color 0.2s;
}

.social-links a:hover {
    color: var(--primary);
}

.footer-links h4 {
    font-size: 0.875rem;
    margin-bottom: 1rem;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.footer-links ul {
    list-style: none;
}

.footer-links li {
    margin-bottom: 0.5rem;
}

.footer-links a {
    color: var(--gray-600);
    text-decoration: none;
    font-size: 0.875rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary);
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid var(--gray-200);
    color: var(--gray-500);
    font-size: 0.875rem;
}

.footer-bottom a {
    color: var(--primary);
    text-decoration: none;
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
    z-index: 200;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0.5rem;
}

.modal-body {
    padding: 1.5rem;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

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

.mt-4 {
    margin-top: 1rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

/* Media Queries */
@media (min-width: 640px) {
    .hero-title {
        font-size: 2.5rem;
    }
    
    .stores-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .results-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .popular-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 768px) {
    .nav-desktop {
        display: flex;
        align-items: center;
        gap: 1rem;
    }
    
    .menu-btn {
        display: none;
    }
    
    .hero {
        padding: 3rem 0 2rem;
    }
    
    .hero-title {
        font-size: 3rem;
    }
    
    .hero-subtitle {
        font-size: 1.125rem;
    }
}

@media (min-width: 1024px) {
    .stores-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .results-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .footer-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Animations */
@keyframes slideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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