/* ============================================
   NanoCart Storefront — Global Styles
   Shared across ALL templates
   ============================================ */

/* --- CSS Variables (defaults, overridden by config.js) --- */
:root {
    --nc-accent: #418a9e;
    --nc-accent-hover: #357a8d;
    --nc-bg: #ffffff;
    --nc-text: #333333;
    --nc-text-light: #6b7280;
    --nc-border: #e5e7eb;
    --nc-radius: 8px;
    --nc-radius-lg: 12px;
    --nc-shadow: 0 1px 3px rgba(0,0,0,0.08);
    --nc-shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --nc-shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --nc-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --nc-transition: 0.2s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--nc-font);
    color: var(--nc-text);
    background: var(--nc-bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
button { cursor: pointer; font-family: inherit; }
input, select { font-family: inherit; }

/* --- Utility --- */
.nc-container { max-width: 1200px; margin: 0 auto; padding: 0 1.5rem; }
.nc-section { padding: 3rem 0; }
.nc-text-center { text-align: center; }
.nc-text-light { color: var(--nc-text-light); }
.nc-text-sm { font-size: 0.875rem; }
.nc-text-lg { font-size: 1.125rem; }
.nc-mb-1 { margin-bottom: 0.5rem; }
.nc-mb-2 { margin-bottom: 0.75rem; }
.nc-mb-3 { margin-bottom: 1.5rem; }
.nc-mb-4 { margin-bottom: 2rem; }
.nc-section-heading {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

/* --- Grid --- */
.nc-grid {
    display: grid;
    gap: 1.5rem;
}
.nc-grid-4 { grid-template-columns: repeat(4, 1fr); }
.nc-grid-3 { grid-template-columns: repeat(3, 1fr); }
.nc-grid-2 { grid-template-columns: repeat(2, 1fr); }

@media (max-width: 1024px) {
    .nc-grid-4 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
    .nc-grid-4 { grid-template-columns: repeat(2, 1fr); }
    .nc-grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
    .nc-grid-4 { grid-template-columns: 1fr; }
    .nc-grid-3 { grid-template-columns: 1fr; }
    .nc-grid-2 { grid-template-columns: 1fr; }
}

/* --- Placeholder Image --- */
.nc-img-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    color: #d1d5db;
    width: 100%;
    height: 100%;
}

/* --- Buttons --- */
.nc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: 2px solid transparent;
    border-radius: var(--nc-radius);
    cursor: pointer;
    transition: all var(--nc-transition);
    text-decoration: none;
    line-height: 1.4;
    background: none;
}
.nc-btn-primary {
    background: var(--nc-accent);
    color: #fff;
    border-color: var(--nc-accent);
}
.nc-btn-primary:hover { background: var(--nc-accent-hover); border-color: var(--nc-accent-hover); }
.nc-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.nc-btn-outline {
    background: transparent;
    color: var(--nc-text);
    border-color: var(--nc-border);
}
.nc-btn-outline:hover { border-color: var(--nc-text); }
.nc-btn-hero {
    background: #fff;
    color: var(--nc-accent);
    border-color: #fff;
    font-weight: 600;
}
.nc-btn-hero:hover { background: rgba(255,255,255,0.9); }
.nc-btn-sm { padding: 0.4rem 1rem; font-size: 0.8rem; }
.nc-btn-lg { padding: 0.75rem 2rem; font-size: 1rem; }
.nc-btn-block { width: 100%; }

/* --- Inputs --- */
.nc-input {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9rem;
    border: 1px solid var(--nc-border);
    border-radius: var(--nc-radius);
    background: var(--nc-bg);
    color: var(--nc-text);
    transition: border-color var(--nc-transition);
    outline: none;
}
.nc-input:focus { border-color: var(--nc-accent); }

.nc-select {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.9rem;
    border: 1px solid var(--nc-border);
    border-radius: var(--nc-radius);
    background: var(--nc-bg);
    color: var(--nc-text);
    cursor: pointer;
    outline: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px;
    padding-right: 2.5rem;
}
.nc-select:focus { border-color: var(--nc-accent); }

/* --- Announcement Bar --- */
.nc-announcement-bar {
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    z-index: 100;
}

/* ============================================
   Navigation (shared component)
   ============================================ */
.nc-nav {
    position: sticky;
    top: 0;
    z-index: 90;
    background: var(--nc-bg);
    border-bottom: 1px solid var(--nc-border);
    box-shadow: var(--nc-shadow);
}
.nc-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    gap: 2rem;
}
.nc-nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    flex-shrink: 0;
}
.nc-nav-logo {
    height: 72px;
    width: auto;
    object-fit: contain;
}
.nc-nav-title {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--nc-text);
    letter-spacing: -0.01em;
}
.nc-nav-links {
    display: flex;
    align-items: center;
    gap: 2rem;
}
.nc-nav-link {
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--nc-text-light);
    transition: color var(--nc-transition);
    text-decoration: none;
    padding: 0.25rem 0;
}
.nc-nav-link:hover { color: var(--nc-text); }
.nc-nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.nc-nav-cart {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    color: var(--nc-text);
    border-radius: var(--nc-radius);
    transition: background var(--nc-transition);
}
.nc-nav-cart:hover { background: #f3f4f6; }
.nc-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    background: var(--nc-accent);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    padding: 0 4px;
}
.nc-nav-mobile-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    color: var(--nc-text);
    border-radius: var(--nc-radius);
}
.nc-nav-mobile-toggle:hover { background: #f3f4f6; }

/* Mobile Nav */
@media (max-width: 768px) {
    .nc-nav-logo { height: 52px; }
    .nc-nav-mobile-toggle { display: flex; }
    .nc-nav-links {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        flex-direction: column;
        background: var(--nc-bg);
        border-bottom: 1px solid var(--nc-border);
        box-shadow: var(--nc-shadow-md);
        padding: 1rem 1.5rem;
        gap: 0;
    }
    .nc-nav.mobile-open .nc-nav-links { display: flex; }
    .nc-nav-link {
        padding: 0.75rem 0;
        font-size: 1rem;
        border-bottom: 1px solid var(--nc-border);
        width: 100%;
    }
    .nc-nav-link:last-child { border-bottom: none; }
}

/* ============================================
   Product Card (shared component)
   ============================================ */
.nc-product-card {
    border: 1px solid var(--nc-border);
    border-radius: var(--nc-radius-lg);
    overflow: hidden;
    background: var(--nc-bg);
    transition: box-shadow var(--nc-transition), transform var(--nc-transition);
}
.nc-product-card:hover {
    box-shadow: var(--nc-shadow-md);
    transform: translateY(-2px);
}
.nc-product-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
}
.nc-product-card-img-wrap {
    aspect-ratio: 3/4;
    overflow: hidden;
    background: #f9fafb;
}
.nc-product-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}
.nc-product-card:hover .nc-product-card-img { transform: scale(1.03); }
.nc-product-card-body {
    padding: 1rem;
}
.nc-product-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.nc-product-card-price {
    font-size: 0.9rem;
    color: var(--nc-text-light);
    font-weight: 500;
}
.nc-product-card-actions {
    padding: 0 1rem 1rem;
}

/* ============================================
   Product Detail (shared component)
   ============================================ */
.nc-product-detail {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: start;
}
.nc-product-detail-gallery { position: sticky; top: 80px; }
.nc-product-detail-main-img-wrap {
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: var(--nc-radius-lg);
    background: #f9fafb;
    margin-bottom: 0.75rem;
}
.nc-product-detail-main-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.nc-product-detail-thumbs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.25rem;
}
.nc-product-detail-thumb {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border: 2px solid var(--nc-border);
    border-radius: var(--nc-radius);
    overflow: hidden;
    cursor: pointer;
    background: none;
    padding: 0;
    transition: border-color var(--nc-transition);
}
.nc-product-detail-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.nc-product-detail-thumb.active,
.nc-product-detail-thumb:hover { border-color: var(--nc-accent); }

.nc-product-detail-info { padding-top: 0.5rem; }
.nc-product-detail-title {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.25;
    margin-bottom: 0.75rem;
    letter-spacing: -0.01em;
}
.nc-product-detail-price {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--nc-text);
}
.nc-product-detail-desc {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--nc-text-light);
    margin-bottom: 1.5rem;
}
.nc-product-detail-desc p { margin-bottom: 0.75rem; }
.nc-product-detail-options { margin-bottom: 1.5rem; }
.nc-product-detail-option-group { margin-bottom: 1rem; }
.nc-product-detail-option-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
    color: var(--nc-text);
}
.nc-product-detail-qty-row { margin-bottom: 1.5rem; }
.nc-product-detail-error {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: #dc2626;
}

/* Quantity Picker */
.nc-qty-picker {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--nc-border);
    border-radius: var(--nc-radius);
    overflow: hidden;
}
.nc-qty-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: #f9fafb;
    border: none;
    font-size: 1.1rem;
    color: var(--nc-text);
    cursor: pointer;
    transition: background var(--nc-transition);
    user-select: none;
}
.nc-qty-btn:hover { background: #e5e7eb; }
.nc-qty-input {
    width: 48px;
    height: 36px;
    text-align: center;
    border: none;
    border-left: 1px solid var(--nc-border);
    border-right: 1px solid var(--nc-border);
    font-size: 0.9rem;
    outline: none;
    background: var(--nc-bg);
    color: var(--nc-text);
    -moz-appearance: textfield;
}
.nc-qty-input::-webkit-outer-spin-button,
.nc-qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Small qty buttons (cart drawer) */
.nc-qty-btn-sm { width: 28px; height: 28px; font-size: 0.9rem; }

@media (max-width: 768px) {
    .nc-product-detail {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
    .nc-product-detail-gallery { position: static; }
    .nc-product-detail-title { font-size: 1.5rem; }
}

/* ============================================
   Cart Drawer (shared component)
   ============================================ */
.nc-cart-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.nc-cart-overlay.open { opacity: 1; visibility: visible; }

.nc-cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 420px;
    max-width: 100%;
    background: var(--nc-bg);
    z-index: 201;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    box-shadow: var(--nc-shadow-lg);
}
.nc-cart-drawer.open { transform: translateX(0); }

.nc-cart-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--nc-border);
    flex-shrink: 0;
}
.nc-cart-drawer-title {
    font-size: 1.1rem;
    font-weight: 700;
}
.nc-cart-drawer-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    border-radius: var(--nc-radius);
    color: var(--nc-text-light);
    transition: background var(--nc-transition);
}
.nc-cart-drawer-close:hover { background: #f3f4f6; }

.nc-cart-drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
}

.nc-cart-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 0;
    text-align: center;
}

.nc-cart-item {
    display: flex;
    gap: 1rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--nc-border);
    position: relative;
}
.nc-cart-item:last-child { border-bottom: none; }
.nc-cart-item-img-wrap {
    width: 72px;
    height: 72px;
    flex-shrink: 0;
    border-radius: var(--nc-radius);
    overflow: hidden;
    background: #f9fafb;
}
.nc-cart-item-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.nc-cart-item-details { flex: 1; min-width: 0; }
.nc-cart-item-name {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--nc-text);
    text-decoration: none;
    margin-bottom: 0.125rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nc-cart-item-name:hover { color: var(--nc-accent); }
.nc-cart-item-variant {
    font-size: 0.8rem;
    color: var(--nc-text-light);
    margin-bottom: 0.25rem;
}
.nc-cart-item-price {
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}
.nc-cart-item-qty {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--nc-border);
    border-radius: var(--nc-radius);
    overflow: hidden;
}
.nc-cart-item-qty-val {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    font-size: 0.8rem;
    font-weight: 500;
    border-left: 1px solid var(--nc-border);
    border-right: 1px solid var(--nc-border);
}
.nc-cart-item-remove {
    position: absolute;
    top: 1rem;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: none;
    border: none;
    color: var(--nc-text-light);
    border-radius: var(--nc-radius);
    transition: background var(--nc-transition), color var(--nc-transition);
}
.nc-cart-item-remove:hover { background: #fee2e2; color: #dc2626; }

.nc-cart-drawer-footer {
    flex-shrink: 0;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--nc-border);
}
.nc-cart-subtotal {
    display: flex;
    justify-content: space-between;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}
.nc-cart-checkout-fields { margin-bottom: 0.75rem; }
.nc-cart-checkout-fields .nc-input { margin-bottom: 0.5rem; }
.nc-cart-coupon-row { display: flex; gap: 0.5rem; }
.nc-cart-coupon-row .nc-input { flex: 1; }
.nc-cart-error {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #dc2626;
    text-align: center;
}
.nc-cart-shipping-note {
    font-size: 0.75rem;
    color: var(--nc-text-light);
    text-align: center;
    margin-top: 0.75rem;
}

/* ============================================
   Footer (shared component)
   ============================================ */
.nc-footer {
    border-top: 1px solid var(--nc-border);
    padding: 2rem 0;
    margin-top: auto;
}
.nc-footer-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    text-align: center;
}
.nc-footer-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--nc-text);
}
.nc-footer-social {
    display: flex;
    gap: 1rem;
}
.nc-footer-social-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--nc-text-light);
    transition: color var(--nc-transition), background var(--nc-transition);
}
.nc-footer-social-link:hover { color: var(--nc-text); background: #f3f4f6; }
.nc-powered-badge {
    font-size: 0.75rem;
    color: var(--nc-text-light);
    text-decoration: none;
    transition: color var(--nc-transition);
}
.nc-powered-badge:hover { color: var(--nc-text); }
.nc-powered-badge strong { font-weight: 600; }

/* ============================================
   Skeleton Loading
   ============================================ */
@keyframes nc-shimmer {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}
.nc-skeleton {
    background: #e5e7eb;
    background-image: linear-gradient(90deg, #e5e7eb 0px, #f3f4f6 40px, #e5e7eb 80px);
    background-size: 200px 100%;
    animation: nc-shimmer 1.5s infinite linear;
    border-radius: var(--nc-radius);
}
.nc-skeleton-card {
    border: 1px solid var(--nc-border);
    border-radius: var(--nc-radius-lg);
    overflow: hidden;
}
.nc-skeleton-img { aspect-ratio: 3/4; border-radius: 0; }
.nc-skeleton-body { padding: 1rem; }
.nc-skeleton-title { height: 1rem; width: 75%; margin-bottom: 0.5rem; }
.nc-skeleton-price { height: 0.9rem; width: 40%; margin-bottom: 0.75rem; }
.nc-skeleton-btn { height: 2.25rem; width: 100%; }
.nc-skeleton-detail-img { aspect-ratio: 1; }
.nc-skeleton-detail-title { height: 1.5rem; width: 70%; margin-bottom: 1rem; }
.nc-skeleton-detail-price { height: 1.25rem; width: 30%; margin-bottom: 1.25rem; }
.nc-skeleton-detail-desc { height: 0.9rem; width: 100%; margin-bottom: 0.75rem; }
.nc-skeleton-detail-btn { height: 3rem; width: 100%; margin-top: 1.5rem; }

/* ============================================
   Main area min-height
   ============================================ */
.nc-main { min-height: calc(100vh - 200px); }

/* ============================================
   Loading spinner (initial load)
   ============================================ */
.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--nc-border);
    border-top-color: var(--nc-accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
