/* Accessory Selection (Checkboxes) */
.accessories-selection {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: var(--spacing-md);
}

.accessory-checkbox-item {
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    background: var(--bg-white);
    box-shadow: var(--shadow-sm);
}

.accessory-checkbox-item:hover {
    border-color: var(--secondary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.accessory-label {
    display: flex;
    align-items: center;
    padding: 6px var(--spacing-sm);
    cursor: pointer;
    margin: 0;
}

.accessory-checkbox,
.installation-checkbox,
.product-option-checkbox {
    width: 20px;
    height: 20px;
    min-width: 20px;
    margin-right: var(--spacing-md);
    cursor: pointer;
}

.accessory-details {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex: 1;
}

.accessory-thumbnail {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 4px;
}

.accessory-info {
    flex: 1;
}

.accessory-info h4 {
    margin: 0 0 var(--spacing-xs) 0;
    color: var(--text-color);
    font-size: 1rem;
}

.accessory-description {
    margin: 0 0 var(--spacing-xs) 0;
    color: #666;
    font-size: 0.9rem;
}

.accessory-price {
    margin: 0;
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.1rem;
}

.accessory-checkbox-item:has(input:checked) {
    border-color: var(--secondary-color);
    background-color: rgba(49, 130, 206, 0.05);
    box-shadow: var(--shadow-md);
}

/* ============================================================
   Cart Group Cards (unified for all group types)
   ============================================================ */

.cart-items-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

/* Outer group card */
.cart-group-card {
    background: var(--bg-white);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.cart-group-card:hover {
    box-shadow: var(--shadow-md);
}

/* Group header */
.cg-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--light-bg);
    border-bottom: 1px solid var(--border-color);
}

.cg-header-standalone {
    border-bottom: none;
}

.cg-collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    padding: 2px 4px;
    line-height: 1;
    font-size: 0.7rem;
    transition: color 0.2s ease;
    flex-shrink: 0;
}

.cg-collapse-btn:hover {
    color: var(--primary-color);
}

.cg-category-badge {
    /* reuse existing .cart-item-category styles */
    flex-shrink: 0;
}

.cg-item-count {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.cg-header-total {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary-color);
    white-space: nowrap;
}

.cg-remove-group {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #fee2e2;
    color: #e74c3c;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.15s ease;
}

.cg-remove-group svg {
    width: 13px;
    height: 13px;
}

.cg-remove-group:hover {
    background: #e74c3c;
    color: white;
    transform: scale(1.1);
}

/* Per-sub-item remove button (slightly smaller than group-level) */
.cg-sub-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fee2e2;
    color: #e74c3c;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.15s ease;
}

.cg-sub-remove svg {
    width: 11px;
    height: 11px;
}

.cg-sub-remove:hover {
    background: #e74c3c;
    color: white;
    transform: scale(1.1);
}

/* Collapsible body */
.cg-body {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--border-color);
    transition: max-height 0.3s ease;
}

.cart-group-card.collapsed .cg-body {
    display: none;
}

/* Main product card (white) */
.cg-main-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-white);
}

.cg-main-img {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.cg-main-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.cg-main-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cg-main-secondary {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-weight: 400;
}

.cg-outdoor-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

.cg-unit-price {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.cg-main-total {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-color);
    white-space: nowrap;
    flex-shrink: 0;
}

/* Compact stepper */
.cg-stepper {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1.5px solid var(--border-color);
    border-radius: 20px;
    overflow: hidden;
    flex-shrink: 0;
}

.cg-stepper-btn {
    background: none;
    border: none;
    cursor: pointer;
    width: 28px;
    height: 28px;
    font-size: 1.1rem;
    line-height: 1;
    color: var(--primary-color);
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cg-stepper-btn:hover {
    background: var(--light-bg);
}

.cg-stepper-val {
    min-width: 24px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
    user-select: none;
}

/* Section divider label */
.cg-section {
    background: #f8f9fa;
    padding: var(--spacing-xs) var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.cg-section-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    padding: var(--spacing-xs) 0 4px 0;
}

/* Sub-item card (accessories, installation, indoor units) */
.cg-sub-card {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) 0;
    background: transparent;
}

.cg-sub-img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
}

.cg-sub-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e6f4f9;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    color: var(--primary-color);
}

.cg-sub-icon-clickable {
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.cg-sub-icon-clickable:hover {
    background: var(--primary-color);
    color: white;
    transform: scale(1.05);
}

.cg-sub-icon svg {
    width: 20px;
    height: 20px;
}

.cg-sub-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.cg-sub-name {
    font-size: 0.85rem;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cg-sub-secondary {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.cg-sub-price {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.cg-qty-badge {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.cg-sub-total {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-color);
    white-space: nowrap;
    flex-shrink: 0;
}



/* Compact Accessory Selection (Product Detail Left Column) */
.accessories-selection.compact {
    margin: var(--spacing-sm) 0;
    gap: var(--spacing-xs);
}

.accessories-title {
    margin: 0 0 var(--spacing-sm) 0;
    font-size: 1.1rem;
    color: var(--text-color);
}

.accessory-checkbox-item.compact {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.accessory-checkbox-item.compact .accessory-label {
    padding: 6px var(--spacing-sm);
}

.accessory-checkbox-item.compact .accessory-checkbox,
.accessory-checkbox-item.compact .installation-checkbox,
.accessory-checkbox-item.compact .product-option-checkbox,
.accessory-checkbox-item.compact .product-option-radio {
    width: 18px;
    height: 18px;
    min-width: 18px;
    margin-right: var(--spacing-sm);
}

.accessory-compact-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    gap: var(--spacing-sm);
}

.accessory-name {
    flex: 1;
    font-size: 0.9rem;
    color: var(--text-color);
}

.accessory-checkbox-item.compact .accessory-price {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary-color);
    white-space: nowrap;
}

/* Add separator line between accessories and description */
.product-detail-left .description-section {
    padding-top: var(--spacing-md);
    border-top: 1px solid #ddd;
}

/* Installation Selection (Product Detail Left Column) */
.installation-selection.compact {
    margin: var(--spacing-sm) 0;
    gap: var(--spacing-xs);
}

/* ============================================================
   RESPONSIVE IMPROVEMENTS FOR CART CARDS
   ============================================================ */

/* Ensure text wraps properly on smaller screens */
@media (max-width: 768px) {
    .cg-main-name,
    .cg-sub-name {
        white-space: normal;
        overflow-wrap: break-word;
        word-wrap: break-word;
    }

    .cart-items-list {
        gap: var(--spacing-sm);
    }

    .cart-group-card {
        border-radius: var(--radius-md);
    }

    .cg-main-info,
    .cg-sub-info {
        overflow: hidden;
    }
}

/* ============================================================
   ADD SERVICES MODAL
   ============================================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    animation: fadeIn 0.2s forwards;
    padding: var(--spacing-md);
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

.service-modal {
    background: white;
    border-radius: var(--radius-lg);
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    opacity: 0;
    transform: scale(0.95);
    animation: slideUp 0.3s 0.1s forwards;
}

@keyframes slideUp {
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.service-modal-header {
    padding: 1rem var(--spacing-md);
    border-bottom: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.service-modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--text-primary);
}

.service-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: var(--spacing-xs);
    line-height: 1;
    transition: color 0.2s;
}

.service-modal-close:hover {
    color: var(--primary-color);
}

.service-modal-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    background: var(--bg-gray);
}

.service-tab {
    flex: 1;
    padding: var(--spacing-sm);
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.service-tab:hover {
    background: var(--bg-white);
    color: var(--text-primary);
}

.service-tab.active {
    background: var(--bg-white);
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.service-modal-body {
    padding: var(--spacing-md);
    overflow-y: auto;
    flex: 1;
}

.service-tab-content {
    display: none;
}

.service-tab-content.active {
    display: block;
}

/* Predefined Services List */
.predefined-services-list {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.service-item {
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
}

.service-item:hover {
    border-color: var(--secondary-color);
    box-shadow: var(--shadow-sm);
}

.service-item-checkbox {
    width: 20px;
    height: 20px;
    min-width: 20px;
    cursor: pointer;
}

.service-item-info {
    flex: 1;
}

.service-item-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.service-item-price {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.service-item-quantity {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.service-item-quantity label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.service-item-quantity input {
    width: 70px;
    padding: 6px var(--spacing-sm);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    text-align: center;
}

/* Custom Services List (top section showing added services) */
.custom-services-list {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    margin-bottom: var(--spacing-lg);
}

.custom-service-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--bg-gray);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color 0.2s;
}

.custom-service-item:hover {
    border-color: var(--secondary-color);
}

.custom-service-info {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--spacing-md);
}

.custom-service-name {
    color: var(--text-primary);
    font-weight: 500;
}

.custom-service-price {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.custom-service-remove {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px var(--spacing-xs);
    font-size: 1.5rem;
    line-height: 1;
    transition: color 0.2s;
    min-width: 30px;
}

.custom-service-remove:hover {
    color: #D32F2F;
}

/* Custom Service Form */
.custom-service-form {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
}

.custom-form-inline {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
    flex: 1;
}

.form-group-narrow {
    flex: 0 0 70px;
}

.form-group label {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.form-group input {
    padding: var(--spacing-sm);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.add-custom-btn {
    padding: 0.5rem var(--spacing-md);
    background: var(--secondary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
    white-space: nowrap;
    margin-top: 1.4rem;
}

.add-custom-btn:hover {
    background: #2D5A8C;
}

.add-custom-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

/* Empty selection message */
.empty-selection {
    text-align: center;
    color: var(--text-muted);
    padding: var(--spacing-lg);
    font-style: italic;
}

/* Modal Footer */
.service-modal-footer {
    padding: 0.75rem var(--spacing-md);
    border-top: 2px solid var(--border-color);
    display: flex;
    gap: var(--spacing-md);
    justify-content: flex-end;
}

.service-modal-footer button {
    padding: 0.5rem var(--spacing-lg);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 500;
    font-size: 1rem;
    transition: all 0.2s;
}

.cancel-btn {
    background: var(--bg-gray);
    color: var(--text-primary);
}

.cancel-btn:hover {
    background: var(--border-color);
}

.add-services-btn {
    background: var(--primary-color);
    color: white;
}

.add-services-btn:hover {
    background: #1E3A5F;
}

.add-services-btn:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

/* Additional Services Display in Cart */
.installation-additional-services {
    margin-top: var(--spacing-sm);
    padding-left: var(--spacing-lg);
    border-left: 3px solid var(--border-color);
}

.additional-services-toggle {
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--spacing-xs) 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
    transition: color 0.2s;
}

.additional-services-toggle:hover {
    color: var(--primary-color);
}

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

.toggle-icon.expanded {
    transform: rotate(90deg);
}

.additional-services-items {
    display: none;
    flex-direction: column;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-xs);
    padding-left: var(--spacing-md);
}

.additional-services-items.expanded {
    display: flex;
}

.additional-service-row {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-xs) 0;
}

.additional-service-name {
    color: var(--text-primary);
    flex: 1;
    font-size: 0.85rem;
}

.additional-service-price {
    color: var(--text-color);
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 70px;
    text-align: right;
}

.remove-service-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fee2e2;
    color: #e74c3c;
    border: none;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    transition: background 0.2s ease, transform 0.15s ease;
}

.remove-service-btn:hover {
    background: #e74c3c;
    color: white;
    transform: scale(1.1);
}

.remove-service-btn svg {
    width: 14px;
    height: 14px;
}

/* Responsive */
@media (max-width: 640px) {
    .service-modal {
        max-height: 95vh;
    }

    .service-modal-header,
    .service-modal-body,
    .service-modal-footer {
        padding: var(--spacing-md);
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .service-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .service-item-quantity {
        width: 100%;
        justify-content: space-between;
    }

    .custom-form-inline {
        flex-direction: column;
        align-items: stretch;
    }

    .form-group-narrow {
        flex: 1;
    }

    .add-custom-btn {
        align-self: stretch;
    }
}
