/* ==========================================================================
   Inhostify Smart Product Builder — Frontend CSS
   Design matches the reference image exactly
   ========================================================================== */

:root {
    --ihspb-accent: #e8590c;
    --ihspb-accent-light: rgba(232,89,12,.08);
    --ihspb-accent-gradient: linear-gradient(90deg, #e8590c 0%, #f59e0b 50%, #f59e0b 100%);
    --ihspb-text-dark: #1a1a2e;
    --ihspb-text-body: #334155;
    --ihspb-text-muted: #64748b;
    --ihspb-green: #10b981;
    --ihspb-green-price: #059669;
    --ihspb-red-strike: #94a3b8;
    --ihspb-border: #e2e8f0;
    --ihspb-bg-white: #ffffff;
    --ihspb-bg-light: #f8fafc;
    --ihspb-radius: 16px;
    --ihspb-radius-sm: 8px;
    --ihspb-font: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, sans-serif;
    --ihspb-shadow: 0 8px 30px rgba(0,0,0,.08);
    --ihspb-transition: all .3s ease;
}

/* ---- Builder Container ---- */
.ihspb-builder {
    background: var(--ihspb-bg-white);
    border-radius: var(--ihspb-radius);
    box-shadow: var(--ihspb-shadow);
    margin: 20px 0;
    overflow: hidden;
    font-family: var(--ihspb-font);
    color: var(--ihspb-text-body);
    border: 1px solid var(--ihspb-border);
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
    clear: both;
    display: block;
}

/* Fix standard WooCommerce Quantity & Add to Cart alignment */
.ihspb-cart-form,
form.cart,
form[class*="cart"] {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    max-width: 100% !important;
}

.ihspb-cart-form .ihspb-builder,
form.cart .ihspb-builder {
    flex: 0 0 100% !important;
    max-width: 100% !important;
    order: 0 !important;
}

.ihspb-cart-form .quantity,
form.cart .quantity,
form[class*="cart"] .quantity {
    display: inline-flex !important;
    float: none !important;
    margin-right: 15px !important;
    margin-bottom: 15px !important;
    order: 10 !important;
    flex: 0 0 auto !important;
}

.ihspb-cart-form .single_add_to_cart_button,
form.cart .single_add_to_cart_button,
form[class*="cart"] .single_add_to_cart_button {
    float: none !important;
    margin-bottom: 15px !important;
    order: 11 !important;
    flex: 1 !important;
    min-width: 150px !important;
}

/* Move Buy Now button after Add to Cart */
.ihspb-cart-form #buynow, 
.ihspb-cart-form .buy_now_button, 
.ihspb-cart-form .wc-buy-now-button, 
.ihspb-cart-form .direct-checkout-button, 
.ihspb-cart-form .single-buy-now,
.ihspb-cart-form .wp-element-button[name="buy-now"],
.ihspb-cart-form button[id*="buy-now"],
.ihspb-cart-form a[class*="buy-now"] { 
    order: 20 !important; 
    flex: 0 0 100% !important;
    width: 100% !important;
    margin-top: 5px !important;
    margin-bottom: 15px !important;
    display: block !important;
}

/* Hide builder in cloned sticky carts so it doesn't cover the screen */
.klb-sticky-cart .ihspb-builder,
.partdo-sticky-cart .ihspb-builder,
.partdo-sticky-add-to-cart .ihspb-builder,
.klb-sticky-add-to-cart .ihspb-builder,
.sticky-add-to-cart .ihspb-builder,
.sticky-cart-form .ihspb-builder,
.mobile-sticky-cart .ihspb-builder,
.mobile-bottom-bar .ihspb-builder,
.elementor-sticky .ihspb-builder,
.is-sticky .ihspb-builder,
.stuck .ihspb-builder {
    display: none !important;
}

/* ---- Header ---- */
.ihspb-header {
    padding: 28px 28px 0;
    background: linear-gradient(to bottom, var(--ihspb-accent-light), transparent);
}

.ihspb-badge-text {
    display: inline-block;
    color: var(--ihspb-accent);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    margin-bottom: 8px;
    padding: 4px 10px;
    background: rgba(232,89,12,.1);
    border-radius: 20px;
}

.ihspb-main-title {
    font-size: 22px;
    font-weight: 800;
    color: var(--ihspb-text-dark);
    margin: 0 0 6px;
    line-height: 1.3;
    letter-spacing: -0.5px;
}

.ihspb-sub-title {
    font-size: 14px;
    color: var(--ihspb-text-muted);
    margin: 0 0 20px;
    line-height: 1.5;
}

.ihspb-gradient-bar {
    height: 5px;
    background: var(--ihspb-accent-gradient);
    border-radius: 5px 5px 0 0;
    margin: 0 -28px;
}

/* ---- Section Title ---- */
.ihspb-section-title {
    padding: 20px 28px 12px;
    border-top: 1px solid var(--ihspb-border);
    background: var(--ihspb-bg-light);
}

.ihspb-section-title strong {
    font-size: 16px;
    font-weight: 700;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ---- Field Row (Checkbox / Radio) ---- */
.ihspb-field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    border-bottom: 1px solid #f1f5f9;
    transition: var(--ihspb-transition);
}

.ihspb-field-row:hover {
    background: var(--ihspb-bg-light);
}

/* ---- Checkbox ---- */
.ihspb-check-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    flex: 1;
    font-size: 15px;
    font-weight: 500;
    color: var(--ihspb-text-body);
    line-height: 1.4;
}

.ihspb-checkbox-input,
.ihspb-radio-input {
    display: none;
}

.ihspb-check-box {
    width: 22px;
    height: 22px;
    border: 2px solid #cbd5e1;
    border-radius: 6px;
    flex-shrink: 0;
    position: relative;
    transition: var(--ihspb-transition);
    background: var(--ihspb-bg-white);
}

.ihspb-checkbox-input:checked + .ihspb-check-box {
    background: var(--ihspb-accent);
    border-color: var(--ihspb-accent);
    box-shadow: 0 0 0 3px rgba(232,89,12,.2);
}

.ihspb-checkbox-input:checked + .ihspb-check-box::after {
    content: '✓';
    color: #fff;
    font-size: 14px;
    font-weight: 800;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* ---- Radio Dot ---- */
.ihspb-radio-dot {
    width: 22px;
    height: 22px;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    flex-shrink: 0;
    position: relative;
    transition: var(--ihspb-transition);
    background: var(--ihspb-bg-white);
}

.ihspb-radio-input:checked + .ihspb-radio-dot {
    border-color: var(--ihspb-accent);
    box-shadow: 0 0 0 3px rgba(232,89,12,.2);
}

.ihspb-radio-input:checked + .ihspb-radio-dot::after {
    content: '';
    width: 10px;
    height: 10px;
    background: var(--ihspb-accent);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.ihspb-check-text {
    font-size: 15px;
}

.ihspb-info-tip {
    cursor: help;
    font-size: 15px;
    margin-left: 4px;
    color: #94a3b8;
    transition: color .2s ease;
}

.ihspb-info-tip:hover {
    color: var(--ihspb-accent);
}

/* ---- Prices ---- */
.ihspb-field-price {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    white-space: nowrap;
    background: #f1f5f9;
    padding: 4px 10px;
    border-radius: 20px;
}

.ihspb-price-old {
    text-decoration: line-through;
    color: var(--ihspb-red-strike);
    font-size: 13px;
}

.ihspb-price-current {
    font-weight: 700;
    font-size: 15px;
    color: var(--ihspb-green-price);
}

/* ---- Field Blocks (Text, Textarea, Dropdown, Number, Color) ---- */
.ihspb-field-block {
    padding: 18px 28px;
    border-bottom: 1px solid #f1f5f9;
}

.ihspb-field-block-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.ihspb-field-block-label {
    font-size: 15px;
    font-weight: 600;
    color: var(--ihspb-text-dark);
}

.ihspb-req {
    color: #ef4444;
}

/* ---- Text Input ---- */
.ihspb-text-input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--ihspb-border);
    border-radius: 12px;
    font-size: 15px;
    font-family: var(--ihspb-font);
    color: #0f172a;
    background: var(--ihspb-bg-light);
    transition: var(--ihspb-transition);
    box-sizing: border-box;
    outline: none;
}

.ihspb-text-input:focus {
    border-color: var(--ihspb-accent);
    background: var(--ihspb-bg-white);
    box-shadow: 0 4px 12px rgba(0,0,0,.03);
}

.ihspb-text-input::placeholder {
    color: #a0aec0;
}

.ihspb-textarea-input {
    border-radius: 12px;
    min-height: 90px;
    resize: vertical;
}

/* ---- Characters Remaining ---- */
.ihspb-chars-remaining {
    font-size: 13px;
    color: #64748b;
    margin-top: 6px;
    padding-left: 4px;
}

/* ---- Select / Dropdown ---- */
.ihspb-select-input {
    width: 100%;
    padding: 14px 18px;
    border: 2px solid var(--ihspb-border);
    border-radius: 12px;
    font-size: 15px;
    font-family: var(--ihspb-font);
    color: #0f172a;
    background: var(--ihspb-bg-light);
    cursor: pointer;
    transition: var(--ihspb-transition);
    outline: none;
    box-sizing: border-box;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

.ihspb-select-input:focus {
    border-color: var(--ihspb-accent);
    background: var(--ihspb-bg-white);
    box-shadow: 0 4px 12px rgba(0,0,0,.03);
}

/* ---- Number Input ---- */
.ihspb-number-input {
    width: 90px;
    padding: 12px;
    border: 2px solid var(--ihspb-border);
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    font-family: var(--ihspb-font);
    text-align: center;
    background: var(--ihspb-bg-light);
    transition: var(--ihspb-transition);
    outline: none;
}

.ihspb-number-input:focus {
    border-color: var(--ihspb-accent);
    background: var(--ihspb-bg-white);
}

/* ---- File Upload ---- */
.ihspb-file-zone {
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all .3s ease;
    background: var(--ihspb-bg-light);
    position: relative;
}

.ihspb-file-zone:hover {
    border-color: var(--ihspb-accent);
    background: var(--ihspb-bg-white);
    box-shadow: 0 4px 12px rgba(0,0,0,.04);
}

.ihspb-file-zone input {
    display: none;
}

.ihspb-file-icon {
    font-size: 36px;
    margin-bottom: 10px;
    opacity: 0.8;
}

.ihspb-file-text {
    font-size: 14px;
    color: #475569;
    font-weight: 500;
}

.ihspb-file-name {
    font-size: 14px;
    color: #059669;
    margin-top: 10px;
    font-weight: 700;
    background: #ecfdf5;
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
}

/* ---- Color Input ---- */
.ihspb-color-input {
    width: 60px;
    height: 46px;
    border: 2px solid var(--ihspb-border);
    border-radius: 10px;
    cursor: pointer;
    padding: 2px;
    background: var(--ihspb-bg-light);
    transition: var(--ihspb-transition);
}

.ihspb-color-input:hover {
    border-color: #cbd5e1;
}

/* ---- Totals Section ---- */
.ihspb-totals-section {
    padding: 20px 28px 24px;
    border-top: 1px solid var(--ihspb-border);
    background: var(--ihspb-bg-light);
}

.ihspb-totals-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 12px;
}

.ihspb-totals-label {
    font-size: 15px;
    font-weight: 600;
    color: #475569;
}

.ihspb-totals-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--ihspb-text-dark);
}

.ihspb-totals-final {
    margin-bottom: 0;
}

.ihspb-final-amount {
    font-size: 32px;
    font-weight: 800;
    color: var(--ihspb-text-dark);
    transition: var(--ihspb-transition);
    letter-spacing: -1px;
}

/* ---- Animation on price change ---- */
@keyframes ihspb-pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.ihspb-final-amount.ihspb-price-changed {
    animation: ihspb-pulse .3s ease;
}

/* ---- Fade in ---- */
.ihspb-builder {
    animation: ihspb-fadeIn .4s ease-out;
}

@keyframes ihspb-fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- Focus States (Accessibility) ---- */
.ihspb-check-label:focus-within .ihspb-check-box,
.ihspb-check-label:focus-within .ihspb-radio-dot {
    box-shadow: 0 0 0 3px rgba(232,89,12,.15);
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
    .ihspb-header { padding: 16px 16px 0; }
    .ihspb-main-title { font-size: 17px; }
    .ihspb-field-row, .ihspb-field-block { padding-left: 16px; padding-right: 16px; }
    .ihspb-totals-section { padding: 14px 16px 16px; }
    .ihspb-final-amount { font-size: 22px; }
    .ihspb-price-current { font-size: 13px; }
}

/* ---- RTL ---- */
[dir="rtl"] .ihspb-builder { text-align: right; }
[dir="rtl"] .ihspb-field-row { flex-direction: row-reverse; }
[dir="rtl"] .ihspb-chars-remaining { padding-left: 0; padding-right: 4px; }
[dir="rtl"] .ihspb-info-tip { margin-left: 0; margin-right: 4px; }
