/* 
 * catalog-ui.css
 * Phase 9 - Unified Premium Catalog Experience
 */

/* ==========================================================================
   1. Catalog Page Layout & Header
   ========================================================================== */
.rr-catalog-page {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem;
    width: 100%;
}

.rr-catalog-header {
    background: var(--rr-surface);
    border: 1px solid var(--rr-border);
    border-radius: var(--rr-border-radius, 0.75rem);
    padding: 1.5rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.rr-catalog-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--rr-text);
    margin-bottom: 0.5rem;
}

.rr-catalog-description {
    font-size: 0.95rem;
    color: var(--rr-text-muted);
    margin-bottom: 0;
    max-width: 800px;
}

/* ==========================================================================
   2. Toolbar (Search & Filters)
   ========================================================================== */
.rr-catalog-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    background: var(--rr-surface);
    border: 1px solid var(--rr-border);
    border-radius: var(--rr-border-radius, 0.75rem);
    padding: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.rr-catalog-search {
    flex: 1;
    min-width: 250px;
    display: flex;
    gap: 0.5rem;
}

.rr-catalog-search .input-group {
    flex: 1;
}

.rr-catalog-filters {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

@media (max-width: 768px) {
    .rr-catalog-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .rr-catalog-search {
        width: 100%;
        flex-direction: column; /* Stack the input and the filters */
        gap: 0.75rem;
    }
    .rr-catalog-search .input-group {
        width: 100%;
    }
    .rr-catalog-filters {
        width: 100%;
        justify-content: space-between;
        margin-left: 0 !important; /* Override the ms-sm-2 */
        margin-top: 0 !important;
    }
    .rr-catalog-filters select {
        flex: 1;
        min-width: 0 !important; /* Override inline min-width */
    }
}

/* ==========================================================================
   3. Product Grid
   ========================================================================== */
.rr-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
    gap: 1.5rem;
}

/* ==========================================================================
   4. Product Card
   ========================================================================== */
.rr-product-card {
    background: var(--rr-surface);
    border: 1px solid var(--rr-border);
    border-radius: var(--rr-border-radius, 0.75rem);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
    min-width: 0;
}

.rr-product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(0,0,0,0.05);
}

/* Media Area */
.rr-product-media {
    position: relative;
    aspect-ratio: 16 / 9;
    background: var(--rr-bg, #f1f5f9);
    overflow: hidden;
    border-bottom: 1px solid var(--rr-border);
}

.rr-product-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rr-product-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--rr-text-muted);
}

.rr-product-placeholder i {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

/* Badges / Access States on top of media */
.rr-product-access-badge {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: rgba(255,255,255,0.9);
    backdrop-filter: blur(4px);
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 10;
}
html[data-theme="dark"] .rr-product-access-badge {
    background: rgba(0,0,0,0.7);
    color: #fff;
}

/* Content Area */
.rr-product-content {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.rr-product-category {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--rr-primary);
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rr-product-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--rr-text);
    margin-bottom: 0.5rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.rr-product-description {
    font-size: 0.85rem;
    color: var(--rr-text-muted);
    margin-bottom: 1rem;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Meta / Pricing Area */
.rr-product-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--rr-border);
}

.rr-product-price {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--rr-text);
}

.rr-product-price-free {
    color: var(--rr-success, #10b981);
}

.rr-product-price strike {
    font-size: 0.9rem;
    color: var(--rr-text-muted);
    font-weight: normal;
    margin-right: 0.25rem;
}

/* Footer / Actions */
.rr-product-footer {
    padding: 0 1.25rem 1.25rem 1.25rem;
}

.rr-product-actions {
    display: flex;
    gap: 0.5rem;
}
.rr-product-actions .rr-btn {
    flex: 1;
    display: inline-flex;
    justify-content: center;
    align-items: center;
}

/* ==========================================================================
   5. Detail Page (View.php equivalents)
   ========================================================================== */
.rr-product-detail {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.5rem;
    width: 100%;
}

.rr-product-detail-grid {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 992px) {
    .rr-product-detail-grid {
        grid-template-columns: 1fr;
    }
}

.rr-product-detail-media {
    border-radius: var(--rr-border-radius, 0.75rem);
    overflow: hidden;
    border: 1px solid var(--rr-border);
    background: var(--rr-surface);
}

.rr-product-detail-media img {
    width: 100%;
    height: auto;
    display: block;
}

.rr-product-detail-info {
    background: var(--rr-surface);
    border: 1px solid var(--rr-border);
    border-radius: var(--rr-border-radius, 0.75rem);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.rr-product-detail-category {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--rr-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.rr-product-detail-title {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--rr-text);
    line-height: 1.2;
    margin: 0;
}

.rr-product-detail-desc {
    font-size: 1rem;
    color: var(--rr-text-muted);
    line-height: 1.6;
}

.rr-product-detail-meta {
    padding: 1.25rem;
    background: var(--rr-bg, #f8fafc);
    border-radius: 0.5rem;
    border: 1px solid var(--rr-border);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
html[data-theme="dark"] .rr-product-detail-meta {
    background: rgba(0,0,0,0.2);
}

.rr-product-detail-price {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--rr-text);
    margin: 0;
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}
.rr-product-detail-price strike {
    font-size: 1.1rem;
    color: var(--rr-text-muted);
    font-weight: 500;
}

.rr-product-detail-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.rr-product-detail-actions .rr-btn {
    width: 100%;
    justify-content: center;
}

/* Access Status Badges for Details */
.rr-access-status {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    font-size: 0.9rem;
}
.rr-access-status.granted {
    background: rgba(16, 185, 129, 0.1);
    color: var(--rr-success, #10b981);
    border: 1px solid rgba(16, 185, 129, 0.2);
}
.rr-access-status.denied {
    background: rgba(239, 68, 68, 0.1);
    color: var(--rr-danger, #ef4444);
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.rr-access-status.premium {
    background: rgba(139, 92, 246, 0.1);
    color: #8b5cf6;
    border: 1px solid rgba(139, 92, 246, 0.2);
}

/* ==========================================================================
   6. Checkout Overrides
   ========================================================================== */
.rr-checkout-container {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}
@media (max-width: 992px) {
    .rr-checkout-container {
        grid-template-columns: 1fr;
    }
}
.rr-checkout-summary {
    position: sticky;
    top: 2rem;
}
.rr-order-item {
    display: flex;
    justify-content: space-between;
    padding: 1rem 0;
    border-bottom: 1px dashed var(--rr-border);
}
.rr-order-item:last-child {
    border-bottom: none;
}
.rr-order-total {
    display: flex;
    justify-content: space-between;
    padding-top: 1.5rem;
    border-top: 2px solid var(--rr-border);
    margin-top: 1rem;
    font-size: 1.25rem;
    font-weight: 800;
}

/* Empty states */
.rr-catalog-empty {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
}

/* Mobile Responsive Product Grid */
@media (max-width: 768px) {
    .rr-product-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    .rr-product-content {
        padding: 10px !important;
    }
    .rr-product-title {
        font-size: 14px !important;
        margin-bottom: 4px !important;
        line-height: 1.2 !important;
    }
    .rr-product-category {
        font-size: 10px !important;
        margin-bottom: 4px !important;
    }
    .rr-product-description {
        font-size: 11px !important;
        -webkit-line-clamp: 2 !important;
        margin-bottom: 8px !important;
    }
    .rr-product-meta {
        padding-top: 8px !important;
        margin-bottom: 8px !important;
    }
    .rr-product-price {
        font-size: 16px !important;
    }
    .rr-product-footer {
        padding: 10px !important;
        padding-top: 0 !important;
    }
    .rr-btn {
        padding: 6px 10px !important;
        font-size: 12px !important;
    }
    .rr-product-media {
        aspect-ratio: 1 / 1 !important;
    }
}

@media (max-width: 768px) {
    .rr-catalog-page {
        padding: 0 !important;
        gap: 1rem !important;
    }
    .rr-catalog-toolbar {
        flex-direction: column !important;
    }
    .rr-catalog-toolbar form, .rr-catalog-toolbar .rr-catalog-filters {
        width: 100% !important;
        margin-left: 0 !important;
    }
    .rr-catalog-filters select {
        width: 100% !important;
    }
}
