/* Кошик (core/templates/core/cart.html).
   Переписано на токени теми. Імена класів збережені — на них зав'язаний
   script_cart.js (.cart-item, .item-select-checkbox, .quantity-btn.minus/.plus,
   .quantity-input, .delete-btn, .item-details-toggle, .price-total,
   .price-per-unit, класи open/collapsed/success/error, id cartItems,
   cartSubtotal, cartTotal, createOrderBtn, confirmModal тощо). */

.cart-page-container {
    padding: 8px 0 24px;
}

/* --------------------------------------------------------- заголовок --- */

.cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 22px;
}
.cart-header h1 {
    font-family: var(--sp-font-head);
    font-size: var(--sp-fs-3xl);
    color: var(--sp-heading);
    margin: 0 0 6px;
}
.cart-header p {
    margin: 0;
    color: var(--sp-body);
    font-size: var(--sp-fs-sm);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 48px;
    padding: 0 24px;
    border: 1px solid var(--sp-line);
    border-radius: var(--sp-radius);
    background-color: #fff;
    color: var(--sp-heading);
    font-family: var(--sp-font);
    font-size: var(--sp-fs-sm);
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background var(--sp-transition), border-color var(--sp-transition), color var(--sp-transition);
}
.btn:hover {
    background: var(--sp-bg-mute);
    border-color: var(--sp-primary);
}
.btn-primary {
    background: var(--sp-primary);
    border-color: var(--sp-primary);
    color: #fff;
}
.btn-primary:hover:not(:disabled) {
    background: var(--sp-primary-hover);
    border-color: var(--sp-primary-hover);
    color: #fff;
}
.btn-primary:disabled {
    opacity: .45;
    cursor: not-allowed;
}

/* ------------------------------------------------------------ розкладка -- */

.cart-main {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 20px;
    align-items: start;
}

.cart-items-section {
    background-color: #fff;
    border-radius: var(--sp-radius);
    box-shadow: var(--sp-shadow-sm);
    overflow: hidden;
}
.cart-items-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 24px;
    background-image: var(--sp-cutline);
    background-repeat: repeat-x;
    background-position: left bottom;
    background-size: 31px 1px;
    background-color: var(--sp-bg-soft);
}
.cart-items-header h2 {
    font-family: var(--sp-font-head);
    font-size: var(--sp-fs-lg);
    color: var(--sp-heading);
    margin: 0;
}
.clear-cart-btn {
    border: none;
    background: transparent;
    color: var(--sp-body);
    font-family: var(--sp-font);
    font-size: var(--sp-fs-xs);
    font-weight: 600;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--sp-radius-sm);
    transition: background var(--sp-transition), color var(--sp-transition);
}
.clear-cart-btn:hover {
    background: var(--sp-danger-bg);
    color: var(--sp-danger);
}

/* ------------------------------------------------------------- позиція --- */

.cart-item {
    padding: 18px 24px;
    border-bottom: 1px solid var(--sp-line-soft);
}
.cart-item:last-child {
    border-bottom: none;
}
.item-main-info {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
}
.item-description {
    flex: 1 1 260px;
    min-width: 0;
}
.item-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}
.item-select-checkbox {
    width: 18px;
    height: 18px;
    accent-color: var(--sp-primary);
    cursor: pointer;
    flex: 0 0 auto;
}
.item-title-row h3,
.item-title-row strong {
    font-family: var(--sp-font-head);
    font-size: var(--sp-fs-body);
    color: var(--sp-heading);
    margin: 0;
}
.item-description p {
    margin: 0;
    color: var(--sp-muted);
    font-size: var(--sp-fs-xs);
}

.item-controls {
    display: flex;
    align-items: center;
    gap: 18px;
    flex: 0 0 auto;
}

/* кількість */
.quantity-control {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--sp-line);
    border-radius: var(--sp-radius);
    overflow: hidden;
    background-color: #fff;
}
.quantity-btn {
    width: 38px;
    height: 42px;
    border: none;
    background-color: #fff;
    color: var(--sp-heading);
    font-size: var(--sp-fs-lg);
    line-height: 1;
    cursor: pointer;
    transition: background var(--sp-transition);
}
.quantity-btn:hover {
    background: var(--sp-bg-mute);
}
.quantity-input {
    width: 54px;
    height: 42px;
    border: none;
    border-left: 1px solid var(--sp-line-soft);
    border-right: 1px solid var(--sp-line-soft);
    text-align: center;
    font-family: var(--sp-font);
    font-size: var(--sp-fs-sm);
    font-weight: 600;
    color: var(--sp-heading);
    background-color: #fff;
}
.quantity-input:focus {
    outline: none;
    background: var(--sp-bg-soft);
}

/* ціна */
.item-price {
    min-width: 120px;
    text-align: right;
}
.price-total {
    font-family: var(--sp-font-head);
    font-size: var(--sp-fs-lg);
    font-weight: 700;
    color: var(--sp-heading);
    font-variant-numeric: tabular-nums;
}
.price-per-unit {
    color: var(--sp-muted);
    font-size: var(--sp-fs-xs);
    margin-top: 2px;
}

.delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1px solid var(--sp-line);
    border-radius: var(--sp-radius-sm);
    background-color: #fff;
    color: var(--sp-body);
    cursor: pointer;
    transition: border-color var(--sp-transition), background var(--sp-transition), color var(--sp-transition);
}
.delete-btn:hover {
    border-color: var(--sp-danger);
    background: var(--sp-danger-bg);
    color: var(--sp-danger);
}

/* деталі позиції */
.item-details-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 6px 10px 6px 0;
    border: none;
    background: transparent;
    color: var(--sp-body);
    font-family: var(--sp-font);
    font-size: var(--sp-fs-xs);
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--sp-radius-sm);
}
.item-details-toggle:hover {
    color: var(--sp-accent);
}
.item-details-toggle .arrow {
    display: inline-block;
    transition: transform var(--sp-transition);
}
.item-details-toggle.open .arrow {
    transform: rotate(90deg);
}
.item-details-toggle.collapsed .arrow {
    transform: none;
}
.item-details-content {
    display: none;
    margin-top: 10px;
    padding: 14px 16px;
    border-radius: var(--sp-radius-sm);
    background: var(--sp-bg-soft);
    border: 1px solid var(--sp-line-soft);
}
.item-details-content.open {
    display: block;
}
.detail-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 6px 0;
    font-size: var(--sp-fs-xs);
    color: var(--sp-heading);
    border-bottom: 1px dashed var(--sp-line-soft);
}
.detail-row:last-child {
    border-bottom: none;
}
.process-icon {
    width: 16px;
    height: 16px;
    opacity: .85;
}

/* ------------------------------------------------------------- підсумок -- */

.order-summary-section {
    position: sticky;
    top: calc(var(--sp-header-h) + 16px);
}
.order-summary-card {
    background-color: #fff;
    border-radius: var(--sp-radius);
    box-shadow: var(--sp-shadow-sm);
    padding: 24px;
}
.order-summary-card h2 {
    font-family: var(--sp-font-head);
    font-size: var(--sp-fs-lg);
    color: var(--sp-heading);
    margin: 0 0 18px;
}
.summary-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 0;
    font-size: var(--sp-fs-sm);
    color: var(--sp-body);
}
.summary-row.total {
    margin-top: 8px;
    padding-top: 16px;
    background-image: var(--sp-cutline);
    background-repeat: repeat-x;
    background-position: left top;
    background-size: 31px 1px;
    color: var(--sp-heading);
}
.summary-row.total span:last-child,
.summary-row.total strong {
    font-family: var(--sp-font-head);
    font-size: var(--sp-fs-xl);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.order-summary-card .btn-primary {
    width: 100%;
    margin-top: 18px;
}


.cart-message {
    margin-top: 12px;
    font-size: var(--sp-fs-xs);
    line-height: 1.5;
    color: var(--sp-body);
}
.cart-message.error {
    color: var(--sp-danger);
}
.cart-message.success {
    color: #24713C;
}

/* --------------------------------------------------------- порожній стан - */

.cart-empty,
.cart-items-section > p {
    padding: 46px 24px;
    text-align: center;
    color: var(--sp-muted);
    font-size: var(--sp-fs-sm);
}

/* -------------------------------------------------------------- модалка -- */

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(20, 25, 30, .55);
    backdrop-filter: blur(2px);
}
.modal-overlay[hidden] {
    display: none;
}
.modal-window {
    width: 100%;
    max-width: 440px;
    background-color: #fff;
    border-radius: var(--sp-radius);
    box-shadow: var(--sp-shadow-lg);
    padding: 28px;
}
.modal-header {
    font-family: var(--sp-font-head);
    font-size: var(--sp-fs-lg);
    color: var(--sp-heading);
    margin-bottom: 10px;
}
.modal-body {
    color: var(--sp-body);
    font-size: var(--sp-fs-sm);
    line-height: 1.6;
    margin-bottom: 22px;
}
.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    flex-wrap: wrap;
}
.modal-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 20px;
    border: 1px solid var(--sp-line);
    border-radius: var(--sp-radius);
    background-color: #fff;
    color: var(--sp-heading);
    font-family: var(--sp-font);
    font-size: var(--sp-fs-sm);
    font-weight: 600;
    cursor: pointer;
    transition: background var(--sp-transition), border-color var(--sp-transition);
}
.modal-btn:hover {
    background: var(--sp-bg-mute);
    border-color: var(--sp-primary);
}
.modal-btn.danger {
    background: var(--sp-danger);
    border-color: var(--sp-danger);
    color: #fff;
}
.modal-btn.danger:hover {
    background: #C93B3F;
    border-color: #C93B3F;
}

/* -------------------------------------------------------------- адаптив -- */

@media (max-width: 1099px) {
    .cart-main {
        grid-template-columns: 1fr;
    }
    .order-summary-section {
        position: static;
    }
}

@media (max-width: 767px) {
    .cart-header h1 { font-size: var(--sp-fs-2xl); }
    .cart-item { padding: 16px 18px; }
    .cart-items-header { padding: 14px 18px; }
    .item-main-info { gap: 14px; }
    .item-controls {
        width: 100%;
        justify-content: space-between;
        gap: 12px;
    }
    .item-price { min-width: 0; }
    .order-summary-card { padding: 20px; }
    .modal-window { padding: 22px 18px; }
    .modal-actions { flex-direction: column-reverse; }
    .modal-actions .modal-btn { width: 100%; }
}

/* попередження про непідтверджений телефон */
.order-phone-warning {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 10px;
    align-items: start;
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: var(--sp-radius-sm);
    border-left: 3px solid var(--sp-warning);
    background-color: var(--sp-warning-bg);
    color: #8A6100;
    font-size: var(--sp-fs-xs);
    line-height: 1.55;
}
.order-phone-warning > span:not(.order-phone-warning-icon) {
    grid-column: 2;
}
.order-phone-warning a {
    grid-column: 2;
    justify-self: start;
    color: #8A6100;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.order-phone-warning a:hover {
    color: #5E4200;
}
.order-phone-warning-icon {
    grid-row: 1 / span 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    color: var(--sp-warning);
    font-size: 0;            /* ховаємо текстовий «!», лишаємо іконку */
}
.order-phone-warning-icon .sp-icon {
    font-size: 0;
}
