/**
 * Lunar Simple Shop — Frontend Styles
 *
 * DESIGN PHILOSOPHY:
 * Minimal and theme-friendly. We use CSS custom properties (variables)
 * at the top so themes can override colors easily. The layout uses
 * CSS Grid for the product grid and Flexbox for components.
 * No framework dependencies.
 */

/* ── Variables ────────────────────────────────────────────────── */
:root {
    --lss-primary: #2563eb;
    --lss-primary-hover: #1d4ed8;
    --lss-text: #1f2937;
    --lss-text-light: #6b7280;
    --lss-border: #e5e7eb;
    --lss-bg: #f9fafb;
    --lss-success: #059669;
    --lss-danger: #dc2626;
    --lss-radius: 8px;
    --lss-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ── Shop Layout ──────────────────────────────────────────────── */
.lss-shop-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.lss-shop-header {
    margin-bottom: 2rem;
}

.lss-shop-title {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--lss-text);
}

/* ── Category Nav ─────────────────────────────────────────────── */
.lss-category-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.lss-cat-link {
    display: inline-block;
    padding: 0.375rem 1rem;
    border: 1px solid var(--lss-border);
    border-radius: 999px;
    text-decoration: none;
    color: var(--lss-text);
    font-size: 0.875rem;
    transition: all 0.2s;
}

.lss-cat-link:hover,
.lss-cat-link.active {
    background: var(--lss-primary);
    border-color: var(--lss-primary);
    color: #fff;
}

/* ── Product Grid ─────────────────────────────────────────────── */
.lss-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.5rem;
}

.lss-product-card {
    border: 1px solid var(--lss-border);
    border-radius: var(--lss-radius);
    overflow: hidden;
    transition: box-shadow 0.2s;
    background: #fff;
}

.lss-product-card:hover {
    box-shadow: var(--lss-shadow);
}

.lss-product-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.lss-product-image {
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: var(--lss-bg);
}

.lss-product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lss-product-image.lss-no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--lss-text-light);
    font-size: 0.875rem;
}

.lss-product-info {
    padding: 1rem;
}

.lss-product-info .lss-product-title {
    font-size: 1rem;
    margin: 0 0 0.5rem;
    color: var(--lss-text);
}

.lss-product-excerpt {
    font-size: 0.875rem;
    color: var(--lss-text-light);
    margin: 0.5rem 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── Prices ───────────────────────────────────────────────────── */
.lss-product-price {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.lss-price-current {
    font-weight: 700;
    color: var(--lss-text);
    font-size: 1.125rem;
}

.lss-price-old {
    text-decoration: line-through;
    color: var(--lss-text-light);
    font-size: 0.875rem;
}

.lss-price-large .lss-price-current {
    font-size: 1.75rem;
}

.lss-price-large .lss-price-old {
    font-size: 1.125rem;
}

/* ── Product Type Badge ───────────────────────────────────────── */
.lss-product-type-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

.lss-type-digital {
    background: #dbeafe;
    color: #1e40af;
}

.lss-type-physical {
    background: #fef3c7;
    color: #92400e;
}

.lss-type-external {
    background: #e0e7ff;
    color: #3730a3;
}

/* ── Single Product ───────────────────────────────────────────── */
.lss-single-product {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.lss-product-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    margin-bottom: 3rem;
}

@media (max-width: 768px) {
    .lss-product-layout {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

.lss-product-gallery .lss-main-image {
    border-radius: var(--lss-radius);
    overflow: hidden;
    background: var(--lss-bg);
}

.lss-product-gallery .lss-main-image img {
    width: 100%;
    height: auto;
    display: block;
}

.lss-product-gallery .lss-main-image.lss-no-image {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--lss-text-light);
}

.lss-product-details .lss-product-title {
    font-size: 2rem;
    margin: 0 0 1rem;
}

.lss-product-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    margin: 1rem 0;
    font-size: 0.875rem;
    color: var(--lss-text-light);
}

.lss-short-description {
    margin: 1.5rem 0;
    color: var(--lss-text);
    line-height: 1.6;
}

/* ── Add to Cart ──────────────────────────────────────────────── */
.lss-add-to-cart {
    display: flex;
    align-items: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

.lss-quantity-wrap label {
    display: block;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
    color: var(--lss-text-light);
}

.lss-quantity-input {
    width: 80px;
    padding: 0.625rem;
    border: 1px solid var(--lss-border);
    border-radius: var(--lss-radius);
    font-size: 1rem;
    text-align: center;
}

.lss-cart-message {
    margin-top: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--lss-radius);
    font-size: 0.875rem;
}

.lss-cart-message.success {
    background: #d1fae5;
    color: #065f46;
}

.lss-cart-message.error {
    background: #fee2e2;
    color: #991b1b;
}

.lss-out-of-stock {
    color: var(--lss-danger);
    font-weight: 600;
    margin-top: 1.5rem;
}

/* ── External Buy Button ─────────────────────────────────────── */
.lss-external-buy {
    margin-top: 1.5rem;
}

.lss-btn-external {
    font-size: 1.125rem;
    padding: 0.875rem 2rem;
}

.lss-external-icon {
    font-size: 1.25rem;
    line-height: 1;
}

/* ── Buttons ──────────────────────────────────────────────────── */
.lss-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--lss-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    line-height: 1.4;
}

.lss-btn-primary {
    background: var(--lss-primary);
    color: #fff;
}

.lss-btn-primary:hover {
    background: var(--lss-primary-hover);
    color: #fff;
}

.lss-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.lss-btn-secondary {
    background: var(--lss-bg);
    color: var(--lss-text);
    border: 1px solid var(--lss-border);
}

.lss-btn-secondary:hover {
    background: #e5e7eb;
    color: var(--lss-text);
}

.lss-btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.lss-btn-full {
    width: 100%;
}

.lss-btn-danger {
    color: var(--lss-danger);
    background: none;
    border: none;
    padding: 0.25rem;
    font-size: 0.875rem;
    cursor: pointer;
}

.lss-btn-danger:hover {
    text-decoration: underline;
}

/* ── Cart Page ────────────────────────────────────────────────── */
.lss-cart-wrap {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.lss-cart-item {
    display: grid;
    grid-template-columns: 80px 1fr auto auto;
    gap: 1rem;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--lss-border);
}

@media (max-width: 600px) {
    .lss-cart-item {
        grid-template-columns: 60px 1fr;
        gap: 0.5rem;
    }
}

.lss-cart-item-image img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
}

.lss-cart-item-name {
    font-weight: 600;
}

.lss-cart-item-price {
    color: var(--lss-text-light);
    font-size: 0.875rem;
}

.lss-cart-item-qty {
    width: 60px;
    padding: 0.375rem;
    text-align: center;
    border: 1px solid var(--lss-border);
    border-radius: 4px;
}

.lss-cart-footer {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--lss-text);
}

.lss-cart-totals {
    margin-bottom: 1.5rem;
}

.lss-cart-total-row {
    display: flex;
    justify-content: space-between;
    font-size: 1.25rem;
    font-weight: 700;
}

.lss-cart-actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

.lss-cart-empty {
    text-align: center;
    padding: 3rem 1rem;
}

/* ── Checkout ─────────────────────────────────────────────────── */
.lss-checkout-wrap {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.lss-checkout-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
}

@media (max-width: 768px) {
    .lss-checkout-layout {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
}

.lss-checkout-section h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--lss-border);
}

.lss-form-row {
    margin-bottom: 1rem;
}

.lss-form-row label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--lss-text);
}

.lss-form-row label .required {
    color: var(--lss-danger);
}

.lss-form-row input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--lss-border);
    border-radius: var(--lss-radius);
    font-size: 1rem;
}

.lss-form-row input:focus {
    outline: none;
    border-color: var(--lss-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.lss-form-row-half {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Address sections */
.lss-address-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--lss-border);
}

.lss-address-section h3 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
}

.lss-checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    font-weight: 400 !important;
    cursor: pointer;
}

.lss-checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
}

/* Order summary on checkout */
.lss-order-summary {
    background: var(--lss-bg);
    border-radius: var(--lss-radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.lss-summary-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0;
    font-size: 0.875rem;
}

.lss-summary-total {
    border-top: 1px solid var(--lss-border);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    font-weight: 700;
}

/* Stripe Payment Element container */
#lss-payment-element {
    padding: 1rem;
    border: 1px solid var(--lss-border);
    border-radius: var(--lss-radius);
    margin-bottom: 1rem;
    min-height: 100px;
}

.lss-payment-errors {
    color: var(--lss-danger);
    font-size: 0.875rem;
    margin-bottom: 1rem;
    min-height: 1.25rem;
}

/* Spinner for loading states */
.lss-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: lss-spin 0.6s linear infinite;
}

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

.lss-loading {
    color: var(--lss-text-light);
    font-style: italic;
}

/* ── Order Confirmation ───────────────────────────────────────── */
.lss-confirmation-wrap {
    max-width: 700px;
    margin: 0 auto;
    padding: 2rem 1rem;
    text-align: center;
}

.lss-confirmation-header {
    padding: 2rem 0;
}

.lss-check-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    background: #d1fae5;
    color: var(--lss-success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
}

.lss-order-number {
    color: var(--lss-text-light);
    font-size: 1.125rem;
}

.lss-confirmation-email {
    color: var(--lss-text-light);
    font-size: 0.875rem;
}

.lss-order-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    margin: 1rem 0;
}

.lss-order-table th,
.lss-order-table td {
    padding: 0.75rem;
    border-bottom: 1px solid var(--lss-border);
}

.lss-order-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--lss-text-light);
}

.lss-confirmation-downloads {
    text-align: left;
    margin: 2rem 0;
    padding: 1.5rem;
    background: #eff6ff;
    border-radius: var(--lss-radius);
}

.lss-download-note {
    font-size: 0.875rem;
    color: var(--lss-text-light);
    margin-bottom: 1rem;
}

.lss-download-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.lss-download-list li {
    margin-bottom: 0.5rem;
}

.lss-confirmation-footer {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--lss-border);
}

/* ── Floating Cart Widget ────────────────────────────────────── */
.lss-cart-widget {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1.25rem;
    background: var(--lss-primary);
    color: #fff;
    border-radius: 999px;
    text-decoration: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 600;
    line-height: 1;
}

.lss-cart-widget:hover {
    background: var(--lss-primary-hover);
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    text-decoration: none;
}

/* Icon wrapper — holds the SVG and the count badge */
.lss-cart-widget-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.lss-cart-widget-icon svg {
    width: 22px;
    height: 22px;
}

/* Count badge — red circle overlapping the top-right of the icon */
.lss-cart-widget-badge {
    position: absolute;
    top: -8px;
    right: -10px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--lss-danger);
    color: #fff;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* Total text next to the icon */
.lss-cart-widget-total {
    white-space: nowrap;
}

/* When the cart is empty, hide the badge and show a subtler look */
.lss-cart-widget-empty .lss-cart-widget-badge {
    display: none;
}

.lss-cart-widget-empty {
    background: var(--lss-text-light);
    padding: 0.75rem;
}

.lss-cart-widget-empty:hover {
    background: var(--lss-text);
}

.lss-cart-widget-empty .lss-cart-widget-total {
    display: none;
}

/* Mobile: make it a bit smaller */
@media (max-width: 600px) {
    .lss-cart-widget {
        bottom: 1rem;
        right: 1rem;
        padding: 0.625rem 1rem;
        font-size: 0.875rem;
    }
    .lss-cart-widget-icon svg {
        width: 20px;
        height: 20px;
    }
}

/* ── Description Section ──────────────────────────────────────── */
.lss-product-description {
    max-width: 800px;
    border-top: 1px solid var(--lss-border);
    padding-top: 2rem;
}

.lss-product-description h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.lss-description-content {
    line-height: 1.7;
    color: var(--lss-text);
}
