/* ==========================================================================
   Ma Palette — Account Pages (list, detail, dropship)
   Theme Classic Bootstrap 4 compatible
   ========================================================================== */

:root {
    --mp-primary: #2fb5d2;
    --mp-primary-dark: #1a8fa8;
    --mp-success: #4cbb6c;
    --mp-warning: #f0ad4e;
    --mp-danger: #e25549;
    --mp-bg-light: #f7f7f7;
    --mp-border: #e5e5e5;
    --mp-text-muted: #999;
    --mp-radius: 6px;
    --mp-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --mp-shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.12);
    --mp-transition: 0.25s ease;
}

/* ---------- Customer Account Link ---------- */

#mapalette-link .link-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

#mapalette-link .mapalette-icon-svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

#mapalette-link .badge {
    margin-left: 6px;
    font-size: 0.7rem;
    vertical-align: middle;
    background: var(--mp-primary);
    color: #fff;
    border-radius: 10px;
    padding: 2px 8px;
}

#mapalette-link .mapalette-sub {
    display: block;
    font-size: 0.75rem;
    color: var(--mp-text-muted);
    margin-top: 2px;
}

/* ---------- Palette List ---------- */

.mapalette-list .mapalette-card {
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    transition: box-shadow var(--mp-transition), transform var(--mp-transition);
    overflow: hidden;
}

.mapalette-list .mapalette-card:hover {
    box-shadow: var(--mp-shadow-hover);
    transform: translateY(-2px);
}

.mapalette-list .mapalette-card .card-body {
    padding: 20px;
}

.mapalette-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.mapalette-card-header .mapalette-icon-svg {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    opacity: 0.6;
}

.mapalette-card-header h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.mapalette-card .badge-pill {
    font-size: 0.72rem;
    padding: 4px 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.badge-status-active { background: var(--mp-success); color: #fff; }
.badge-status-full { background: var(--mp-warning); color: #fff; }
.badge-status-shipped { background: var(--mp-primary); color: #fff; }
.badge-status-shipping_requested { background: #6c757d; color: #fff; }
.badge-status-archived { background: #dee2e6; color: #555; }

.badge-free {
    background: transparent;
    border: 1px solid var(--mp-success);
    color: var(--mp-success);
    font-size: 0.7rem;
    padding: 3px 8px;
}

/* Progress bars */
.mapalette-progress-item {
    margin-bottom: 10px;
}

.mapalette-progress-item .progress-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.82rem;
    color: #555;
    margin-bottom: 4px;
}

.mapalette-progress-item .progress {
    height: 18px;
    border-radius: 10px;
    background: #eee;
    overflow: hidden;
}

.mapalette-progress-item .progress-bar {
    font-size: 0.72rem;
    line-height: 18px;
    font-weight: 600;
    border-radius: 10px;
    transition: width 0.6s ease;
}

.mapalette-card .mapalette-meta {
    text-align: right;
    color: var(--mp-text-muted);
    font-size: 0.85rem;
}

.mapalette-card .mapalette-meta .meta-products {
    font-size: 1rem;
    color: #333;
    font-weight: 600;
}

.mapalette-card .btn-detail {
    display: inline-block;
    margin-top: 12px;
    padding: 8px 20px;
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 20px;
    transition: all var(--mp-transition);
}

/* Empty state */
.mapalette-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--mp-text-muted);
}

.mapalette-empty .mapalette-icon-svg {
    width: 64px;
    height: 64px;
    opacity: 0.3;
    margin-bottom: 16px;
}

/* ---------- Palette Detail ---------- */

.mapalette-detail .back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9rem;
    color: var(--mp-primary);
    text-decoration: none;
    margin-bottom: 20px;
}

.mapalette-detail .back-link:hover {
    color: var(--mp-primary-dark);
}

/* Stat boxes */
.mapalette-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.mapalette-stat-box {
    flex: 1;
    min-width: 120px;
    background: var(--mp-bg-light);
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    padding: 16px;
    text-align: center;
}

.mapalette-stat-box .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
    display: block;
}

.mapalette-stat-box .stat-label {
    font-size: 0.78rem;
    color: var(--mp-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 4px;
}

/* 2D Visualization */
.mapalette-visu {
    display: flex;
    align-items: flex-end;
    gap: 24px;
    padding: 24px;
    justify-content: center;
}

.mapalette-visu-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mapalette-visu-palette {
    position: relative;
    border: 2px solid #555;
    border-bottom: 3px solid #444;
    border-radius: 2px 2px 0 0;
    background: #fafafa;
    overflow: hidden;
}

.mapalette-visu-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    border-radius: 0;
    transition: height 1s ease-out;
    animation: mp-fill-up 1.2s ease-out;
}

@keyframes mp-fill-up {
    from { height: 0 !important; }
}

.mapalette-visu-fill.fill-ok {
    background: linear-gradient(to top, var(--mp-success), #8ee0a1);
}

.mapalette-visu-fill.fill-warn {
    background: linear-gradient(to top, var(--mp-warning), #f7d184);
}

.mapalette-visu-fill.fill-danger {
    background: linear-gradient(to top, var(--mp-danger), #f0908a);
}

.mapalette-visu-fill-label {
    position: absolute;
    bottom: 50%;
    left: 50%;
    transform: translate(-50%, 50%);
    font-size: 1.1rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
}

.mapalette-visu-limit {
    position: absolute;
    top: 0;
    left: -8px;
    right: -8px;
    border-top: 2px dashed var(--mp-danger);
    opacity: 0.5;
}

.mapalette-visu-limit-label {
    position: absolute;
    top: -18px;
    right: -8px;
    font-size: 0.65rem;
    color: var(--mp-danger);
    white-space: nowrap;
}

/* Palette feet */
.mapalette-visu-feet {
    display: flex;
    justify-content: space-between;
    width: 100%;
    padding: 0 8px;
}

.mapalette-visu-foot {
    width: 20%;
    height: 10px;
    background: #8B6914;
    border-radius: 0 0 3px 3px;
}

/* Dimension labels */
.mapalette-visu-dim {
    position: absolute;
    font-size: 0.7rem;
    color: #888;
}

.mapalette-visu-dim-width {
    bottom: -24px;
    left: 50%;
    transform: translateX(-50%);
}

.mapalette-visu-dim-height {
    top: 50%;
    right: -40px;
    transform: translateY(-50%) rotate(90deg);
    transform-origin: right center;
}

/* Info panel beside visu */
.mapalette-visu-info {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 200px;
}

.mapalette-visu-info-item {
    padding: 12px 16px;
    background: var(--mp-bg-light);
    border-radius: var(--mp-radius);
    border-left: 3px solid var(--mp-primary);
}

.mapalette-visu-info-item .info-label {
    font-size: 0.75rem;
    color: var(--mp-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.mapalette-visu-info-item .info-value {
    font-size: 1rem;
    font-weight: 600;
    color: #333;
    margin-top: 2px;
}

.mapalette-visu-info-item .info-bar {
    height: 6px;
    background: #eee;
    border-radius: 3px;
    margin-top: 6px;
    overflow: hidden;
}

.mapalette-visu-info-item .info-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

/* Detail cards */
.mapalette-detail .card {
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    margin-bottom: 20px;
    box-shadow: var(--mp-shadow);
}

.mapalette-detail .card-header {
    background: var(--mp-bg-light);
    border-bottom: 1px solid var(--mp-border);
    padding: 14px 20px;
}

.mapalette-detail .card-header h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

/* Products table */
.mapalette-detail .table-products img {
    border-radius: 4px;
    width: 60px;
    height: 60px;
    object-fit: cover;
}

.mapalette-detail .table-products tbody tr {
    transition: background var(--mp-transition);
}

.mapalette-detail .table-products tbody tr:hover {
    background: rgba(47, 181, 210, 0.04);
}

/* Shipment card */
.mapalette-ship-card {
    background: linear-gradient(135deg, #f8f9fa, #eef6f9) !important;
    border: 1px solid var(--mp-primary) !important;
}

.mapalette-ship-card .btn-ship {
    padding: 12px 32px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 25px;
    transition: all var(--mp-transition);
}

.mapalette-ship-card .btn-ship:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 187, 108, 0.3);
}

/* History badges */
.mapalette-detail .badge-shipment {
    padding: 5px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 12px;
}

/* ---------- Product Chips (Drag & Drop) ---------- */

.mp-product-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 4px;
    background: var(--mp-bg-light);
    border: 1px solid var(--mp-border);
    border-radius: 16px;
    font-size: 0.78rem;
    color: #333;
    transition: all 0.2s ease;
    max-width: 200px;
    user-select: none;
}

.mp-product-chip[draggable="true"] {
    cursor: grab;
}

.mp-product-chip[draggable="true"]:hover {
    background: #eef6f9;
    border-color: var(--mp-primary);
    box-shadow: 0 1px 4px rgba(47, 181, 210, 0.2);
}

.mp-product-chip[draggable="true"]:active {
    cursor: grabbing;
}

.mp-product-chip img {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

/* Drag & Drop card highlights */
.mapalette-card.mp-drag-over-ok {
    outline: 2px solid var(--mp-primary) !important;
    outline-offset: -2px;
    background: rgba(47, 181, 210, 0.02);
}

.mapalette-card.mp-drag-over-nok {
    outline: 2px solid var(--mp-danger) !important;
    outline-offset: -2px;
    background: rgba(226, 85, 73, 0.02);
}

/* ---------- Mini 2D Visualization ---------- */

.mp-mini-visu {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mp-mini-visu-fill {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    transition: height 0.8s ease-out;
    animation: mp-mini-fill-up 1s ease-out;
}

@keyframes mp-mini-fill-up {
    from { height: 0 !important; }
}

/* ---------- Rename ---------- */

.mp-rename-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    color: var(--mp-text-muted);
    opacity: 0.6;
    transition: opacity var(--mp-transition), color var(--mp-transition);
}

.mp-rename-btn:hover {
    opacity: 1;
    color: var(--mp-primary);
}

.mp-palette-name input {
    font-size: 1.05rem;
    font-weight: 600;
    border: 1px solid var(--mp-primary);
    border-radius: 4px;
    padding: 2px 6px;
    outline: none;
    width: 100%;
    max-width: 300px;
}

/* ---------- Transfer Modal ---------- */

#mp-transfer-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    animation: mp-modal-fade-in 0.2s ease;
}

@keyframes mp-modal-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

#mp-transfer-modal > div {
    animation: mp-modal-slide-in 0.25s ease;
}

@keyframes mp-modal-slide-in {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ---------- Transfer Badge (floating) ---------- */

#mp-transfer-badge {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: var(--mp-primary);
    color: #fff;
    border-radius: 28px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(47, 181, 210, 0.4);
    z-index: 9998;
    transition: transform var(--mp-transition), box-shadow var(--mp-transition);
    animation: mp-badge-pulse 2s ease-in-out infinite;
    user-select: none;
}

#mp-transfer-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(47, 181, 210, 0.5);
}

.mp-badge-icon {
    font-size: 1.2rem;
}

.mp-badge-action {
    padding: 3px 10px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 14px;
    font-size: 0.78rem;
}

@keyframes mp-badge-pulse {
    0%, 100% { box-shadow: 0 4px 16px rgba(47, 181, 210, 0.4); }
    50% { box-shadow: 0 4px 24px rgba(47, 181, 210, 0.6); }
}

/* ---------- Transfer List (in modal) ---------- */

.mp-transfer-list {
    max-height: 300px;
    overflow-y: auto;
    margin: -4px 0 16px;
}

.mp-transfer-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    margin-bottom: 8px;
    background: var(--mp-bg-light);
    transition: background var(--mp-transition);
}

.mp-transfer-item:hover {
    background: #eef6f9;
}

.mp-transfer-item-info {
    flex: 1;
    min-width: 0;
}

.mp-transfer-item-info strong {
    font-size: 0.88rem;
    color: #333;
}

.mp-transfer-qty {
    font-size: 0.75rem;
    color: var(--mp-text-muted);
    font-weight: 400;
}

.mp-transfer-route {
    font-size: 0.78rem;
    color: var(--mp-text-muted);
    margin-top: 2px;
}

.mp-transfer-remove {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: var(--mp-text-muted);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--mp-transition);
}

.mp-transfer-remove:hover {
    background: rgba(226, 85, 73, 0.1);
    color: var(--mp-danger);
}

/* Transfer progress */
.mp-transfer-progress {
    text-align: center;
    padding: 16px 0;
}

.mp-transfer-progress-text {
    font-size: 0.9rem;
    color: #555;
    font-weight: 500;
}

/* ---------- Checkout Palette Selector ---------- */

#mapalette-select-palette {
    padding: 6px 10px;
    border: 1px solid var(--mp-border);
    border-radius: 20px;
    font-size: 0.85rem;
    color: #333;
    background: #fff;
    cursor: pointer;
    outline: none;
    transition: border-color var(--mp-transition);
}

#mapalette-select-palette:focus {
    border-color: var(--mp-primary);
    box-shadow: 0 0 0 2px rgba(47, 181, 210, 0.15);
}

/* ---------- Dropship Form ---------- */

.mapalette-dropship .card {
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    box-shadow: var(--mp-shadow);
}

.mapalette-dropship .table img {
    border-radius: 4px;
    width: 60px;
    height: 60px;
    object-fit: cover;
}

.mapalette-dropship .qty-stepper {
    display: inline-flex;
    align-items: center;
    gap: 0;
    border: 1px solid var(--mp-border);
    border-radius: var(--mp-radius);
    overflow: hidden;
}

.mapalette-dropship .qty-stepper button {
    width: 44px;
    height: 44px;
    border: none;
    background: var(--mp-bg-light);
    font-size: 1.2rem;
    font-weight: 700;
    color: #555;
    cursor: pointer;
    transition: background var(--mp-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mapalette-dropship .qty-stepper button:hover {
    background: #e0e0e0;
}

.mapalette-dropship .qty-stepper button:active {
    background: #d0d0d0;
}

.mapalette-dropship .qty-stepper input {
    width: 56px;
    height: 44px;
    border: none;
    border-left: 1px solid var(--mp-border);
    border-right: 1px solid var(--mp-border);
    text-align: center;
    font-size: 0.95rem;
    font-weight: 600;
    -moz-appearance: textfield;
}

.mapalette-dropship .qty-stepper input::-webkit-outer-spin-button,
.mapalette-dropship .qty-stepper input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Row highlight when qty > 0 */
.mapalette-dropship tbody tr {
    transition: background var(--mp-transition);
}

.mapalette-dropship tbody tr.has-qty {
    background: rgba(47, 181, 210, 0.04);
}

/* Live summary bar */
.mp-dropship-summary-bar {
    position: sticky;
    bottom: 0;
    z-index: 100;
    background: #fff;
    border-top: 2px solid var(--mp-primary);
    padding: 12px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    border-radius: var(--mp-radius) var(--mp-radius) 0 0;
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: #333;
}

.mp-summary-left {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.mp-summary-icon {
    font-size: 1.1rem;
}

.mp-summary-right {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #555;
}

.mp-summary-sep {
    color: var(--mp-text-muted);
}

/* Address cards */
.mp-address-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mp-address-card {
    display: block;
    border: 2px solid var(--mp-border);
    border-radius: var(--mp-radius);
    padding: 16px;
    cursor: pointer;
    transition: all var(--mp-transition);
    margin-bottom: 0;
}

.mp-address-card:hover {
    border-color: var(--mp-primary);
}

.mp-address-card.active {
    border-color: var(--mp-primary);
    background: rgba(47, 181, 210, 0.04);
}

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

.mp-address-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 0.92rem;
}

.mp-address-content {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--mp-border);
}

.mapalette-dropship #mapalette-new-address {
    background: transparent;
    border-radius: 0;
    padding: 0;
    margin-top: 0;
}

.mapalette-dropship .btn-confirm-dropship {
    padding: 12px 32px;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 25px;
    transition: all var(--mp-transition);
}

.mapalette-dropship .btn-confirm-dropship:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Review modal */
.mp-review-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    animation: mp-modal-fade-in 0.2s ease;
}

.mp-review-modal-content {
    background: #fff;
    border-radius: 10px;
    padding: 24px;
    max-width: 460px;
    width: 90%;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: mp-modal-slide-in 0.25s ease;
}

.mp-review-list {
    max-height: 260px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.mp-review-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    border-bottom: 1px solid var(--mp-border);
    font-size: 0.88rem;
}

.mp-review-item:last-child {
    border-bottom: none;
}

.mp-review-name {
    color: #333;
    font-weight: 500;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 12px;
}

.mp-review-detail {
    color: var(--mp-text-muted);
    font-size: 0.8rem;
    white-space: nowrap;
}

.mp-review-total {
    padding: 10px 10px 0;
    border-top: 2px solid var(--mp-border);
    font-size: 0.9rem;
    color: #333;
}

/* ---------- Responsive ---------- */

@media (max-width: 767px) {
    .mapalette-list .mapalette-card .row {
        flex-direction: column;
    }

    .mapalette-card .mapalette-meta {
        text-align: left;
        margin-top: 12px;
    }

    .mapalette-stats {
        flex-direction: column;
    }

    .mapalette-stat-box {
        min-width: auto;
    }

    .mapalette-visu {
        flex-direction: column;
        align-items: center;
    }

    .mapalette-visu-info {
        min-width: auto;
        width: 100%;
    }

    .mapalette-detail .table-products img {
        width: 40px;
        height: 40px;
    }

    .mapalette-dropship .qty-stepper button {
        width: 40px;
        height: 40px;
    }

    .mapalette-dropship .qty-stepper input {
        width: 44px;
        height: 40px;
    }

    .mp-dropship-summary-bar {
        padding: 10px 14px;
        font-size: 0.82rem;
    }

    .mp-address-card {
        padding: 12px;
    }

    /* Mini visu stacks above bars on mobile */
    .mp-mini-visu {
        margin-bottom: 12px;
    }

    /* Chips wrap tighter on mobile */
    .mp-product-chips {
        gap: 4px !important;
    }

    .mp-product-chip {
        max-width: 160px;
        font-size: 0.72rem;
    }

    /* Checkout palette selector full width */
    #mapalette-select-palette {
        max-width: 100% !important;
    }

    /* Transfer badge full-width on mobile */
    #mp-transfer-badge {
        left: 12px;
        right: 12px;
        bottom: 12px;
        justify-content: center;
        border-radius: 24px;
    }
}
