/* ==========================================================================
   Frontend Styles for WooCommerce Product Personalization Options
   ========================================================================== */

.wcpcs-swatches-container {
    margin: 18px 0 22px 0;
    font-family: inherit;
    clear: both;
    box-sizing: border-box;
}

/* Personalization Toggle Checkbox */
.wcpcs-toggle-wrap {
    margin-bottom: 0;
}

.wcpcs-toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    padding: 6px 0;
    transition: color 0.2s ease;
}

.wcpcs-toggle-label:hover {
    color: #0f172a;
}

.wcpcs-toggle-checkbox {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

/* Custom Checkbox Design */
.wcpcs-custom-checkbox {
    position: relative;
    display: inline-block;
    width: 20px;
    height: 20px;
    background-color: #ffffff;
    border: 2px solid #cbd5e1;
    border-radius: 5px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
    flex-shrink: 0;
}

.wcpcs-toggle-label:hover .wcpcs-custom-checkbox {
    border-color: #94a3b8;
}

.wcpcs-toggle-checkbox:checked ~ .wcpcs-custom-checkbox {
    background-color: #0f172a;
    border-color: #0f172a;
}

.wcpcs-custom-checkbox::after {
    content: "";
    position: absolute;
    display: none;
    left: 6px;
    top: 2px;
    width: 5px;
    height: 10px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.wcpcs-toggle-checkbox:checked ~ .wcpcs-custom-checkbox::after {
    display: block;
}

.wcpcs-toggle-title {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
}

/* ==========================================================================
   Butter-smooth Grid Accordion
   ========================================================================== */
.wcpcs-swatches-body {
    display: grid !important;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.38s cubic-bezier(0.25, 1, 0.5, 1),
                opacity 0.3s ease,
                margin-top 0.38s cubic-bezier(0.25, 1, 0.5, 1);
    opacity: 0;
    margin-top: 0;
    visibility: hidden;
    overflow: hidden;
}

.wcpcs-swatches-body.is-open {
    grid-template-rows: 1fr;
    opacity: 1;
    margin-top: 10px;
    visibility: visible;
}

.wcpcs-swatches-inner {
    min-height: 0;
    overflow: visible;
}

.wcpcs-swatches-card {
    padding: 18px 20px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-sizing: border-box;
}

/* Sections */
.wcpcs-section {
    position: relative;
}

.wcpcs-color-section {
    margin-bottom: 0;
}

.wcpcs-font-section,
.wcpcs-name-section,
.wcpcs-date-section,
.wcpcs-note-section {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px dashed #e2e8f0;
}

/* Personalization Note Box */
.wcpcs-personalization-note {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 14px;
    background: #f1f5f9;
    border-left: 3.5px solid #0f172a;
    border-radius: 6px;
    box-sizing: border-box;
}

.wcpcs-note-icon {
    font-size: 17px;
    color: #0f172a;
    line-height: 1.2;
    flex-shrink: 0;
    margin-top: 1px;
}

.wcpcs-note-content {
    flex: 1;
    font-size: 13px;
    line-height: 1.5;
    color: #475569;
}

.wcpcs-note-content p:last-child {
    margin-bottom: 0 !important;
}

/* Header Typography */
.wcpcs-swatches-header,
.wcpcs-font-header,
.wcpcs-input-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.4;
}

.wcpcs-swatches-header .wcpcs-label,
.wcpcs-font-header .wcpcs-label,
.wcpcs-input-header .wcpcs-label {
    color: #475569;
    font-weight: 600;
    font-size: 13.5px;
}

.wcpcs-swatches-header .wcpcs-selected-name,
.wcpcs-font-header .wcpcs-selected-font-preview {
    display: inline-flex;
    align-items: center;
    color: #0f172a;
    font-weight: 700;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 12.5px;
    min-height: 24px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
}

.wcpcs-required-badge {
    color: #ef4444;
    font-weight: 700;
    font-size: 15px;
    margin-left: 2px;
    line-height: 1;
}

/* Swatches List */
.wcpcs-swatches-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 4px 0;
    list-style: none;
}

/* Base Swatch Item */
button.wcpcs-swatch-item,
.wcpcs-swatch-item {
    position: relative !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
    min-height: 36px !important;
    max-width: 36px !important;
    max-height: 36px !important;
    padding: 2px !important;
    margin: 0 !important;
    background: #ffffff !important;
    background-color: #ffffff !important;
    border: 2px solid #e2e8f0 !important;
    border-radius: 7px !important;
    cursor: pointer !important;
    outline: none !important;
    box-shadow: none !important;
    line-height: 1 !important;
    text-transform: none !important;
    font-size: 0 !important;
    box-sizing: border-box !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), 
                border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* Inner Color Box */
.wcpcs-swatch-box,
.wcpcs-swatch-circle {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 5px !important;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1) !important;
    box-sizing: border-box !important;
}

/* Border outline for bright / white shades */
.wcpcs-swatch-item.is-light .wcpcs-swatch-box,
.wcpcs-swatch-item.is-light .wcpcs-swatch-circle {
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.22) !important;
}

/* Minimal Checkmark */
.wcpcs-swatch-check {
    position: absolute;
    color: #ffffff;
    font-size: 14px !important;
    font-weight: 900;
    line-height: 1;
    opacity: 0;
    transform: scale(0.5);
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
    z-index: 2;
}

.wcpcs-swatch-item.is-light .wcpcs-swatch-check {
    color: #0f172a;
    text-shadow: none;
}

/* Floating Hover Tooltip (Properly offset so it doesn't overlap text) */
.wcpcs-tooltip {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: #0f172a;
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    z-index: 50;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1.2;
}

.wcpcs-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 4px;
    border-style: solid;
    border-color: #0f172a transparent transparent transparent;
}

/* Hover State */
button.wcpcs-swatch-item:hover,
.wcpcs-swatch-item:hover {
    transform: translateY(-2px) !important;
    border-color: #94a3b8 !important;
}

button.wcpcs-swatch-item:hover .wcpcs-tooltip,
.wcpcs-swatch-item:hover .wcpcs-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Selected State: SINGLE CLEAN MATCHING BORDER (NO BIG OUTER RING!) */
button.wcpcs-swatch-item.is-selected,
.wcpcs-swatch-item.is-selected {
    border-color: var(--swatch-color) !important;
    border-width: 2.5px !important;
    box-shadow: none !important;
    transform: translateY(-2px) !important;
}

/* Light / White color selected state */
button.wcpcs-swatch-item.is-light.is-selected,
.wcpcs-swatch-item.is-light.is-selected {
    border-color: #1e293b !important;
    border-width: 2.5px !important;
    box-shadow: none !important;
}

.wcpcs-swatch-item.is-selected .wcpcs-swatch-check {
    opacity: 1;
    transform: scale(1);
}

/* ==========================================================================
   Font Family Dropdown & Text Inputs Styling
   ========================================================================== */
.wcpcs-font-select-wrapper,
.wcpcs-input-wrapper {
    position: relative;
    max-width: 100%;
}

.wcpcs-font-select,
.wcpcs-custom-text-input,
.wcpcs-custom-date-input {
    width: 100% !important;
    height: 42px !important;
    padding: 8px 14px !important;
    background: #ffffff !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 7px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    color: #1e293b !important;
    outline: none !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important;
    box-sizing: border-box !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}

.wcpcs-font-select {
    padding-right: 36px !important;
    cursor: pointer !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
}

.wcpcs-font-select:focus,
.wcpcs-custom-text-input:focus,
.wcpcs-custom-date-input:focus {
    border-color: #0f172a !important;
    box-shadow: 0 0 0 1px #0f172a !important;
}

.wcpcs-select-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: #64748b;
    font-size: 16px;
}

/* Error State */
.wcpcs-swatches-container.wcpcs-has-error .wcpcs-swatches-card {
    border: 1.5px solid #ef4444;
    background-color: #fef2f2;
    animation: wcpcs-shake 0.4s ease-in-out;
}

@keyframes wcpcs-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

/* ==========================================================================
   Checkout Dropdowns & Select2 Styling
   ========================================================================== */

/* Dropdown Container */
.woocommerce-checkout .select2-dropdown,
.select2-container .select2-dropdown {
    border: 1px solid #cbd5e1 !important;
    border-radius: 8px !important;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.05) !important;
    background-color: #ffffff !important;
    overflow: hidden !important;
    z-index: 99999 !important;
}

/* Dropdown Options */
.woocommerce-checkout .select2-results__option,
.select2-container--default .select2-results__option {
    padding: 9px 14px !important;
    font-size: 14px !important;
    line-height: 1.4 !important;
    color: #334155 !important;
    transition: background-color 0.15s ease, color 0.15s ease !important;
}

/* Hover / Highlighted Option */
.woocommerce-checkout .select2-container--default .select2-results__option--highlighted[aria-selected],
.woocommerce-checkout .select2-container--default .select2-results__option--highlighted[data-selected],
.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted[data-selected] {
    background-color: #0f172a !important;
    color: #ffffff !important;
}

/* Selected Option (Default state) */
.woocommerce-checkout .select2-container--default .select2-results__option[aria-selected="true"],
.select2-container--default .select2-results__option[aria-selected="true"] {
    background-color: #f1f5f9 !important;
    color: #0f172a !important;
    font-weight: 600 !important;
}

/* Selected Option when also highlighted */
.woocommerce-checkout .select2-container--default .select2-results__option--highlighted[aria-selected="true"],
.select2-container--default .select2-results__option--highlighted[aria-selected="true"] {
    background-color: #0f172a !important;
    color: #ffffff !important;
}

/* Select2 Input Box / Selection Single */
.woocommerce-checkout .select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--single {
    height: 44px !important;
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 7px !important;
    background-color: #ffffff !important;
    display: flex !important;
    align-items: center !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}

.woocommerce-checkout .select2-container--default .select2-selection--single:focus,
.woocommerce-checkout .select2-container--default.select2-container--open .select2-selection--single {
    border-color: #0f172a !important;
    box-shadow: 0 0 0 1px #0f172a !important;
}

.woocommerce-checkout .select2-container--default .select2-selection--single .select2-selection__rendered,
.select2-container--default .select2-selection--single .select2-selection__rendered {
    line-height: 42px !important;
    padding-left: 14px !important;
    padding-right: 28px !important;
    color: #1e293b !important;
    font-size: 14px !important;
}

.woocommerce-checkout .select2-container--default .select2-selection--single .select2-selection__arrow,
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 42px !important;
    right: 8px !important;
}

/* Search input inside Select2 Dropdown */
.select2-container--default .select2-search--dropdown .select2-search__field {
    border: 1.5px solid #cbd5e1 !important;
    border-radius: 6px !important;
    padding: 8px 12px !important;
    font-size: 13.5px !important;
    outline: none !important;
}

.select2-container--default .select2-search--dropdown .select2-search__field:focus {
    border-color: #0f172a !important;
    box-shadow: 0 0 0 1px #0f172a !important;
}

/* ==========================================================================
   Checkout "Your Order" Table & Cart Item Width Optimization (Desktop)
   ========================================================================== */
@media (min-width: 768px) {
    .woocommerce-checkout table.shop_table,
    .woocommerce-checkout table.woocommerce-checkout-review-order-table {
        table-layout: fixed !important;
        width: 100% !important;
    }

    .woocommerce-checkout table.shop_table .cart_item td.product-name,
    .woocommerce-checkout table.shop_table th.product-name,
    .woocommerce-checkout table.woocommerce-checkout-review-order-table td.product-name,
    .woocommerce-checkout table.woocommerce-checkout-review-order-table th.product-name,
    .woocommerce-checkout .cart_item .product-name {
        width: 76% !important;
        max-width: 76% !important;
        padding-right: 18px !important;
        line-height: 1.55 !important;
        word-break: normal !important;
        overflow-wrap: break-word !important;
    }

    .woocommerce-checkout table.shop_table .cart_item td.product-total,
    .woocommerce-checkout table.shop_table th.product-total,
    .woocommerce-checkout table.woocommerce-checkout-review-order-table td.product-total,
    .woocommerce-checkout table.woocommerce-checkout-review-order-table th.product-total {
        width: 24% !important;
        text-align: right !important;
        white-space: nowrap !important;
        vertical-align: top !important;
    }
}

/* Order Item Meta Styling for Checkout & Cart */
.woocommerce-checkout .cart_item .product-name dl.variation,
.woocommerce-cart .cart_item .product-name dl.variation,
.woocommerce-checkout .wc-item-meta {
    margin-top: 8px !important;
    margin-bottom: 4px !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
    color: #475569 !important;
}

.woocommerce-checkout .cart_item .product-name dl.variation dt,
.woocommerce-cart .cart_item .product-name dl.variation dt {
    font-weight: 600 !important;
    color: #334155 !important;
    margin-top: 2px !important;
}

.woocommerce-checkout .cart_item .product-name dl.variation dd,
.woocommerce-cart .cart_item .product-name dl.variation dd {
    margin-bottom: 2px !important;
}

