/* Rank Badge & Modal Premium Design */
.eco-rank-badge {
    transition: transform 0.2s, background-color 0.2s;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.eco-rank-badge:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.eco-rank-modal-content {
    max-width: 480px !important;
    padding: 20px !important;
    background: #ffffff !important;
    border-radius: 24px !important;
    border: 1px solid rgba(0, 0, 0, 0.08) !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2) !important;
    max-height: 70vh !important;
    /* Slightly more restricted to encourage scroll */
    overflow-y: auto !important;
    scrollbar-width: thin;
    scrollbar-color: var(--eco-pri) transparent;
}

.eco-rank-modal-content::-webkit-scrollbar {
    width: 4px;
}

.eco-rank-modal-content::-webkit-scrollbar-thumb {
    background: var(--eco-pri);
    border-radius: 10px;
}

.eco-rank-dropdown-title {
    font-size: 15px;
    font-weight: 800;
    color: var(--eco-text);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 24px;
    text-align: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    padding-bottom: 18px;
}

.eco-rank-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-radius: 18px;
    margin-bottom: 10px;
    transition: background-color 0.15s, transform 0.15s;
    border: 1px solid transparent;
}

.eco-rank-item:hover {
    background: rgba(0, 0, 0, 0.03);
    transform: translateX(4px);
}

.eco-rank-item.is-current {
    background: var(--eco-pri-soft);
    border: 1px solid rgba(131, 157, 3, 0.2);
    box-shadow: 0 1px 4px rgba(131, 157, 3, 0.1);
}

.eco-rank-name {
    font-weight: 700;
    font-size: 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.eco-rank-label-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.eco-rank-current-dot {
    width: 10px;
    height: 10px;
    background: var(--eco-pri);
    border-radius: 50%;
    flex-shrink: 0;
}

.eco-rank-leader-bonus {
    font-size: 10px;
    font-weight: 700;
    margin-top: 0px;
    margin-left: 22px;
    /* Căn lề thẳng với tên rank khi có dot (10px + 12px) */
}

/* Khi không phải rank hiện tại (không có dot), không thụt lề */
.eco-rank-item:not(.is-current) .eco-rank-leader-bonus {
    margin-left: 0;
}

.eco-rank-info {
    text-align: right;
}

.eco-rank-rate {
    font-weight: 800;
    font-size: 16px;
    color: var(--eco-pri);
}

.eco-rank-target {
    font-size: 11px;
    color: var(--eco-text-sec);
    font-weight: 600;
    margin-top: 3px;
}

/* Mobile Bottom Sheet for Rank Modal */
@media (max-width: 600px) {
    #eco-rank-modal.eco-modal {
        align-items: flex-end !important;
    }

    #eco-rank-modal .eco-rank-modal-content {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 30px 30px 0 0 !important;
        transform: translateY(100%);
        transition: transform 0.3s ease-out;
        max-height: 85vh !important;
        padding: 40px 24px 50px 24px !important;
    }

    #eco-rank-modal.active .eco-rank-modal-content {
        transform: translateY(0);
    }

    #eco-rank-modal .eco-rank-modal-content::before {
        content: '';
        position: absolute;
        top: 15px;
        left: 50%;
        transform: translateX(-50%);
        width: 45px;
        height: 5px;
        background: rgba(0, 0, 0, 0.12);
        border-radius: 3px;
    }

    #eco-rank-modal .eco-modal-close {
        top: 10px;
        right: 15px;
        background: rgba(0, 0, 0, 0.05);
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        font-size: 20px;
    }
}

/* --- Product Modal & Form --- */
.eco-modal {
    display: none;
    position: fixed;
    z-index: 100001 !important;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.75) !important;
    pointer-events: auto;
    /* Ensure events are caught by overlay */
}

.eco-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.eco-modal:not(.active) {
    display: none !important;
    pointer-events: none;
    opacity: 0;
}

.eco-modal-content {
    background-color: #fff;
    margin: 0;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 700px;
    position: relative;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    max-height: 85vh;
    overflow-y: auto;
}

.eco-modal-close {
    position: absolute;
    right: 15px;
    top: 10px;
    font-size: 32px;
    font-weight: bold;
    color: #999;
    cursor: pointer;
    line-height: 1;
    z-index: 10001;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s, color 0.15s;
    /* Reset Button Styles */
    background: transparent;
    border: none;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.eco-modal-close:hover {
    color: #333;
    transform: scale(1.1);
}

.eco-modal-close:active {
    transform: scale(0.9);
}

.eco-form-group {
    margin-bottom: 20px;
}

.eco-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 700;
    font-size: 14px;
}

.eco-form-group input[type="text"],
.eco-form-group input[type="url"],
.eco-form-group input[type="email"],
.eco-form-group input[type="password"],
.eco-form-group select,
.eco-form-group textarea {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #ddd;
    font-size: 14px;
}

.eco-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.eco-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.eco-thumb-preview img {
    width: 80px;
    height: 80px;
    border-radius: 10px;
    margin-top: 10px;
    object-fit: cover;
}

/* --- New Product Form UI (Enhancement) --- */
.eco-media-picker-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    border: 2px dashed rgba(131, 157, 3, 0.3);
    border-radius: 12px;
    background: #fff;
    color: var(--eco-pri);
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 700;
}

.eco-media-picker-btn:hover {
    background: var(--eco-pri-soft);
    border-color: var(--eco-pri);
}

/* Mobile Optimization */
@media (max-width: 768px) {
    .eco-dashboard-v6 {
        margin: 10px auto;
        padding: 0 10px;
    }

    .eco-product-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 15px;
        margin-bottom: 20px;
    }

    .eco-product-header h2 {
        font-size: 20px;
    }

    .eco-product-header .eco-btn-primary {
        width: 100%;
        justify-content: center;
    }

    .eco-table-wrapper {
        margin: 0 -10px;
        /* Bleed to edges on mobile if desired, or keep 0 */
        width: calc(100% + 20px);
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .eco-table th,
    .eco-table td {
        padding: 12px 15px;
    }

    .eco-product-info img {
        width: 40px;
        height: 40px;
    }

    #eco-product-modal.active {
        display: flex !important;
        align-items: flex-end !important;
        /* Canh dưới đáy */
        justify-content: center !important;
        padding: 0 !important;
    }

    #eco-product-modal .eco-modal-content {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        /* Xóa margin mặt định */
        border-radius: 25px 25px 0 0 !important;
        /* Bo góc trên */
        height: auto !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
        padding: 25px 20px !important;
        animation: slideUp 0.4s cubic-bezier(0, 0.55, 0.45, 1) !important;
    }

    @keyframes slideUp {
        from {
            transform: translateY(100%);
            opacity: 0;
        }

        to {
            transform: translateY(0);
            opacity: 1;
        }
    }

    .eco-form-row {
        flex-direction: column !important;
        gap: 0 !important;
    }

    .eco-form-group {
        width: 100% !important;
    }

    .eco-media-picker-btn {
        padding: 15px !important;
    }

    .eco-preview-item {
        width: calc(33.33% - 7px) !important;
        height: 100px !important;
    }
}

.eco-media-picker-btn .material-symbols-outlined {
    font-size: 32px;
}

.eco-media-picker-btn.btn-wide {
    width: 100%;
}

.eco-media-preview-area {
    margin-top: 15px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.eco-preview-item {
    position: relative;
    width: 100px;
    height: 100px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.eco-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.eco-remove-media {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    background: #ff3b30;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    line-height: 1;
    font-weight: bold;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
}

/* Tag Suggestions */
.eco-tag-suggest-container {
    position: relative;
}

.eco-tag-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 0 0 10px 10px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: none;
    max-height: 200px;
    overflow-y: auto;
}

.eco-tag-suggestion {
    padding: 10px 15px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.eco-tag-suggestion:hover {
    background: #f5f5f7;
}

/* --- AVATAR MODAL (SIMPLIFIED & FIXED) --- */
.eco-avatar-modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.7) !important;
    z-index: 999999 !important;
    display: none; /* Controlled by .active */
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.eco-avatar-modal.active {
    display: flex !important;
}

.eco-avatar-modal-content {
    background: #fff !important;
    width: 100%;
    max-width: 400px !important;
    border-radius: 24px !important;
    padding: 30px !important;
    position: relative;
    max-height: 90vh !important;
    overflow-y: auto !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2) !important;
    scrollbar-width: thin;
}

.eco-modal-title {
    margin: 0 0 25px 0;
    color: #839d03;
    font-size: 20px;
}

.eco-avatar-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.eco-avatar-option {
    cursor: pointer;
    border-radius: 50%;
    overflow: hidden;
    aspect-ratio: 1/1;
    border: 3px solid transparent;
    transition: all 0.2s ease;
}

.eco-avatar-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.eco-avatar-option:hover,
.eco-avatar-option.selected {
    border-color: #839d03;
    transform: scale(1.05);
}

.eco-modal-divider {
    text-align: center;
    position: relative;
    margin: 25px 0;
}

.eco-modal-divider:before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 1px;
    background: #eee;
}

.eco-modal-divider span {
    background: #fff;
    padding: 0 15px;
    position: relative;
    color: #999;
    font-size: 12px;
    font-weight: 600;
}

.eco-avatar-upload-area {
    text-align: center;
}

.eco-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #f5f5f5;
    padding: 12px 20px;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
    width: 100%;
    justify-content: center;
}

.eco-upload-btn:hover {
    background: #eee;
}

.eco-upload-hint {
    margin-top: 10px;
    font-size: 12px;
    color: #999;
}

/* Mobile Optimization for Account Tab */
@media (max-width: 768px) {
    .eco-account-card {
        padding: 20px 15px !important;
    }

    .eco-account-avatar-section {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    .eco-avatar-info {
        align-items: center;
    }

    .eco-display-name-big {
        font-size: 20px;
    }

    .eco-form-row {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .eco-form-actions {
        flex-direction: column;
    }

    .eco-btn-large {
        width: 100%;
        text-align: center;
    }

    .eco-avatar-modal-content {
        width: 90% !important;
        margin: 20% auto !important;
        padding: 20px !important;
    }

    .eco-avatar-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    /* Pagination Mobile */
    .eco-pagination {
        gap: 6px;
    }

    .eco-pagination a,
    .eco-pagination span {
        min-width: 32px;
        height: 32px;
        font-size: 12px;
        padding: 0 8px;
        border-radius: 8px;
    }

    .eco-pagination .prev,
    .eco-pagination .next {
        font-size: 11px;
    }
}

/* Order Details Modal V2 Custom Scrollbar */
#modal-order-content-v2::-webkit-scrollbar {
    width: 6px;
}

#modal-order-content-v2::-webkit-scrollbar-thumb {
    background: var(--eco-pri);
    border-radius: 10px;
}

/* --- Order Details Modal V2 [V17.2] --- */
.eco-order-loading-container {
    padding: 80px 30px;
    text-align: center;
    color: #666;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}

.eco-order-loading-text {
    margin-top: 25px;
    font-weight: 600;
    color: #64748b;
}

.eco-order-meta-header {
    padding: 15px 30px;
    background: #fff;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.eco-order-meta-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.eco-order-meta-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.eco-order-meta-row.mt-2 {
    margin-top: 2px;
}

.eco-order-meta-label {
    font-size: 11px;
    font-weight: 800;
    color: #64748b;
    letter-spacing: 0.5px;
}

.eco-order-meta-member {
    font-size: 11px;
    font-weight: 800;
    color: var(--eco-pri);
}

.eco-order-status-badge-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.eco-order-status-label {
    font-size: 11px;
    font-weight: 800;
    color: #64748b;
}

.eco-order-status-badge {
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 800;
    font-size: 11px;
}

.eco-order-items-wrapper {
    padding: 10px 0;
}

.eco-order-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.eco-order-item-row {
    border-bottom: 1px solid #f8fafc;
}

.eco-order-item-thumb-td {
    padding: 15px 0 15px 30px;
    width: 65px;
    vertical-align: middle;
}

.eco-order-item-thumb-box {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #f1f5f9;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.eco-order-item-thumb-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.eco-order-item-info-td {
    padding: 15px 15px;
    vertical-align: middle;
}

.eco-order-item-name {
    font-weight: 700;
    color: #1e293b;
    font-size: 14px;
    line-height: 1.3;
    margin-bottom: 2px;
}

.eco-order-item-id {
    font-size: 11px;
    color: #94a3b8;
    font-weight: 600;
}

.eco-order-item-qty-td {
    padding: 15px 15px;
    text-align: center;
    vertical-align: middle;
    width: 60px;
}

.eco-order-qty-pill {
    background: #f1f5f9;
    color: #64748b;
    padding: 4px 10px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 12px;
}

.eco-order-item-total-td {
    padding: 15px 30px;
    text-align: right;
    vertical-align: middle;
    font-weight: 800;
    color: #1e293b;
    font-size: 15px;
    width: 120px;
}

.eco-order-footer {
    padding: 25px 30px;
    background: #f8fafc;
    border-top: 1px solid #edf2f7;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.eco-order-footer-label {
    font-size: 11px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.eco-order-footer-value {
    font-size: 18px;
    font-weight: 800;
    color: #334155;
}

.eco-order-footer-income-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--eco-pri);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.eco-order-footer-income-value {
    font-size: 24px;
    font-weight: 900;
    color: var(--eco-pri);
    text-shadow: 0 2px 10px var(--eco-pri-soft);
}

.eco-order-note-area {
    padding: 12px 30px;
    background: #fff;
    text-align: center;
    border-top: 1px solid #f1f5f9;
}

.eco-order-note-text {
    margin: 0;
    font-size: 10px;
    font-style: italic;
    color: #cbd5e1;
}
