/* ==========================================================
   Cart — Address management & form modals
   Tham khảo edu-account-modal (education-admin.css)
   ========================================================== */

.address-management-popup,
.address-form-popup {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.address-management-popup.active,
.address-form-popup.active {
    opacity: 1;
    visibility: visible;
}

.address-management-content,
.address-form-content {
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.18);
    display: flex;
    flex-direction: column;
    transform: translateY(12px) scale(0.98);
    transition: transform 0.25s ease;
}

.address-form-content {
    max-width: 520px;
}

.address-management-popup.active .address-management-content,
.address-form-popup.active .address-form-content {
    transform: translateY(0) scale(1);
}

/* Header */
.address-management-header,
.address-form-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 24px;
    background: linear-gradient(135deg, #667eea 0%, #5a4fcf 100%);
    border-bottom: none;
}

.address-management-header-inner,
.address-form-header-inner {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.address-modal-icon-badge {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.16);
    flex-shrink: 0;
    line-height: 0;
}

.address-modal-icon-badge i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    font-size: 22px;
    line-height: 1;
    color: #fff;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.address-management-header h3,
.address-form-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    line-height: 1.25;
}

.address-modal-subtitle {
    margin: 2px 0 0;
    font-size: 12.5px;
    color: rgba(255, 255, 255, 0.78);
    line-height: 1.35;
}

.address-management-close,
.address-form-close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    margin: 0;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 0;
    transition: background 0.15s ease, transform 0.15s ease;
}

.address-management-close i,
.address-form-close i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    font-size: 18px;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.address-management-close:hover,
.address-form-close:hover {
    background: rgba(255, 255, 255, 0.22);
    transform: scale(1.05);
}

/* Body */
.address-management-body,
.address-form-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
    background: #fbfcfe;
}

.add-address-section {
    margin-bottom: 18px;
}

.add-address-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    line-height: 1.3;
    padding: 12px 16px;
    border: 1px dashed #c7d2fe;
    border-radius: 10px;
    background: linear-gradient(180deg, #f8faff 0%, #f1f5ff 100%);
    color: #4f46e5;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}

.add-address-btn i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

.add-address-btn:hover {
    border-color: #667eea;
    background: #eef2ff;
    transform: translateY(-1px);
}

.saved-addresses-section h4,
.cart-addr-section-label {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
}

#savedAddressList,
.saved-address-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.loading-addresses,
.cart-addr-empty {
    text-align: center;
    padding: 28px 16px;
    color: #64748b;
    font-size: 14px;
}

/* Saved address cards */
.saved-address-item {
    position: relative;
    padding: 14px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.saved-address-item:hover {
    border-color: #a5b4fc;
    box-shadow: 0 8px 24px rgba(102, 126, 234, 0.1);
    transform: translateY(-1px);
}

.saved-address-item.default {
    border-color: #86efac;
    background: linear-gradient(180deg, #f0fdf4 0%, #fff 100%);
}

.saved-address-item.default::before {
    content: none;
}

.address-item-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 8px;
}

.address-item-identity {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    min-width: 0;
}

.address-item-recipient {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
}

.address-item-phone {
    font-size: 13px;
    color: #64748b;
}

.address-item-default {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    background: #dcfce7;
    color: #15803d;
    font-size: 11px;
    font-weight: 700;
}

.address-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    line-height: 1.45;
}

.address-item-line {
    font-size: 13px;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 8px;
}

.address-item-line i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 15px;
    line-height: 1;
    color: #64748b;
    flex-shrink: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.address-item-note {
    font-style: italic;
    color: #94a3b8;
}

.address-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    position: static !important;
    top: auto !important;
}

.address-item-action {
    width: 34px;
    height: 34px;
    padding: 0;
    margin: 0;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    line-height: 0;
    flex-shrink: 0;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.address-item-action i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 17px;
    height: 17px;
    font-size: 17px;
    line-height: 1;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.address-item-edit {
    color: #4338ca;
    border-color: #c7d2fe;
}

.address-item-edit:hover {
    background: #eef2ff;
    border-color: #6366f1;
    color: #3730a3;
}

.address-item-delete {
    color: #b91c1c;
    border-color: #fecaca;
}

.address-item-delete:hover {
    background: #fef2f2;
    border-color: #ef4444;
    color: #991b1b;
}

.address-item-delete:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

/* Form */
#addressForm .form-row-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

#addressForm .form-group {
    margin-bottom: 14px;
}

#addressForm .form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
}

#addressForm .form-input,
#addressForm textarea.form-input {
    width: 100%;
    box-sizing: border-box;
    min-height: 40px;
    padding: 9px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    font-size: 14px;
    color: #1e293b;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#addressForm textarea.form-input {
    min-height: 72px;
    resize: vertical;
    line-height: 1.4;
}

#addressForm .form-input::placeholder,
#addressForm textarea.form-input::placeholder {
    color: #b8c0cc;
    font-style: italic;
    font-weight: 300;
    opacity: 1;
}

#addressForm .checkout-sdw-row .sdw-trigger-label.sdw--placeholder {
    color: #b8c0cc !important;
    font-style: italic;
    font-weight: 300;
}

#addressForm .form-input:focus,
#addressForm textarea.form-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.12);
}

#addressForm .checkout-sdw-row .sdw {
    width: 100%;
}

#addressForm .checkout-sdw-row .sdw-trigger {
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #fff;
    font-size: 14px;
}

#addressForm .checkbox-group {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
}

#addressForm .checkbox-group input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #667eea;
    margin: 0;
}

#addressForm .checkbox-group label {
    margin: 0;
    font-size: 13px;
    color: #475569;
    cursor: pointer;
}

/* Footer */
.address-management-footer,
.address-form-footer {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 24px;
    background: #fff;
    border-top: 1px solid #e9ecef;
}

.address-management-footer .btn-cancel,
.address-form-footer .btn-cancel,
.address-form-footer .btn-save {
    min-width: 96px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.address-management-footer .btn-cancel,
.address-form-footer .btn-cancel {
    background: #fff;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.address-management-footer .btn-cancel:hover,
.address-form-footer .btn-cancel:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.address-form-footer .btn-save {
    background: linear-gradient(135deg, #667eea 0%, #5a4fcf 100%);
    color: #fff;
    border: none;
    box-shadow: 0 4px 14px rgba(102, 126, 234, 0.28);
}

.address-form-footer .btn-save:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.34);
}

.address-form-footer .btn-save:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.address-form-footer .btn-save i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 16px;
    line-height: 1;
}

@media (max-width: 560px) {
    .address-management-popup,
    .address-form-popup {
        padding: 8px;
        align-items: flex-end;
    }

    .address-management-content,
    .address-form-content {
        max-height: 92vh;
        border-radius: 16px 16px 0 0;
    }

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

    .address-management-footer,
    .address-form-footer {
        flex-direction: column-reverse;
    }

    .address-management-footer .btn-cancel,
    .address-form-footer .btn-cancel,
    .address-form-footer .btn-save {
        width: 100%;
    }
}
