/**
 * Silenthought — Invitation Card Calculator (IC-001)
 *
 * Visual style mirrors the product-page.css button system:
 *   .ic-option-btn  → same look as .st-var-btn  (red when selected)
 *   .ic-qty-btn     → same look as .st-qty-option (black when selected)
 *   .ic-toggle-btn  → same look as .st-var-btn
 *   .ic-type-btn    → same look as .st-var-btn
 *
 * Uses CSS variables from product-page.css (:root block):
 *   --st-red, --st-black, --st-gray-50/100/200/300/600/900
 *   --shadow-sm, --shadow-md
 *
 * Class names are all ic-* to avoid collisions with product-page.js listeners.
 * @package Silenthought
 */

/* ── Wrapper: no card border; flows naturally in the product info column ─ */
.ic-calculator {
    margin: 0;
    font-family: 'Poppins', sans-serif;
}

/* ── Section: matches .st-variation-group spacing ────────────────────── */
.ic-section {
    margin-bottom: 20px;
}

/* ── Section label: mirrors .st-variation-label exactly ──────────────── */
.ic-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--st-black);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Base pill button (used for Design Toggle, Type, Size, Color) ────── */
/* Mirrors .st-var-btn exactly — red highlight on selected */
.ic-option-btn,
.ic-toggle-btn,
.ic-type-btn {
    padding: 10px 20px;
    background: #fff;
    border: 2px solid var(--st-gray-200);
    border-radius: 50px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--st-black);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.ic-option-btn:hover,
.ic-toggle-btn:hover,
.ic-type-btn:hover {
    border-color: var(--st-black);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.ic-option-btn.selected,
.ic-toggle-btn.selected,
.ic-type-btn.selected {
    background: var(--st-red);
    border-color: var(--st-red);
    color: #fff;
    box-shadow: 0 6px 20px rgba(235, 31, 58, 0.4);
    transform: translateY(-2px);
}

/* ── Quantity buttons: mirrors .st-qty-option — black highlight ────── */
.ic-qty-btn {
    padding: 10px 20px;
    background: #fff;
    border: 2px solid var(--st-gray-200);
    border-radius: 50px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--st-black);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 90px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.ic-qty-btn:hover {
    border-color: var(--st-black);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.ic-qty-btn.selected {
    background: var(--st-black);
    border-color: var(--st-black);
    color: #fff;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
    transform: translateY(-2px);
}

/* ── Button rows ──────────────────────────────────────────────────────── */
.ic-btn-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Design toggle: 2-column grid */
.ic-design-toggle {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.ic-toggle-btn {
    flex: 1;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 12px;
}

.ic-toggle-icon  { font-size: 20px; line-height: 1; }
.ic-toggle-label { font-size: 0.85rem; font-weight: 700; }
.ic-toggle-sub   { font-size: 0.7rem; font-weight: 400; opacity: 0.75; }

.ic-toggle-btn.selected .ic-toggle-sub { opacity: 0.85; }

/* Type buttons: single row, icons */
.ic-type-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
}

.ic-type-icon { font-size: 16px; line-height: 1; }

/* ── Wedding Theme Selector ───────────────────────────────────────────── */
.ic-theme-row {
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.ic-theme-btn {
    padding: 8px 20px;
    background: #fff;
    border: 2px solid var(--st-gray-200);
    border-radius: 50px;
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    font-size: 0.78rem;
    color: var(--st-black);
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.ic-theme-btn:hover {
    border-color: var(--st-black);
    transform: translateY(-2px);
}

.ic-theme-btn.selected {
    background: var(--st-red);
    border-color: var(--st-red);
    color: #fff;
    box-shadow: 0 4px 14px rgba(235, 31, 58, 0.35);
    transform: translateY(-1px);
}

/* ── Ready Design Grid ────────────────────────────────────────────────── */
.ic-grid-hint {
    font-size: 12px;
    color: var(--st-gray-600);
    margin-bottom: 8px;
    font-family: 'DM Sans', sans-serif;
}

.ic-design-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 10px;
    max-height: 320px;
    overflow-y: auto;
    padding: 2px;
}

.ic-design-thumb {
    position: relative;
    border: 2px solid var(--st-gray-200);
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--st-gray-50);
}

.ic-design-thumb:hover {
    border-color: var(--st-black);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.ic-design-thumb.selected {
    border-color: var(--st-red);
    box-shadow: 0 0 0 3px rgba(235, 31, 58, 0.2);
}

.ic-design-thumb img {
    width: 100%;
    aspect-ratio: 3 / 4;
    object-fit: cover;
    display: block;
}

/* Hover overlay: "Preview" hint */
.ic-design-thumb::before {
    content: '🔍 Preview';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.48);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 1;
    pointer-events: none;
    border-radius: 8px;
}
.ic-design-thumb:hover::before { opacity: 1; }
.ic-design-thumb.selected::before { display: none; }

.ic-design-check {
    display: none;
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--st-red);
    color: #fff;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 11px;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.ic-design-thumb.selected .ic-design-check { display: flex; }

.ic-design-label {
    font-size: 10px;
    color: var(--st-gray-600);
    text-align: center;
    padding: 4px;
    background: #fff;
    line-height: 1.3;
    word-break: break-word;
}

.ic-selected-design-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--st-gray-50);
    border: 1.5px solid var(--st-gray-200);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--st-gray-900);
    margin-top: 10px;
    font-family: 'DM Sans', sans-serif;
    font-weight: 600;
}

.ic-clear-design {
    margin-left: auto;
    background: none;
    border: 1.5px solid var(--st-gray-300);
    border-radius: 50px;
    color: var(--st-gray-600);
    font-size: 11px;
    cursor: pointer;
    padding: 3px 10px;
    font-family: 'DM Sans', sans-serif;
    flex-shrink: 0;
    transition: all 0.2s;
}

.ic-clear-design:hover {
    border-color: var(--st-red);
    color: var(--st-red);
}

.ic-no-designs {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 24px;
    border: 2px dashed var(--st-gray-200);
    border-radius: 10px;
    color: var(--st-gray-600);
    text-align: center;
    font-size: 13px;
    font-family: 'DM Sans', sans-serif;
}

/* ── Own Design Method Selector ──────────────────────────────────────── */
.ic-own-method-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.ic-own-method-btn {
    flex: 1;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 12px;
    background: #fff;
    border: 2px solid var(--st-gray-200);
    border-radius: 12px;
    font-family: 'Poppins', sans-serif;
    color: var(--st-black);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.ic-own-method-btn:hover {
    border-color: var(--st-black);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.ic-own-method-btn.selected {
    background: var(--st-red);
    border-color: var(--st-red);
    color: #fff;
    box-shadow: 0 6px 20px rgba(235, 31, 58, 0.4);
    transform: translateY(-2px);
}

.ic-method-icon  { font-size: 20px; line-height: 1; }
.ic-method-label { font-size: 0.85rem; font-weight: 700; }
.ic-method-sub   { font-size: 0.7rem; font-weight: 400; opacity: 0.75; }

.ic-own-method-btn.selected .ic-method-sub { opacity: 0.85; }

/* ── Own Design Upload ────────────────────────────────────────────────── */
.ic-upload-area {
    border: 2px dashed var(--st-gray-300);
    border-radius: 10px;
    padding: 28px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--st-gray-50);
    font-family: 'DM Sans', sans-serif;
}

.ic-upload-area:hover,
.ic-upload-area--drag {
    border-color: var(--st-red);
    background: #fff5f6;
}

.ic-upload-icon  { font-size: 28px; margin-bottom: 8px; }
.ic-upload-text  { font-size: 14px; color: var(--st-black); margin-bottom: 4px; }
.ic-upload-hint  { font-size: 12px; color: var(--st-gray-600); margin: 0; }

.ic-upload-progress { padding: 10px 0; }

.ic-progress-bar {
    height: 5px;
    background: var(--st-gray-100);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.ic-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--st-red), #c91a31);
    border-radius: 3px;
    transition: width 0.2s ease;
    width: 0%;
}

#ic-progress-text { font-size: 12px; color: var(--st-gray-600); font-family: 'DM Sans', sans-serif; }

.ic-upload-done {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f0fdf4;
    border: 1.5px solid #86efac;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    color: #166534;
    font-family: 'DM Sans', sans-serif;
}

.ic-upload-ok { font-weight: 700; color: #16a34a; font-size: 16px; }

.ic-remove-file {
    margin-left: auto;
    background: none;
    border: 1.5px solid #86efac;
    border-radius: 50px;
    color: #15803d;
    font-size: 11px;
    cursor: pointer;
    padding: 3px 10px;
    font-family: 'DM Sans', sans-serif;
    flex-shrink: 0;
    transition: all 0.2s;
}

.ic-remove-file:hover { background: #dcfce7; }

.ic-upload-error {
    background: #fef2f2;
    border: 1.5px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
    padding: 8px 12px;
    font-size: 12px;
    margin-top: 8px;
    font-family: 'DM Sans', sans-serif;
}

/* ── Custom Fields ────────────────────────────────────────────────── */
.ic-custom-fields {
    border: 1.5px solid var(--st-gray-200);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
    background: var(--st-gray-50);
}

.ic-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.ic-field { display: flex; flex-direction: column; gap: 5px; }
.ic-field--full { grid-column: span 2; }

.ic-field label {
    font-family: 'Poppins', sans-serif;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--st-gray-600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ic-req { color: var(--st-red); }
.ic-optional {
    color: var(--st-gray-600);
    font-weight: 400;
    text-transform: none;
    font-size: 0.7rem;
    letter-spacing: 0;
}

/* Bride / Groom name pair wrapper */
.ic-name-pair {
    background: #fff;
    border: 1.5px solid var(--st-gray-200);
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 12px;
}

.ic-name-pair-heading {
    font-family: 'Poppins', sans-serif;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--st-black);
    margin: 0 0 2px;
}

.ic-field-hint {
    font-size: 11px;
    color: var(--st-gray-600);
    margin: 2px 0 0;
    font-family: 'DM Sans', sans-serif;
    line-height: 1.4;
}

/* ── Inputs & Textareas ────────────────────────────────────────────── */
.ic-text-input,
.ic-select {
    padding: 12px 14px;
    border: 1.5px solid var(--st-gray-200);
    border-radius: 8px;
    font-size: 14px;
    font-family: 'DM Sans', sans-serif;
    color: var(--st-black);
    background: #fff;
    transition: border-color 0.2s;
    width: 100%;
    box-sizing: border-box;
}

/* Single-line inputs: tall enough to feel spacious */
input.ic-text-input {
    min-height: 52px;
}

/* Textareas: generous height, vertically resizable */
textarea.ic-text-input {
    min-height: 84px;
    resize: vertical;
    line-height: 1.55;
}

.ic-text-input:focus,
.ic-select:focus {
    outline: none;
    border-color: var(--st-red);
    box-shadow: 0 0 0 3px rgba(235, 31, 58, 0.1);
}

/* ── Price Breakdown ──────────────────────────────────────────────────── */
.ic-breakdown {
    background: var(--st-gray-50);
    border: 1.5px solid var(--st-gray-200);
    border-radius: 10px;
    padding: 16px;
    margin: 16px 0;
    font-family: 'DM Sans', sans-serif;
}

.ic-bd-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--st-gray-100);
    font-size: 13px;
    color: var(--st-gray-600);
}

.ic-bd-row:last-of-type { border-bottom: none; }
.ic-bd-row strong { color: var(--st-black); font-weight: 600; }

.ic-bd-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 2px solid var(--st-gray-200);
    font-size: 15px;
    font-weight: 700;
    color: var(--st-black);
    font-family: 'Poppins', sans-serif;
}

.ic-bd-total strong {
    font-size: 20px;
    color: var(--st-red);
}

/* ── Notices / Errors / Loading ───────────────────────────────────────── */
.ic-notice {
    background: #fff7ed;
    border: 1.5px solid #fed7aa;
    border-radius: 8px;
    color: #9a3412;
    padding: 10px 14px;
    font-size: 12px;
    margin: 10px 0;
    font-family: 'DM Sans', sans-serif;
}

.ic-error {
    background: #fef2f2;
    border: 1.5px solid #fecaca;
    border-radius: 8px;
    color: #dc2626;
    padding: 10px 14px;
    font-size: 12px;
    margin: 10px 0;
    font-family: 'DM Sans', sans-serif;
}

.ic-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--st-gray-600);
    font-size: 12px;
    padding: 8px 0;
    font-family: 'DM Sans', sans-serif;
}

.ic-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--st-gray-200);
    border-top-color: var(--st-red);
    border-radius: 50%;
    animation: ic-spin 0.6s linear infinite;
    flex-shrink: 0;
}

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

/* ── Pricing reference table override ────────────────────────────────── */
.ic-price-table th,
.ic-price-table td { font-size: 11px; padding: 6px 8px; }

/* ── Design Lightbox ──────────────────────────────────────────────────── */
body.ic-lightbox-open { overflow: hidden; }

.ic-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

.ic-lightbox-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    cursor: pointer;
}

.ic-lightbox-dialog {
    position: relative;
    background: #fff;
    border-radius: 14px;
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4);
    z-index: 1;
}

.ic-lightbox-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    background: rgba(0, 0, 0, 0.55);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    padding: 0;
}

.ic-lightbox-close:hover { background: rgba(0, 0, 0, 0.85); }

.ic-lightbox-img-wrap {
    flex: 1;
    overflow: auto;
    background: #f9fafb;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.ic-lightbox-img {
    max-width: 100%;
    max-height: 62vh;
    object-fit: contain;
    display: block;
}

.ic-lightbox-footer {
    padding: 14px 16px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #fff;
    flex-shrink: 0;
}

.ic-lightbox-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--st-black);
    font-family: 'Poppins', sans-serif;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ic-lightbox-select-btn {
    background: var(--st-red);
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 10px 22px;
    font-size: 0.8rem;
    font-weight: 700;
    font-family: 'Poppins', sans-serif;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.25s;
    flex-shrink: 0;
}

.ic-lightbox-select-btn:hover {
    background: #c91a31;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(235, 31, 58, 0.4);
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .ic-field-row { grid-template-columns: 1fr; }
    .ic-field--full { grid-column: span 1; }
}

@media (max-width: 480px) {
    .ic-design-grid { grid-template-columns: repeat(3, 1fr); }
    .ic-btn-row { gap: 8px; }
    .ic-option-btn,
    .ic-qty-btn { font-size: 0.75rem; padding: 9px 14px; }
    .ic-toggle-btn { min-width: 0; flex: 1; }

    .ic-lightbox-dialog { border-radius: 10px; }
    .ic-lightbox-footer { flex-direction: column; align-items: stretch; }
    .ic-lightbox-select-btn { text-align: center; }
}

/* Active state consistent with product-page.css */
.ic-option-btn:active,
.ic-toggle-btn:active,
.ic-type-btn:active,
.ic-qty-btn:active,
.ic-theme-btn:active {
    transform: translateY(-1px);
}
