/**
 * Quick Buy Popup Styles - Customizable Design System
 * Styled for admin customization via WordPress settings
 * Inspired by https://ui.shadcn.com/
 */

/* CSS Variables for Admin Customization - có thể override qua WordPress Customizer */
:root {
    /* Design System Colors - Admin có thể thay đổi */
    --qb-background            : 0 0% 100%;
    --qb-foreground            : 222.2 84% 4.9%;
    --qb-card                  : 0 0% 100%;
    --qb-card-foreground       : 222.2 84% 4.9%;
    --qb-popover               : 0 0% 100%;
    --qb-popover-foreground    : 222.2 84% 4.9%;
    --qb-primary               : 221.2 83.2% 53.3%;
    --qb-primary-foreground    : 210 40% 98%;
    --qb-secondary             : 210 40% 96%;
    --qb-secondary-foreground  : 222.2 84% 4.9%;
    --qb-muted                 : 210 40% 96%;
    --qb-muted-foreground      : 215.4 16.3% 46.9%;
    --qb-accent                : 210 40% 96%;
    --qb-accent-foreground     : 222.2 84% 4.9%;
    --qb-destructive           : 0 84.2% 60.2%;
    --qb-destructive-foreground: 210 40% 98%;
    --qb-border                : 214.3 31.8% 91.4%;
    --qb-input                 : 214.3 31.8% 91.4%;
    --qb-ring                  : 221.2 83.2% 53.3%;
    --qb-success               : 173 58% 39%;
    --qb-warning               : 43 74% 66%;
    --qb-radius                : 0.5rem;

    /* Typography Customization */
    --qb-font-size-xs  : 0.75rem;
    --qb-font-size-sm  : 0.875rem;
    --qb-font-size-base: 1rem;
    --qb-font-size-lg  : 1.125rem;
    --qb-font-size-xl  : 1.25rem;
    --qb-font-size-2xl : 1.5rem;

    /* Spacing Customization */
    --qb-spacing-xs : 0.25rem;
    --qb-spacing-sm : 0.5rem;
    --qb-spacing-md : 1rem;
    --qb-spacing-lg : 1.5rem;
    --qb-spacing-xl : 2rem;
    --qb-spacing-2xl: 2.5rem;

    /* Component Sizes */
    --qb-input-height   : 2.5rem;
    --qb-button-height  : 2.5rem;
    --qb-popup-max-width: 1200px;
    --qb-popup-padding  : 2rem;

    /* Layout Customization */
    --qb-layout-breakpoint-tablet: 768px;
    --qb-layout-breakpoint-mobile: 480px;

    /* Shadow Customization */
    --qb-shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --qb-shadow-md: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --qb-shadow-lg: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --qb-shadow-xl: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* Theme Variations - Admin có thể chọn theme */
[data-qb-theme="dark"] {
    --qb-background        : 222.2 84% 4.9%;
    --qb-foreground        : 210 40% 98%;
    --qb-card              : 222.2 84% 4.9%;
    --qb-card-foreground   : 210 40% 98%;
    --qb-popover           : 222.2 84% 4.9%;
    --qb-popover-foreground: 210 40% 98%;
    --qb-muted             : 217.2 32.6% 17.5%;
    --qb-muted-foreground  : 215 20.2% 65.1%;
    --qb-accent            : 217.2 32.6% 17.5%;
    --qb-accent-foreground : 210 40% 98%;
    --qb-border            : 217.2 32.6% 17.5%;
    --qb-input             : 217.2 32.6% 17.5%;
}

[data-qb-theme="blue"] {
    --qb-primary: 221.2 83.2% 53.3%;
    --qb-ring   : 221.2 83.2% 53.3%;
}

[data-qb-theme="green"] {
    --qb-primary: 142.1 76.2% 36.3%;
    --qb-ring   : 142.1 76.2% 36.3%;
}

[data-qb-theme="red"] {
    --qb-primary: 0 84.2% 60.2%;
    --qb-ring   : 0 84.2% 60.2%;
}

/* Container chính của popup - overlay toàn màn hình */
.order-container {
    position        : fixed;
    top             : 0;
    left            : 0;
    width           : 100%;
    height          : 100%;
    background-color: hsl(0 0% 0% / 0.8);
    backdrop-filter : blur(4px);
    z-index         : 9999;
    display         : flex;
    justify-content : center;
    align-items     : center;
    opacity         : 0;
    visibility      : hidden;
    transition      : opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.order-container.show {
    opacity   : 1;
    visibility: visible;
}

.order-container.show #content {
    overflow-y: scroll;
}

/* Nội dung popup chính - 2 Column Layout */
.popup-content {
    background    : hsl(var(--qb-card));
    border        : 1px solid hsl(var(--qb-border));
    border-radius : var(--qb-radius);
    max-width     : var(--qb-popup-max-width);
    width         : 98%;
    max-height    : 90vh;
    overflow      : hidden;
    box-shadow    : var(--qb-shadow-xl);
    display       : flex;
    flex-direction: column;
}

/* Header của popup */
.order-header {
    display        : flex;
    justify-content: space-between;
    align-items    : center;
    gap            : var(--qb-order-header-gap, 0.5rem);
    padding        : var(--qb-order-header-padding, 1rem);
    border-bottom  : 1px solid hsl(var(--qb-border));
    background     : hsl(var(--qb-card));
    flex-shrink    : 0;
}

.order-header span {
    font-size  : var(--qb-order-header-font-size, 1.25rem);
    font-weight: 600;
    color      : hsl(var(--qb-foreground));
    line-height: 1;
}

/* Nút đóng popup */
.close-button {
    background     : none;
    border         : none;
    font-size      : var(--qb-font-size-xl);
    cursor         : pointer;
    color          : hsl(var(--qb-muted-foreground));
    width          : var(--qb-spacing-2xl);
    height         : var(--qb-spacing-2xl);
    display        : flex;
    align-items    : center;
    justify-content: center;
    border-radius  : var(--qb-radius);
}

.close-button:hover {
    color     : hsl(var(--qb-foreground));
    background: hsl(var(--qb-secondary));
}

/* Body của popup - 2 Column Layout */
.order-body {
    display       : flex;
    flex-direction: row;
    gap           : 0;
    flex          : 1;
    width         : 100%;
    overflow      : hidden;
}

@media (max-width: 768px) {
    .order-body {
        flex-direction: column;
    }
}

/* Padding cho các section - Sử dụng CSS variables */
.order-header {
    padding: var(--qb-order-header-padding, 1rem) !important;
    gap    : var(--qb-order-header-gap, 0.5rem) !important;
}

/* Product Info Section - Padding và Gap */
.order-container .product-info.section-large {
    padding       : var(--qb-product-info-padding, 1.5rem) !important;
    box-sizing    : border-box;
    display       : flex;
    flex-direction: column;
    gap           : var(--qb-product-info-gap, 0.5rem);
    font-size     : var(--qb-product-info-font-size, 1rem);
}

.order-container .buyer-form.section-large {
    padding       : var(--qb-buyer-form-padding, 1.5rem) !important;
    box-sizing    : border-box;
    display       : flex;
    flex-direction: column;
    gap           : var(--qb-buyer-form-gap, 0.5rem);
    font-size     : var(--qb-buyer-form-font-size, 1rem);
}

.order-container .order-summary.section-large {
    padding       : var(--qb-order-summary-padding, 1.5rem) !important;
    box-sizing    : border-box;
    display       : flex;
    flex-direction: column;
    gap           : var(--qb-order-summary-gap, 0.5rem);
    font-size     : var(--qb-order-summary-font-size, 1rem);
}

/* Cột trái - Thông tin sản phẩm */
.product-info {
    border-right: 1px solid hsl(var(--qb-border));
    overflow-y  : auto;
    width       : 60% !important;
    background  : hsl(var(--qb-muted) / 0.3);
}

@media (max-width: 768px) {
    .product-info {
        width: 100% !important;
    }
}

/* Cột phải - Form đặt hàng */
.buyer-form {
    overflow-y: auto;
    width     : 40% !important;
    background: hsl(var(--qb-card));
}

@media (max-width: 768px) {
    .buyer-form {
        width: 100% !important;
    }
}

.product-basic-info {
    display    : flex;
    gap        : var(--qb-spacing-md);
    align-items: center;
}

.product-image {
    width        : 80px;
    height       : 80px;
    object-fit   : cover;
    border-radius: var(--qb-radius);
    border       : 1px solid hsl(var(--qb-border));
    box-shadow   : var(--qb-shadow-md);
}

.product-details {
    display       : flex;
    flex-direction: column;
    gap           : var(--qb-product-info-gap, 0.5rem);
}

.product-title {
    font-size  : var(--qb-font-size-xl);
    font-weight: 600;
    color      : hsl(var(--qb-foreground));
    line-height: 1.4;
}

.product-price {
    display       : flex;
    flex-direction: row;
    gap           : var(--qb-product-info-gap, 0.5rem);
}

.product-price-sale {
    font-weight: 600;
    color      : hsl(var(--qb-destructive));
    margin     : 0;
    font-size  : var(--qb-product-info-font-size, 1rem);
}

.product-price-regular {
    font-weight    : 600;
    color          : hsl(var(--qb-foreground));
    margin         : 0;
    font-size      : var(--qb-product-info-font-size, 1rem);
    text-decoration: line-through;
}

/* Product options section */
.product-options {
    display       : flex;
    flex-direction: column;
    gap           : var(--qb-product-info-gap, 0.5rem);
}

/* Labels theo Shadcn/UI */
.label {
    font-weight: 500;
    color      : hsl(var(--qb-foreground));
    line-height: 1.25rem;
}

/* Variation groups - Sử dụng gap từ parent thay vì margin-bottom */
.variation-group {
    margin-bottom: 0;
}

/* Nhóm options cho variants */
.options-group {
    display  : flex;
    flex-wrap: wrap;
    gap      : var(--qb-spacing-sm);
}

.option-button {
    display        : inline-flex;
    align-items    : center;
    justify-content: center;
    white-space    : nowrap;
    border-radius  : var(--qb-radius);
    font-size      : var(--qb-font-size-sm);
    font-weight    : 500;
    height         : var(--qb-button-height);
    padding        : 0 var(--qb-spacing-md);
    border         : 1px solid hsl(var(--qb-input));
    background     : hsl(var(--qb-background));
    color          : hsl(var(--qb-foreground));
    cursor         : pointer;
}

.option-button:hover {
    background  : hsl(var(--qb-accent));
    color       : hsl(var(--qb-accent-foreground));
    border-color: hsl(var(--qb-ring));
}

.option-button.selected {
    background  : hsl(var(--qb-primary));
    color       : hsl(var(--qb-primary-foreground));
    border-color: hsl(var(--qb-primary));
    box-shadow  : 0 0 0 2px hsl(var(--qb-ring) / 0.2);
}

.quantity-group {
    display        : flex;
    align-items    : center;
    gap            : var(--qb-spacing-sm);
    justify-content: flex-start;
}

.quantity-input {
    width        : 80px;
    height       : var(--qb-input-height);
    padding      : 0 0.75rem;
    text-align   : center;
    border       : 1px solid hsl(var(--qb-border));
    border-radius: var(--qb-radius);
    font-size    : var(--qb-font-size-sm);
    font-weight  : 500;
    background   : hsl(var(--qb-background));
    color        : hsl(var(--qb-foreground));
}

.quantity-input:focus {
    outline     : none;
    border-color: hsl(var(--qb-ring));
    box-shadow  : 0 0 0 2px hsl(var(--qb-ring) / 0.2);
}

.quantity-button-increase,
.quantity-button-decrease {
    width          : var(--qb-input-height);
    height         : var(--qb-input-height);
    border         : 1px solid hsl(var(--qb-border));
    background     : hsl(var(--qb-background));
    cursor         : pointer;
    font-size      : var(--qb-font-size-lg);
    font-weight    : 600;
    border-radius  : var(--qb-radius);
    color          : hsl(var(--qb-foreground));
    display        : flex;
    align-items    : center;
    justify-content: center;
    user-select    : none;
}

.quantity-button-increase:hover,
.quantity-button-decrease:hover {
    background  : hsl(var(--qb-secondary));
    border-color: hsl(var(--qb-ring));
}

.quantity-button-increase:active,
.quantity-button-decrease:active {
    background: hsl(var(--qb-muted));
    transform : scale(0.95);
}

/* Alert/Note component theo Shadcn/UI */
.note {
    border       : 1px solid hsl(var(--qb-warning) / 0.2);
    background   : hsl(var(--qb-warning) / 0.1);
    color        : hsl(var(--qb-foreground));
    padding      : var(--qb-spacing-md);
    border-radius: var(--qb-radius);
    line-height  : 1.5;
}

/* Form styling theo Shadcn/UI */
.buyer-form h3 {
    margin     : 0;
    color      : hsl(var(--qb-foreground));
    font-size  : var(--qb-buyer-form-font-size, 1rem);
    font-weight: 600;
    line-height: 1;
}

.form-row {
    display       : flex;
    flex-direction: row;
    gap           : var(--qb-spacing-sm);
    margin-bottom : 0;
}

/* Form Layout - Mặc định vertical (column) */
.order-container .buyer-form .form-row {
    flex-direction: row !important;
    gap           : var(--qb-buyer-form-gap, 0.5rem);
}

.form-rows:after,
.form-row:before {
    content: none !important;
}

.form-row:after {
    content: none !important;
}

/* Textarea và form-discount luôn column */
.order-container .buyer-form .form-row:has(textarea),
.order-container .buyer-form .form-row:has(.form-discount) {
    flex-direction: column !important;
}

/* Input fields styling theo Shadcn/UI */
.buyer-form input,
.buyer-form textarea,
.buyer-form select {
    display      : flex;
    height       : var(--qb-input-height) !important;
    width        : 100%;
    max-width    : 100%;
    border-radius: var(--qb-radius) !important;
    border       : 1px solid hsl(var(--qb-input)) !important;
    background   : hsl(var(--qb-background)) !important;
    padding      : 0.5rem 0.75rem !important;
    font-size    : var(--qb-buyer-form-font-size, 1rem) !important;
    color        : hsl(var(--qb-foreground)) !important;
    box-sizing   : border-box;
}

.buyer-form textarea {
    min-height: var(--qb-input-height);
    resize    : none;
}

.buyer-form input:focus,
.buyer-form textarea:focus,
.buyer-form select:focus {
    outline     : none;
    border-color: hsl(var(--qb-ring));
    box-shadow  : 0 0 0 2px hsl(var(--qb-ring) / 0.2);
}

.buyer-form input::placeholder,
.buyer-form textarea::placeholder {
    color: hsl(var(--qb-muted-foreground));
}

/* Select dropdown styling */
.form-select,
.wc-country-select,
.wc-state-select {
    appearance         : none;
    background-image   : url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 20 20"><path stroke="%236b7280" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M6 8l4 4 4-4"/></svg>');
    background-repeat  : no-repeat;
    background-position: right 0.75rem center;
    background-size    : 1rem;
    padding-right      : 2.5rem;
}

/* Form discount section */
.form-discount {
    display    : flex;
    gap        : var(--qb-spacing-sm);
    align-items: stretch;
}

.form-discount input {
    flex  : 1;
    margin: 0;
}

.apply-discount-button {
    display        : inline-flex;
    align-items    : center;
    justify-content: center;
    white-space    : nowrap;
    border-radius  : var(--qb-radius);
    font-size      : var(--qb-font-size-sm);
    font-weight    : 500;
    height         : var(--qb-button-height);
    padding        : 0 var(--qb-spacing-md);
    background     : hsl(var(--qb-primary));
    color          : hsl(var(--qb-primary-foreground));
    border         : none;
    cursor         : pointer;
    box-shadow     : var(--qb-shadow-sm);
}

.apply-discount-button:hover {
    background: hsl(var(--qb-primary) / 0.9);
    box-shadow: var(--qb-shadow-md);
}

/* Order summary section - Card component */
.order-summary {
    background   : hsl(var(--qb-card));
    border       : 1px solid hsl(var(--qb-border));
    border-radius: var(--qb-radius);
    margin       : 0;
    box-shadow   : var(--qb-shadow-md);
}

/* Đảm bảo các phần tử con trong các section không có margin để gap hoạt động đúng */
.order-container .product-info.section-large>* {
    margin-top   : 0;
    margin-bottom: 0;
}

.order-container .buyer-form.section-large>* {
    margin-top   : 0;
    margin-bottom: 0;
}

.order-container .order-summary.section-large>* {
    margin-top   : 0;
    margin-bottom: 0;
}

/* Đảm bảo các section con không có margin */
.quantity-section {
    display        : flex;
    gap            : var(--qb-product-info-gap, 0.5rem);
    align-items    : center;
    justify-content: flex-start;
}

.quantity-section,
.address-section,
.shipping-payment-section {
    margin: 0;
}

.summary-row {
    display        : flex;
    justify-content: space-between;
    align-items    : center;
    border-bottom  : none;
    margin         : 0;
}

.summary-row.total-row {
    padding-top: var(--qb-spacing-md);
    margin-top : var(--qb-spacing-sm);
    border-top : 1px solid hsl(var(--qb-border));
    font-weight: 600;
    font-size  : var(--qb-font-size-base);
}

.summary-label {
    color    : hsl(var(--qb-muted-foreground));
    font-size: var(--qb-font-size-sm);
}

.summary-value {
    color      : hsl(var(--qb-foreground));
    font-weight: 500;
    font-size  : var(--qb-font-size-sm);
}

.total-price {
    color      : hsl(var(--qb-destructive));
    font-size  : var(--qb-font-size-lg);
    font-weight: 600;
}

/* Button component theo Shadcn/UI */
.submit-button {
    display        : inline-flex;
    align-items    : center;
    justify-content: center;
    white-space    : nowrap;
    border-radius  : var(--qb-radius);
    font-size      : var(--qb-font-size-sm);
    font-weight    : 500;
    height         : var(--qb-button-height);
    padding        : 0 var(--qb-spacing-md);
    width          : 100%;
    background     : hsl(var(--qb-destructive));
    color          : hsl(var(--qb-destructive-foreground));
    border         : none;
    cursor         : pointer;
    box-shadow     : var(--qb-shadow-sm);
    text-transform : uppercase;
    letter-spacing : 0.025em;
    font-weight    : 600;
}

.submit-button:hover {
    background: hsl(var(--qb-destructive) / 0.9);
    box-shadow: var(--qb-shadow-md);
}

.submit-button:active {
    box-shadow: var(--qb-shadow-sm);
}

/* Nút Quick Buy trên trang sản phẩm */
#quick-buy-button,
.quick-buy-shortcode-button,
button.quick-buy-button {
    display        : inline-flex !important;
    align-items    : center !important;
    justify-content: center !important;
    white-space    : nowrap !important;
    border-radius  : var(--qb-radius) !important;
    font-size      : var(--qb-font-size-sm) !important;
    font-weight    : 500 !important;
    height         : var(--qb-button-height) !important;
    padding        : 0 var(--qb-spacing-lg) !important;
    background     : hsl(var(--qb-destructive)) !important;
    color          : hsl(var(--qb-destructive-foreground)) !important;
    border         : none !important;
    cursor         : pointer !important;
    margin         : var(--qb-spacing-md) 0 !important;
    box-shadow     : var(--qb-shadow-md) !important;
    text-transform : uppercase !important;
    letter-spacing : 0.025em !important;
    font-weight    : 600 !important;
    transition     : background 0.15s, box-shadow 0.15s, transform 0.15s !important;
    gap            : 0.5rem !important;
    text-decoration: none !important;
    line-height    : 1 !important;
}

/* Icon styling trong nút */
#quick-buy-button .quick-buy-icon,
.quick-buy-shortcode-button .quick-buy-icon {
    display        : inline-flex;
    align-items    : center;
    justify-content: center;
    line-height    : 1;
    font-size      : 1em;
}

#quick-buy-button .quick-buy-icon i,
.quick-buy-shortcode-button .quick-buy-icon i {
    font-size  : inherit;
    line-height: inherit;
}

#quick-buy-button .quick-buy-text,
.quick-buy-shortcode-button .quick-buy-text {
    display: inline-block;
}

#quick-buy-button:hover,
.quick-buy-shortcode-button:hover,
button.quick-buy-button:hover {
    background: hsl(var(--qb-destructive) / 0.9) !important;
    box-shadow: var(--qb-shadow-lg) !important;
    transform : translateY(-2px) scale(1.03) !important;
    opacity   : 1 !important;
}

#quick-buy-button:active,
.quick-buy-shortcode-button:active,
button.quick-buy-button:active {
    transform: scale(0.97) !important;
    opacity  : 1 !important;
}

/* Responsive design */
@media (max-width: 1024px) {
    .popup-content {
        max-width: 900px;
    }

    .order-body {
        flex-direction: column;
    }

    .product-info,
    .buyer-form {
        padding: var(--qb-spacing-lg);
    }
}

@media (max-width: var(--qb-layout-breakpoint-tablet)) {
    .popup-content {
        width     : 98%;
        max-height: 95vh;
        margin    : var(--qb-spacing-md);
    }

    .order-body {
        flex-direction: column;
        gap           : 0;
    }

    .product-info {
        border-right : none;
        border-bottom: 1px solid hsl(var(--qb-border));
        padding      : var(--qb-spacing-lg);
    }

    .buyer-form {
        padding: var(--qb-spacing-lg);
    }

    .product-basic-info {
        flex-direction: column;
        align-items   : center;
        text-align    : center;
    }

    .product-image {
        width : 60px;
        height: 60px;
    }

    .buyer-form .form-row {
        flex-direction: column;
        gap           : 0.75rem;
    }

    .form-discount {
        flex-direction: column;
        gap           : 0.75rem;
    }

    .quantity-group {
        justify-content: center;
    }

    .options-group {
        justify-content: center;
    }
}

@media (max-width: var(--qb-layout-breakpoint-mobile)) {
    .popup-content {
        width        : 100%;
        height       : 100vh;
        border-radius: 0;
        max-height   : none;
    }

    .order-header {
        padding: var(--qb-spacing-md);
    }

    .product-title {
        font-size: var(--qb-font-size-lg);
    }

    .product-price {
        font-size: var(--qb-font-size-base);
    }
}

/* Scrollbar tùy chỉnh */
.product-info::-webkit-scrollbar,
.buyer-form::-webkit-scrollbar {
    width: 6px;
}

.product-info::-webkit-scrollbar-track,
.buyer-form::-webkit-scrollbar-track {
    background   : hsl(var(--qb-muted));
    border-radius: 3px;
}

.product-info::-webkit-scrollbar-thumb,
.buyer-form::-webkit-scrollbar-thumb {
    background   : hsl(var(--qb-muted-foreground) / 0.3);
    border-radius: 3px;
}

.product-info::-webkit-scrollbar-thumb:hover,
.buyer-form::-webkit-scrollbar-thumb:hover {
    background: hsl(var(--qb-muted-foreground) / 0.5);
}

/* Loading state */
.buyer-form.loading {
    pointer-events: none;
    opacity       : 0.7;
}

.buyer-form.loading .submit-button {
    position: relative;
}

.buyer-form.loading .submit-button::after {
    content      : '';
    position     : absolute;
    top          : 50%;
    left         : 50%;
    transform    : translate(-50%, -50%);
    width        : 1rem;
    height       : 1rem;
    border       : 2px solid transparent;
    border-top   : 2px solid currentColor;
    border-radius: 50%;
    animation    : qb-spin 1s linear infinite;
}

@keyframes qb-spin {
    0% {
        transform: translate(-50%, -50%) rotate(0deg);
    }

    100% {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Error states */
.form-error {
    border-color: hsl(var(--qb-destructive)) !important;
    box-shadow  : 0 0 0 2px hsl(var(--qb-destructive) / 0.2) !important;
}

.error-message {
    color     : hsl(var(--qb-destructive));
    font-size : var(--qb-font-size-xs);
    margin-top: var(--qb-spacing-xs);
    display   : block;
}

/* Success states for validation */
.form-success {
    border-color: hsl(var(--qb-success)) !important;
    box-shadow  : 0 0 0 2px hsl(var(--qb-success) / 0.2) !important;
}

.success-message {
    color     : hsl(var(--qb-success));
    font-size : var(--qb-font-size-xs);
    margin-top: var(--qb-spacing-xs);
    display   : block;
}

/* Focus ring improvements */
.option-button:focus-visible,
.quantity-button-increase:focus-visible,
.quantity-button-decrease:focus-visible,
.apply-discount-button:focus-visible,
.submit-button:focus-visible,
#quick-buy-button:focus-visible,
.quick-buy-shortcode-button:focus-visible {
    outline       : 2px solid hsl(var(--qb-ring));
    outline-offset: 2px;
}

/* Disabled states */
.option-button:disabled,
.quantity-button-increase:disabled,
.quantity-button-decrease:disabled,
.apply-discount-button:disabled,
.submit-button:disabled,
#quick-buy-button:disabled,
.quick-buy-shortcode-button:disabled {
    pointer-events: none;
    opacity       : 0.5;
}

/* Admin Customization Classes - để admin có thể override */
/* Các class này có thể được sử dụng trong custom CSS */

/* Utility Classes cho Admin */
.qb-hidden {
    display: none !important;
}

.qb-visible {
    display: block !important;
}

.qb-text-center {
    text-align: center !important;
}

.qb-text-left {
    text-align: left !important;
}

.qb-text-right {
    text-align: right !important;
}

.qb-rounded-none {
    border-radius: 0 !important;
}

.qb-rounded-sm {
    border-radius: 0.125rem !important;
}

.qb-rounded-md {
    border-radius: var(--qb-radius) !important;
}

.qb-rounded-lg {
    border-radius: 0.75rem !important;
}

.qb-shadow-none {
    box-shadow: none !important;
}

.qb-shadow-sm {
    box-shadow: var(--qb-shadow-sm) !important;
}

.qb-shadow-md {
    box-shadow: var(--qb-shadow-md) !important;
}

.qb-shadow-lg {
    box-shadow: var(--qb-shadow-lg) !important;
}


.quick-buy-no-scroll {
    overflow: hidden !important;
    height  : 100vh;
}

.buyer-form.form-section .form-row {
    padding: 0px !important;
}

.form-select>* {
    overflow     : hidden !important;
    text-overflow: ellipsis !important;
    white-space  : nowrap !important;
}

/* ===========================
   Hiệu ứng chuyển động mượt mà cho popup, nút, section
   =========================== */
.order-container,
.popup-content,
.order-header,
.order-body,
.product-info,
.buyer-form {
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Nút và các thành phần có thể tương tác */
.close-button,
.submit-button,
#quick-buy-button,
.quick-buy-shortcode-button,
.option-button,
.quantity-button-increase,
.quantity-button-decrease,
.apply-discount-button {
    transition: background 0.15s, color 0.15s, box-shadow 0.15s, border-color 0.15s, transform 0.15s;
}

/* Hiệu ứng hover/active cho nút */
.submit-button:hover,
#quick-buy-button:hover,
.quick-buy-shortcode-button:hover,
.option-button:hover,
.apply-discount-button:hover {
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.10);
    transform : translateY(-2px) scale(1.03);
}

.submit-button:active,
#quick-buy-button:active,
.quick-buy-shortcode-button:active,
.option-button:active,
.apply-discount-button:active {
    transform: scale(0.97);
}

/* ===========================
   Hiệu ứng cho notification (thông báo)
   =========================== */
.quick-buy-notification {
    opacity   : 0;
    transform : translateX(100%);
    transition: opacity 0.15s, transform 0.15s;
}

.quick-buy-notification.show {
    opacity  : 1;
    transform: translateX(0);
}

/* ===========================
   Hiệu ứng cho input, focus, error
   =========================== */
.buyer-form input:focus,
.buyer-form textarea:focus,
.buyer-form select:focus {
    border-color: hsl(var(--qb-ring));
    box-shadow  : 0 0 0 2px hsl(var(--qb-ring) / 0.25);
    transition  : border-color 0.2s, box-shadow 0.2s;
}

.form-error {
    border-color: hsl(var(--qb-destructive)) !important;
    box-shadow  : 0 0 0 2px hsl(var(--qb-destructive) / 0.25) !important;
    transition  : border-color 0.2s, box-shadow 0.2s;
}

/* ===========================
   Hiệu ứng mở rộng/collapse section
   =========================== */
.collapsible-section {
    max-height    : 0;
    overflow      : hidden;
    transition    : max-height 0.2s cubic-bezier(0.4, 0, 0.2, 1), padding-top 0.2s ease, padding-bottom 0.2s ease, margin 0.15s;
    padding-top   : 0;
    padding-bottom: 0;
    border        : none !important;
    margin-bottom : 0 !important;
}

/* Đảm bảo form-row trong collapsible-section có gap đúng */
.collapsible-section .form-row {
    margin-bottom: var(--qb-buyer-form-gap, 0.5rem);
}

.collapsible-section .form-row:last-child {
    margin-bottom: 0;
}

/* Đảm bảo các phần tử trong collapsible-section không bị dính */
.collapsible-section>* {
    margin-top   : 0;
    margin-bottom: 0;
}

.collapsible-section>*+* {
    margin-top: var(--qb-buyer-form-gap, 0.5rem);
}

/* Đảm bảo label trong buyer-form dùng font-size đúng */
.buyer-form .label {
    font-size: var(--qb-buyer-form-font-size, 1rem);
}

/* Toggle button text font-size */
.toggle-text {
    font-size: var(--qb-buyer-form-font-size, 1rem);
}

.collapsible-section.expanded {
    /* Không set max-height cố định ở đây! */
    /* Padding/margin sẽ được set động bằng JS */
    display: block;
}

/* Toggle icon với transition mượt */
.toggle-icon {
    transition     : transform 0.2s ease;
    display        : inline-flex;
    align-items    : center;
    justify-content: center;
}

.toggle-icon svg {
    transition: transform 0.2s ease;
}

/* ===========================
   Responsive mượt mà
   =========================== */
@media (max-width: 1024px) {
    .popup-content {
        transition: max-width 0.3s;
    }
}

@media (max-width: var(--qb-layout-breakpoint-tablet)) {
    .popup-content {
        transition: width 0.3s, max-height 0.3s;
    }
}

/* ===========================
   Hiệu ứng loading cho nút submit
   =========================== */
.buyer-form.loading .submit-button::after {
    animation : qb-spin 1s linear infinite;
    transition: border-top-color 0.2s;
}

.quick-buy-notification {
    position      : fixed;
    top           : 30px;
    right         : 30px;
    z-index       : 9999;
    background    : #333;
    color         : #fff;
    padding       : 16px 24px;
    border-radius : 6px;
    box-shadow    : 0 2px 8px rgba(0, 0, 0, 0.15);
    opacity       : 0;
    transform     : translateY(-20px);
    transition    : opacity 0.3s, transform 0.3s;
    pointer-events: none;
    font-size     : 16px;
}

.quick-buy-notification.success {
    background: #28a745;
}

.quick-buy-notification.error {
    background: #dc3545;
}

.quick-buy-notification.show {
    opacity       : 1;
    transform     : translateY(0);
    pointer-events: auto;
}