/* Deals Template - Base Mobile-First CSS */
/* This file contains theme-agnostic styles. Theme-specific styles are in /statics/themes/ */

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

html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background: var(--theme-body-bg);
    color: var(--theme-text-primary);
    overflow-x: hidden;
    min-height: 100vh;
    position: relative;
    padding-bottom: var(--nav-height);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background 0.3s ease, color 0.3s ease;
}

.app-container {
    width: 100%;
    max-width: 100vw;
    margin: 0 auto;
    padding-bottom: var(--nav-height);
}

/* ============================================
   DARK MODE TOGGLE
   ============================================ */
.theme-toggle {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    background: var(--theme-card-bg);
    border: 2px solid var(--theme-card-border);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--theme-shadow);
}

.theme-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px var(--theme-shadow);
}

.theme-toggle svg {
    width: 24px;
    height: 24px;
    color: var(--theme-text-primary);
    transition: transform 0.3s ease;
}

.theme-toggle:hover svg {
    transform: rotate(15deg);
}

.theme-toggle .sun-icon {
    display: none;
}

.theme-toggle .moon-icon {
    display: block;
}

[data-theme="dark"] .theme-toggle .sun-icon {
    display: block;
}

[data-theme="dark"] .theme-toggle .moon-icon {
    display: none;
}

/* ============================================
   SEARCH & FILTER SECTIONS
   ============================================ */
.search-section {
    padding: 0 0.75rem;
    margin-bottom: 0.85rem;
}

.search-bar {
    position: relative;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.search-bar input {
    width: 100%;
    padding: 0.65rem 2.5rem 0.65rem 0.75rem;
    background: var(--theme-input-bg);
    border: 1.5px solid var(--theme-card-border);
    border-radius: 10px;
    color: var(--theme-text-primary);
    font-size: 0.875rem;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--theme-shadow);
}

.search-bar input:focus {
    outline: none;
    border-color: var(--theme-primary-light);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.search-bar input::placeholder {
    color: var(--theme-light-gray);
}

.search-icon {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--theme-light-gray);
}

/* Filter Section */
.filter-section {
    padding: 0 0.75rem;
    margin-bottom: 0.85rem;
}

.filter-chips {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar {
    display: none;
}

.filter-chip {
    padding: 0.375rem 0.875rem;
    background: var(--theme-card-bg);
    border: 1.5px solid var(--theme-card-border);
    border-radius: 16px;
    color: var(--theme-text-primary);
    font-size: 0.8125rem;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px var(--theme-shadow);
}

.filter-chip:hover,
.filter-chip.active {
    transform: scale(1.05);
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */
.main-content {
    padding: 0 1rem;
    min-height: calc(100vh - 300px);
}

/* Loading State */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--theme-text-primary);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--theme-card-border);
    border-top-color: var(--theme-primary-light);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Error State */
.error-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--theme-text-primary);
}

.error-icon {
    width: 48px;
    height: 48px;
    color: var(--theme-highlight);
    margin: 0 auto 1rem;
}

.retry-btn {
    margin-top: 1rem;
    padding: 0.75rem 1.5rem;
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-btn:hover {
    transform: scale(1.05);
}

/* ============================================
   STORE LISTINGS GRID
   ============================================ */
.listings-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    padding-bottom: 0.75rem;
}

.store-card {
    background: var(--theme-card-bg);
    border: 1.5px solid var(--theme-card-border);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--theme-shadow);
}

/* Fix white border issue */
.store-card[style*="border-color: #ffffff"],
.store-card[style*="border-color: #FFFFFF"],
.store-card[style*="border-color: white"],
.store-card[style*="border-color: rgb(255, 255, 255)"] {
    border-color: #9ca3af !important;
}

.store-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.store-card:hover {
    transform: scale(1.02);
}

.deal-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 0.2rem 0.6rem;
    border-radius: 14px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.75px;
    z-index: 10;
    animation: badge-pulse 2s ease-in-out infinite;
}

.deal-badge.trending {
    background: linear-gradient(135deg, #8b5cf6, #a78bfa);
    color: #ffffff;
}

@keyframes badge-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.store-logo-container {
    height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

.store-logo {
    max-width: 100%;
    max-height: 32px;
    object-fit: contain;
}

.store-info {
    padding: 0.5rem 0.6rem;
}

.store-name {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.35rem;
    color: var(--theme-text-primary);
}

.store-tagline-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
}

.store-tagline {
    font-size: 0.75rem;
    color: var(--theme-text-secondary);
    margin: 0;
    flex: 1;
}

.store-meta {
    margin-bottom: 0.65rem;
}

.discount-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid var(--theme-secondary);
    border-radius: 4px;
    color: var(--theme-secondary-dark);
    font-size: 0.75rem;
    font-weight: 600;
}

.shop-now-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.4rem 0.75rem;
    color: #ffffff;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.75rem;
    white-space: nowrap;
    transition: all 0.3s ease;
}

.shop-now-btn:hover {
    transform: translateX(5px);
}

.btn-icon {
    width: 14px;
    height: 14px;
}

/* ============================================
   CATALOGUES PAGE
   ============================================ */
.catalogues-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding-bottom: 1rem;
}

.catalogue-card {
    background: var(--theme-card-bg);
    border: 2px solid var(--theme-card-border);
    border-radius: 12px;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px var(--theme-shadow);
}

.catalogue-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.catalogue-header {
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.65rem;
    position: relative;
}

.catalogue-store-logo {
    width: 140px;
    height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 6px;
    padding: 0.35rem;
}

[data-theme="dark"] .catalogue-store-logo {
    background: rgba(255, 255, 255, 0.1);
}

.cat-logo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.store-initial {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--theme-primary-light);
}

.catalogue-preview {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pdf-icon {
    width: 28px;
    height: 28px;
    color: var(--theme-primary-light);
}

.catalogue-info {
    padding: 0.75rem;
}

.catalogue-name {
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--theme-text-primary);
    line-height: 1.3;
}

.catalogue-meta {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.65rem;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.625rem;
    color: var(--theme-text-secondary);
}

.meta-item svg {
    width: 12px;
    height: 12px;
    flex-shrink: 0;
}

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

.view-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border: none;
    border-radius: 8px;
    color: #ffffff;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.view-btn:hover {
    transform: scale(1.05);
}

.download-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 2px solid var(--theme-card-border);
    border-radius: 8px;
    background: transparent;
    color: var(--theme-text-primary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.download-btn:hover {
    background: var(--theme-primary-light);
    border-color: var(--theme-primary-light);
    color: #ffffff;
    transform: scale(1.05);
}

.view-btn svg,
.download-btn svg {
    width: 16px;
    height: 16px;
}

.no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--theme-text-secondary);
}

/* ============================================
   BOTTOM NAVIGATION
   ============================================ */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--nav-height);
    background: var(--theme-nav-bg);
    border-top: 1px solid var(--theme-nav-border);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 100;
    backdrop-filter: blur(10px);
    box-shadow: 0 -2px 10px var(--theme-shadow);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 0.5rem;
    color: var(--theme-text-secondary);
    text-decoration: none;
    transition: all 0.3s ease;
    position: relative;
}

.nav-item svg {
    width: 24px;
    height: 24px;
}

.nav-item span {
    font-size: 0.75rem;
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
}

/* ============================================
   COMING SOON STYLES
   ============================================ */
.coming-soon-text {
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
    text-align: center;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.store-card.coming-soon .store-logo,
.catalogue-card.coming-soon .cat-logo {
    display: none;
}

.store-card.coming-soon .shop-now-btn,
.catalogue-card.coming-soon .view-btn {
    display: none;
}

.store-card.coming-soon .store-tagline,
.catalogue-card.coming-soon .catalogue-name {
    display: none;
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden {
    display: none !important;
}

/* ============================================
   RESPONSIVE STYLES
   ============================================ */
@media (min-width: 768px) {
    .listings-grid,
    .catalogues-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }

    .app-container {
        max-width: 1200px;
        padding: 0 2rem;
    }

    .theme-toggle {
        top: 1.5rem;
        right: 1.5rem;
    }
}

@media (min-width: 1024px) {
    .listings-grid,
    .catalogues-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Smooth scrolling for iOS */
.app-container {
    -webkit-overflow-scrolling: touch;
}

/* Safe area insets for notched devices */
.bottom-nav {
    padding-bottom: env(safe-area-inset-bottom);
}

.app-container {
    padding-top: env(safe-area-inset-top);
}

/* ============================================
   MODAL/POPUP STYLES
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(30, 41, 59, 0.85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
    backdrop-filter: blur(5px);
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--theme-modal-bg);
    border: 2px solid;
    border-radius: 16px;
    padding: 1.5rem;
    max-width: 90%;
    width: 350px;
    animation: slideUp 0.3s ease;
    position: relative;
}

.modal-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    display: block;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--theme-text-primary);
    text-align: center;
    margin-bottom: 0.5rem;
}

.modal-message {
    font-size: 0.9375rem;
    color: var(--theme-text-secondary);
    text-align: center;
    margin-bottom: 0.75rem;
    line-height: 1.5;
}

.modal-logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    border-radius: 10px;
    margin: 1rem 0;
    background: var(--theme-bg-light);
}

.modal-logo {
    display: block;
    max-width: 150px;
    max-height: 70px;
    object-fit: contain;
}

.modal-notice {
    font-size: 0.75rem;
    color: var(--theme-text-secondary);
    text-align: center;
    margin-bottom: 1.5rem;
    font-style: italic;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
}

.modal-btn {
    flex: 1;
    padding: 0.875rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.modal-btn-cancel {
    background: var(--theme-bg-light);
    color: var(--theme-text-primary);
    border: 1.5px solid var(--theme-card-border);
}

.modal-btn-cancel:hover {
    background: var(--theme-card-border);
    transform: scale(1.05);
}

.modal-btn-cancel:focus,
.modal-btn-cancel:active {
    background: var(--theme-bg-light);
    color: var(--theme-text-primary);
    outline: none;
}

.modal-btn-confirm {
    color: #ffffff;
}

.modal-btn-confirm:hover {
    transform: scale(1.05);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ============================================
   TOAST STYLES
   ============================================ */
.toast {
    position: fixed;
    bottom: calc(var(--nav-height) + 20px);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--theme-primary-light);
    color: #fff;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    z-index: 1000;
    transition: transform 0.3s ease;
    box-shadow: 0 4px 16px var(--theme-shadow);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    transform: scale(0);
    animation: ripple-animation 0.6s ease-out;
    pointer-events: none;
}

@keyframes ripple-animation {
    to {
        transform: scale(4);
        opacity: 0;
    }
}