/* ===== КОРЗИНА ===== */

/* Header */
.cart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.cart-header h1 {
    margin: 0;
    color: var(--text-primary);
}

/* Список товаров */
.cart-items {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-bottom: 30px;
}

/* ===== Карточка товара ===== */
.cart-item {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: grid;
    grid-template-columns: auto 1px 1fr;
    gap: 20px;
    align-items: center;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

/* Левый блок: превью + статус */
.cart-item-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 100px;
}

.cart-item-preview-wrapper {
    position: relative;
    display: inline-block;
}

.cart-item-preview {
    position: relative;
    width: 90px;
    height: 90px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.cart-item-preview img,
.cart-item-preview .lazy-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cart-item-preview img.loaded,
.cart-item-preview .lazy-preview-img.loaded {
    opacity: 1;
}

.cart-item-preview .no-preview,
.cart-item-preview .no-preview-placeholder {
    color: var(--text-secondary);
    font-size: 36px;
    opacity: 0.4;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Индикатор статуса поверх превью */
.layout-status-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    border: 2px solid var(--bg-card);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    z-index: 10;
}

.layout-status-badge.ready {
    background: var(--success);
    color: white;
}

.layout-status-badge.pending {
    background: var(--error);
    color: white;
}

/* Подпись под превью */
.layout-status-label {
    font-size: 11px;
    text-align: center;
    line-height: 1.2;
    font-weight: 500;
    margin-top: 4px;
}

.layout-status-label.ready {
    color: var(--success);
}

.layout-status-label.pending {
    color: var(--error);
}

/* Spinner загрузки превью */
.cart-item-preview .preview-loader {
    position: absolute;
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Разделитель между блоками */
.cart-item-divider {
    width: 1px;
    height: 80px;
    background: var(--border-color);
    align-self: center;
}

/* Правый блок: информация + цена + кнопки */
.cart-item-right {
    display: flex;
    flex-direction: column;
    gap: 15px;
    min-width: 0;
}

.cart-item-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cart-item-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.cart-item-details {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.cart-item-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.cart-item-price {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.cart-item-actions {
    display: flex;
    gap: 10px;
}

.cart-item-actions .btn {
    padding: 8px 16px;
    font-size: 13px;
}

/* ===== Cart Summary ===== */
.cart-summary {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow-lg);
    border: 2px solid var(--primary);
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    font-size: 16px;
}

.summary-label {
    color: var(--text-secondary);
}

.summary-value {
    color: var(--text-primary);
    font-weight: 600;
}

.summary-total {
    font-size: 28px;
    color: var(--primary);
}

.cart-summary .btn-large {
    width: 100%;
    margin-top: 20px;
    padding: 16px;
    font-size: 18px;
}

/* Подсказка для кнопки оформления */
.checkout-tooltip {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: rgba(244, 67, 54, 0.1);
    border: 2px solid var(--error);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin-top: 15px;
    font-size: 13px;
    color: var(--text-primary);
}

.tooltip-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.tooltip-text {
    line-height: 1.4;
}

/* Кнопка disabled */
.btn-disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ===== Checkout Modal ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
}

.modal-content.modal-checkout {
    position: relative;
    max-width: 700px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 30px;
    box-shadow: var(--shadow-lg);
    z-index: 2001;
}

.modal-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-primary);
    font-size: 28px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: var(--transition);
    z-index: 10;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    color: var(--primary);
}

/* Шаги оформления */
.checkout-steps {
    display: flex;
    justify-content: space-between;
    margin-bottom: 40px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 1;
    opacity: 0.5;
    transition: var(--transition);
}

.step.active {
    opacity: 1;
}

.step.completed {
    opacity: 0.7;
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-input);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
}

.step.active .step-number {
    background: var(--primary);
    color: white;
}

.step.completed .step-number {
    background: var(--success);
    color: white;
}

.step-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

.checkout-step-content h4 {
    margin-bottom: 20px;
    color: var(--text-primary);
}

/* Выбор типа клиента */
.client-type-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    align-items: stretch;
}

.client-type-card {
    cursor: pointer;
}

.client-type-card input[type="radio"] {
    display: none;
}

.client-type-content {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: var(--transition);
    min-height: 115px;
}

.client-type-card input[type="radio"]:checked + .client-type-content {
    border-color: var(--primary);
    background: rgba(156, 39, 176, 0.1);
}

.client-type-icon {
    font-size: 32px;
}

.client-type-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.client-type-desc {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Способы доставки и оплаты */
.delivery-options,
.payment-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.option-card {
    cursor: pointer;
}

.option-card input[type="radio"] {
    display: none;
}

.option-card-content {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 15px;
    text-align: center;
    transition: var(--transition);
}

.option-card input[type="radio"]:checked + .option-card-content {
    border-color: var(--primary);
    background: rgba(156, 39, 176, 0.1);
}

.option-card-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.option-card-price {
    font-size: 14px;
    color: var(--primary);
    font-weight: 700;
}

/* Итоговое подтверждение */
.order-summary {
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 20px;
}

.summary-section {
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.summary-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.summary-section h5 {
    margin: 0 0 8px 0;
    font-size: 13px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.summary-section p {
    margin: 0;
    font-size: 16px;
    color: var(--text-primary);
    font-weight: 500;
}

.confirm-total {
    font-size: 28px !important;
    color: var(--primary) !important;
    font-weight: 700 !important;
}

.checkout-actions {
    display: flex;
    gap: 15px;
    margin-top: 20px;
}

.checkout-actions .btn {
    flex: 1;
}

.checkout-navigation {
    display: flex;
    justify-content: space-between;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.checkout-navigation .btn {
    flex: 1;
}

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    color: white;
    font-size: 18px;
    gap: 20px;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ===== Notifications ===== */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: var(--radius-md);
    color: white;
    font-size: 14px;
    z-index: 10001;
    animation: slideIn 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.notification-success {
    background: var(--success);
}

.notification-error {
    background: var(--error);
}

@keyframes slideIn {
    from { transform: translateX(400px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(400px); opacity: 0; }
}

/* ===== Адаптивность ===== */
@media (max-width: 768px) {
    .cart-item {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .cart-item-divider {
        width: 100%;
        height: 1px;
    }
    
    .cart-item-left {
        flex-direction: row;
        justify-content: flex-start;
        gap: 12px;
        min-width: auto;
    }
    
    .cart-item-preview {
        width: 70px;
        height: 70px;
    }
    
    .layout-status-badge {
        top: -6px;
        right: -6px;
        width: 22px;
        height: 22px;
        font-size: 12px;
    }
    
    .cart-item-bottom {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .cart-item-actions {
        width: 100%;
    }
    
    .cart-item-actions .btn {
        flex: 1;
    }
    
    .client-type-options {
        grid-template-columns: 1fr;
    }
    
    .checkout-steps {
        flex-wrap: wrap;
        gap: 10px;
    }
    
    .step {
        flex: 0 0 calc(50% - 10px);
    }
}

/* Стилизация select компании */
.company-select-wrapper {
    margin-top: 20px;
}

.company-select-wrapper label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

#checkout-company {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

#checkout-company:focus {
    outline: none;
    border-color: var(--primary);
}

#checkout-company:hover {
    border-color: var(--primary);
}

#checkout-company option {
    background: var(--bg-card);
    color: var(--text-primary);
    padding: 10px;
}

/* Компактные кнопки доставки */
.delivery-method-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.delivery-method-options .option-card-content {
    padding: 12px 15px;
}

.delivery-method-options .option-card-title {
    font-size: 14px;
    margin-bottom: 3px;
}

.delivery-method-options .option-card-price {
    font-size: 12px;
}

/* Фиксированная textarea адреса */
#delivery-address {
    resize: none;
    height: 80px;
    padding: 12px;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

#delivery-address:focus {
    outline: none;
    border-color: var(--primary);
}

#delivery-address:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Кнопки оплаты в один ряд */
.payment-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.payment-options .option-card-content {
    padding: 12px 10px;
}

.payment-options .option-card-title {
    font-size: 13px;
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .delivery-method-options,
    .payment-options {
        grid-template-columns: 1fr;
    }
}

.payment-options .option-card-content {
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Кнопки оплаты в один ряд с одинаковой высотой */
.payment-options {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.payment-options .option-card-content {
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 10px;
}

.payment-options .option-card-title {
    font-size: 13px;
    margin-bottom: 0;
    text-align: center;
    line-height: 1.3;
}

@media (max-width: 768px) {
    .payment-options {
        grid-template-columns: 1fr;
    }
    
    .payment-options .option-card-content {
        min-height: 50px;
    }
}