/**
 * Checkout Page Stylesheet
 * Bakr & Khattab E-Commerce
 * 
 * @author Rizki Maulana
 * @year 2026
 */

/* ============================================================
   Checkout Main Layout
   ============================================================ */
.checkout-main {
    background-color: #F5F5F3;
    min-height: calc(100vh - var(--announcement-height) - var(--header-height));
    padding-top: calc(var(--announcement-height) + var(--header-height) + 40px);
    padding-bottom: 60px;
}

.checkout-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 40px;
}

/* ============================================================
   Checkout Header
   ============================================================ */

.checkout-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 40px;
    position: relative;
}

.back-link {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    color: #143552;
    font-size: 14px;
    font-weight: 400;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.back-link:hover {
    opacity: 0.7;
}

.checkout-title {
    font-family: 'Neue Montreal', sans-serif;
    font-size: 32px;
    font-weight: 500;
    letter-spacing: 0.15em;
    color: #143552;
    margin: 0;
}

.checkout-title-ar {
    font-family: 'Amiri', serif;
    font-size: 18px;
    color: #9A9A9A;
    margin-top: 4px;
}

/* ============================================================
   Checkout Content Layout
   ============================================================ */
.checkout-content {
    display: grid;
    grid-template-columns: 1fr 420px;
    gap: 40px;
    align-items: start;
}

/* ============================================================
   Form Section
   ============================================================ */
.checkout-form-section {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.checkout-section {
    background-color: #FFFFFF;
    padding: 32px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: 'Neue Montreal', sans-serif;
    font-size: 18px;
    font-weight: 500;
    color: #143552;
    margin: 0 0 24px 0;
}

.section-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background-color: #143552;
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 500;
    border-radius: 50%;
}

.section-title .optional {
    font-size: 13px;
    font-weight: 400;
    color: #9A9A9A;
    margin-left: auto;
}

/* ============================================================
   Form Elements
   ============================================================ */
.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #143552;
    margin-bottom: 8px;
    letter-spacing: 0.02em;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 14px 16px;
    font-family: 'Neue Montreal', sans-serif;
    font-size: 14px;
    color: #1A1A1A;
    background-color: #F9F9F9;
    border: 1px solid #E5E5E5;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #143552;
    background-color: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(20, 53, 82, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: #9A9A9A;
}

.form-group select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239A9A9A' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 48px;
}

.form-group select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-row .form-group {
    margin-bottom: 0;
}

/* ============================================================
   Shipping Methods
   ============================================================ */
.shipping-methods {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.shipping-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background-color: #F9F9F9;
    border: 1px dashed #E5E5E5;
    border-radius: 6px;
    text-align: center;
    color: #9A9A9A;
}

.shipping-placeholder svg {
    margin-bottom: 12px;
    opacity: 0.5;
}

.shipping-placeholder p {
    font-size: 14px;
    margin: 0;
}

.shipping-option {
    display: flex;
    align-items: center;
    padding: 16px;
    background-color: #F9F9F9;
    border: 1px solid #E5E5E5;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.shipping-option:hover {
    border-color: #143552;
    background-color: #FFFFFF;
}

.shipping-option.selected {
    border-color: #143552;
    background-color: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(20, 53, 82, 0.1);
}

.shipping-option input {
    display: none;
}

.shipping-radio {
    width: 20px;
    height: 20px;
    border: 2px solid #E5E5E5;
    border-radius: 50%;
    margin-right: 14px;
    flex-shrink: 0;
    position: relative;
    transition: all 0.2s ease;
}

.shipping-option.selected .shipping-radio,
.shipping-option input:checked + .shipping-radio {
    border-color: #143552;
}

.shipping-option.selected .shipping-radio::after,
.shipping-option input:checked + .shipping-radio::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background-color: #143552;
    border-radius: 50%;
}

.shipping-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.shipping-courier {
    display: flex;
    align-items: center;
    gap: 8px;
}

.shipping-courier-name {
    font-size: 14px;
    font-weight: 500;
    color: #143552;
    text-transform: uppercase;
}

.shipping-service {
    font-size: 13px;
    color: #5A5A5A;
}

.shipping-etd {
    font-size: 12px;
    color: #9A9A9A;
}

.shipping-price {
    font-size: 15px;
    font-weight: 600;
    color: #143552;
    margin-left: auto;
    white-space: nowrap;
}

.shipping-free {
    color: #59663D;
}

/* Loading state */
.shipping-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    background-color: #F9F9F9;
    border: 1px solid #E5E5E5;
    border-radius: 6px;
}

.shipping-loading::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 2px solid #E5E5E5;
    border-top-color: #143552;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   Payment Methods
   ============================================================ */
.payment-methods {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.payment-option {
    display: flex;
    align-items: center;
    padding: 16px;
    background-color: #F9F9F9;
    border: 1px solid #E5E5E5;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.payment-option:hover {
    border-color: #143552;
    background-color: #FFFFFF;
}

.payment-option:has(input:checked) {
    border-color: #143552;
    background-color: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(20, 53, 82, 0.1);
}

.payment-option input {
    display: none;
}

.payment-radio {
    width: 20px;
    height: 20px;
    border: 2px solid #E5E5E5;
    border-radius: 50%;
    margin-right: 14px;
    flex-shrink: 0;
    position: relative;
    transition: all 0.2s ease;
}

.payment-option:has(input:checked) .payment-radio {
    border-color: #143552;
}

.payment-option:has(input:checked) .payment-radio::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    background-color: #143552;
    border-radius: 50%;
}

.payment-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.payment-name {
    font-size: 14px;
    font-weight: 500;
    color: #143552;
}

.payment-desc {
    font-size: 12px;
    color: #9A9A9A;
}

/* ============================================================
   Order Summary Card
   ============================================================ */
.checkout-summary-section {
    position: sticky;
    top: calc(var(--header-height) + 20px);
}

.order-summary-card {
    background-color: #FFFFFF;
    padding: 32px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.summary-title {
    font-family: 'Neue Montreal', sans-serif;
    font-size: 18px;
    font-weight: 500;
    color: #143552;
    margin: 0 0 24px 0;
    padding-bottom: 16px;
    border-bottom: 1px solid #E5E5E5;
}

/* Summary Items */
.summary-items {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 24px;
    max-height: 300px;
    overflow-y: auto;
}

.summary-item {
    display: flex;
    gap: 14px;
}

.summary-item-image {
    width: 60px;
    height: 75px;
    background-color: #F5F5F3;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.summary-item-image img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

.summary-item-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.summary-item-name {
    font-size: 14px;
    font-weight: 500;
    color: #143552;
    margin-bottom: 4px;
}

.summary-item-qty {
    font-size: 12px;
    color: #9A9A9A;
}

.summary-item-price {
    font-size: 14px;
    font-weight: 500;
    color: #143552;
    margin-left: auto;
    align-self: center;
}

/* Summary Totals */
.summary-totals {
    padding-top: 20px;
    border-top: 1px solid #E5E5E5;
}

.summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 14px;
    color: #5A5A5A;
}

.summary-row.summary-total {
    padding-top: 16px;
    margin-top: 8px;
    border-top: 1px solid #E5E5E5;
    font-size: 18px;
    font-weight: 600;
    color: #143552;
}

/* Free Shipping Note */
.free-shipping-note {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background-color: rgba(89, 102, 61, 0.1);
    border-radius: 6px;
    margin-top: 16px;
    color: #59663D;
    font-size: 13px;
}

/* Place Order Button */
.btn-place-order {
    width: 100%;
    padding: 18px 24px;
    margin-top: 24px;
    font-family: 'Neue Montreal', sans-serif;
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.12em;
    color: #FFFFFF;
    background-color: #143552;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.btn-place-order:hover {
    background-color: #541622;
}

.btn-place-order:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Security Note */
.security-note {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    color: #9A9A9A;
    font-size: 12px;
}

/* ============================================================
   Empty Cart State
   ============================================================ */
.checkout-empty {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 40px;
    background-color: #FFFFFF;
    border-radius: 8px;
    text-align: center;
}

.checkout-empty-icon {
    color: #9A9A9A;
    margin-bottom: 20px;
    opacity: 0.5;
}

.checkout-empty-title {
    font-size: 20px;
    font-weight: 500;
    color: #143552;
    margin-bottom: 8px;
}

.checkout-empty-text {
    font-size: 14px;
    color: #9A9A9A;
    margin-bottom: 24px;
}

.checkout-empty-btn {
    display: inline-flex;
    padding: 14px 32px;
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.12em;
    color: #FFFFFF;
    background-color: #143552;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.checkout-empty-btn:hover {
    background-color: #541622;
    opacity: 1;
}

/* Spinner */
.spinner,
.spinner-small {
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.spinner {
    width: 20px;
    height: 20px;
}

.spinner-small {
    width: 14px;
    height: 14px;
    border-width: 2px;
    border-top-color: white;
    border-color: rgba(255,255,255,0.3);
    border-top-color: white;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================================
   Confirmation Modal
============================================================ */
.confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.confirm-modal.active {
    display: flex;
}

.confirm-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.confirm-modal-content {
    position: relative;
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.confirm-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--primary);
    color: white;
}

.confirm-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.confirm-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
}

.confirm-modal-close:hover {
    opacity: 1;
}

.confirm-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.confirm-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.confirm-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.confirm-section h4 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin: 0 0 8px 0;
}

.confirm-section p {
    margin: 0 0 4px 0;
    font-size: 13px;
    color: var(--text);
}

.confirm-totals {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.confirm-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
}

.confirm-row.total {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    padding-top: 8px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
}

.confirm-modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: #F9F9F9;
}

.confirm-modal-footer .btn-cancel {
    flex: 1;
    padding: 12px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
}

.confirm-modal-footer .btn-cancel:hover {
    background: #F5F5F5;
}

.confirm-modal-footer .btn-confirm {
    flex: 2;
    padding: 12px;
    background: var(--primary);
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.confirm-modal-footer .btn-confirm:hover:not(:disabled) {
    background: var(--accent);
}

.confirm-modal-footer .btn-confirm:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.confirm-modal-footer .btn-confirm .btn-loading {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Footer */
.checkout-footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 12px;
}


/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
    .checkout-content {
        grid-template-columns: 1fr;
    }
    
    .checkout-summary-section {
        position: static;
        order: -1;
    }
}

@media (max-width: 768px) {
    .checkout-container {
        padding: 0 20px;
    }
    
    .checkout-header {
        margin-bottom: 24px;
    }
    
    .back-link {
        position: static;
        transform: none;
        margin-bottom: 16px;
    }
    
    .checkout-title {
        font-size: 24px;
    }
    
    .checkout-section {
        padding: 24px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .order-summary-card {
        padding: 24px;
    }
}