/* ============================================================================
   select-products.css
   Shared stylesheet for select-products-dimona.html and select-product-client.html
   Visual identity follows shared-products-dimona.css:
   #f4f3ef surfaces, 32px/26px rounding, Figtree, #151219 text, #712bf5 accent.
   ========================================================================== */

:root {
    --sp-purple:       #712bf5;
    --sp-purple-hover: #5f22d6;
    --sp-purple-tint:  #f1ebff;
    --sp-bg:           #f5f4f0;
    --sp-surface:      #f4f3ef;
    --sp-image-bg:     #e9e8e4;
    --sp-text:         #151219;
    --sp-text-mid:     #4a4a4f;
    --sp-text-soft:    #9a9aa1;
    --sp-border:       #e2e2e2;
    --sp-border-soft:  #ecebe7;
    --sp-danger:       #e0475a;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0 0 110px;
    background: var(--sp-bg);
    color: var(--sp-text);
    font-family: 'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 400;
}

.hidden { display: none !important; }

/* ─── Top bar ─────────────────────────────────────────────────────────────── */

.top-bar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 40px;
    background: var(--sp-bg);
}

.top-bar h2 {
    position: relative;
    margin: 0;
    padding-bottom: 8px;
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--sp-text);
}

.top-bar h2::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    width: 38px;
    height: 3px;
    background: var(--sp-purple);
    border-radius: 2px;
}

.stats {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    font-weight: 500;
    color: var(--sp-text-mid);
}

#product-count { font-weight: 700; color: var(--sp-text); }

#refresh-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 12px;
    background: var(--sp-purple);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
}

#refresh-btn:hover  { background: var(--sp-purple-hover); transform: scale(1.06); }
#refresh-btn:active { transform: scale(0.96); }

/* ─── Main / status messages ──────────────────────────────────────────────── */

main { padding: 8px 40px 24px; }

.loading {
    padding: 40px 0;
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    color: var(--sp-text-soft);
}

.error {
    margin: 12px 0;
    padding: 12px 16px;
    border-radius: 16px;
    background: #fdecef;
    border: 1px solid rgba(224, 71, 90, 0.25);
    color: var(--sp-danger);
    font-size: 14px;
    font-weight: 500;
}

.error:empty { display: none; }

/* ─── Selected art banner (client page) ───────────────────────────────────── */

.selected-art-container { margin: 0 0 24px; }

.selected-art-display {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 12px;
    background: var(--sp-surface);
    border-radius: 32px;
}

.art-thumbnail {
    flex-shrink: 0;
    width: 110px;
    height: 110px;
    border-radius: 22px;
    overflow: hidden;
    background: var(--sp-image-bg);
}

.art-thumbnail img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.art-details { min-width: 0; flex: 1; padding-right: 12px; }

.art-details h4 {
    margin: 0;
    font-size: 20.8px;
    font-weight: 500;
    color: var(--sp-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.art-price {
    margin: 4px 0 0;
    font-size: 22px;
    font-weight: 700;
    color: var(--sp-purple);
}

.art-description {
    margin: 6px 0 0;
    font-size: 14px;
    line-height: 1.4;
    color: var(--sp-text-soft);
}

.art-description:empty { display: none; }

/* ─── Product grid + cards (.product-card > img + title + info) ───────────── */

.product-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    padding: 8px 0;
}

@media (max-width: 1100px) { .product-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px)  { .product-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; } }
@media (max-width: 480px)  { .product-grid { grid-template-columns: 1fr; } }

.product-grid .product-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 12px;
    background: var(--sp-surface);
    border-radius: 32px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.product-grid .product-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(21, 18, 25, 0.08);
}

.product-grid .product-card:active { transform: scale(0.99); }

.product-grid .product-image {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 5;
    object-fit: contain;
    background: var(--sp-image-bg);
    border-radius: 26px;
    transition: transform 0.4s ease;
}

.product-grid .product-card:hover .product-image { transform: scale(1.04); }

.product-grid .product-title {
    margin: 12px 4px 0;
    font-size: 20.8px;
    font-weight: 500;
    color: var(--sp-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-grid .product-info {
    margin: 2px 4px 4px;
    font-size: 14px;
    font-weight: 500;
    color: var(--sp-text-soft);
}

/* ─── Floating "Criar Arte" button (dimona page) ──────────────────────────── */

#create-art-btn {
    position: fixed;
    right: 40px;
    bottom: 32px;
    z-index: 200;
    min-height: 52px;
    padding: 16px 28px;
    border: none;
    border-radius: 16px;
    background: var(--sp-purple);
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(113, 43, 245, 0.35);
    transition: transform 0.15s ease, background 0.15s ease;
}

#create-art-btn:hover  { background: var(--sp-purple-hover); transform: scale(1.04); }
#create-art-btn:active { transform: scale(0.96); }

/* ─── Variant modal (the script shows it with style.display = 'block') ────── */

.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: none;
    overflow-y: auto;
    padding: 16px;
    background: rgba(21, 18, 25, 0.45);
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 680px;
    margin: 4vh auto;
    padding: 28px 24px 24px;
    background: #fff;
    border-radius: 28px;
    box-shadow: 0 20px 50px rgba(21, 18, 25, 0.25);
}

.modal-content h3 {
    margin: 0 44px 16px 0;
    font-size: 1.5rem;
    font-weight: 500;
    color: var(--sp-text);
}

.close-modal {
    position: absolute;
    top: 14px;
    right: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff;
    color: var(--sp-text);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    transition: background 0.15s ease, transform 0.15s ease;
}

.close-modal:hover { background: #f1f1f3; transform: scale(1.05); }

.flatlay-container {
    display: block;
    width: 100%;
    margin-bottom: 18px;
    background: var(--sp-surface);
    border-radius: 18px;
    box-shadow: inset 0 0 0 1px rgba(21, 18, 25, 0.04);
    overflow: hidden;
    line-height: 0;
}

.flatlay-img {
    display: block;
    width: 100%;
    height: auto;
    max-height: 48vh;
    object-fit: contain;
    margin: 0 auto;
}

/* ─── Variant options (.variant-option > .color-dot + name) ───────────────── */

.variant-section { margin-bottom: 16px; }

.section-title {
    margin-bottom: 10px;
    font-size: 15px;
    font-weight: 600;
    color: var(--sp-text);
}

.variant-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.variant-option {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    min-height: 56px;
    padding: 10px 14px;
    background: var(--sp-surface);
    border: 2px solid transparent;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--sp-text);
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.variant-option:hover {
    border-color: rgba(113, 43, 245, 0.45);
    transform: translateY(-1px);
}

.variant-option:active { transform: scale(0.97); }

.color-dot {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: box-shadow 0.15s ease;
}

/* Selected = strong purple highlight */
.variant-option.selected {
    background: var(--sp-purple);
    border-color: var(--sp-purple);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 6px 16px rgba(113, 43, 245, 0.35);
}

.variant-option.selected .color-dot { box-shadow: 0 0 0 2px #fff; }

.variant-option.selected::after {
    content: "\2713";
    margin-left: auto;
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

.variant-option.disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

/* Size options (client page) */
#size-selection-container { margin-top: 18px; }

.variant-selection-grid[data-type="size"] {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
}

.size-option {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    text-align: center;
}

.size-option.selected::after { content: none; }

.size-label { font-size: 16px; font-weight: 700; }
.size-price { font-size: 12px; font-weight: 500; opacity: 0.75; }

/* ─── Selected list ("Cores selecionadas") ────────────────────────────────── */

.selected-colors-container {
    margin-bottom: 18px;
    padding-top: 14px;
    border-top: 1.5px solid var(--sp-border-soft);
}

.selected-colors {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-height: 36px;
}

.selected-color {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px 6px 10px;
    background: var(--sp-purple-tint);
    border: 1.5px solid rgba(113, 43, 245, 0.35);
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
    color: var(--sp-text);
}

.selected-color-dot {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1.5px solid rgba(21, 18, 25, 0.18);
}

.remove-color {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    margin-left: 2px;
    border-radius: 50%;
    background: rgba(21, 18, 25, 0.08);
    color: var(--sp-text);
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.remove-color:hover  { background: var(--sp-danger); color: #fff; transform: scale(1.1); }
.remove-color:active { transform: scale(0.92); }

.selected-size {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 0 !important;
    padding: 6px 12px;
    background: var(--sp-surface);
    border: 1.5px solid var(--sp-border-soft);
    border-radius: 999px;
    font-size: 14px;
    font-weight: 600;
}

.confirm-button {
    width: 100%;
    min-height: 52px;
    padding: 13px 14px;
    border: none;
    border-radius: 16px;
    background: var(--sp-purple);
    color: #fff;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease, opacity 0.15s ease;
}

.confirm-button:hover:not(:disabled)  { background: var(--sp-purple-hover); }
.confirm-button:active:not(:disabled) { transform: scale(0.97); }
.confirm-button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .top-bar { padding: 16px 20px; }
    .top-bar h2 { font-size: 1.5rem; }
    main { padding: 8px 20px 24px; }
    #create-art-btn { right: 20px; bottom: 20px; }
    .art-thumbnail { width: 84px; height: 84px; }
}

@media (max-width: 576px) {
    .modal { padding: 0; }
    .modal-content {
        max-width: 100%;
        margin: 8vh 0 0;
        min-height: 92vh;
        border-radius: 20px 20px 0 0;
        padding-bottom: 32px;
    }
    .variant-selection-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .variant-selection-grid[data-type="size"] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}