/* ═══════════════════════════════════════════════════
   DASHBOARD CUSTOMIZER — Drag & Drop Widgets
   ═══════════════════════════════════════════════════ */

/* ─── Customize Bar ─── */
.dash-customize-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: linear-gradient(90deg, rgba(var(--bs-primary-rgb), .06), transparent);
    border: 1px solid rgba(var(--bs-primary-rgb), .15);
    border-radius: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.dash-customize-bar .bar-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: .85rem;
    color: var(--bs-primary);
}
.dash-customize-bar .bar-label i { font-size: 1rem; }

.dash-customize-actions {
    margin-inline-start: auto;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.btn-customize {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 14px;
    border: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border-radius: 10px;
    font-size: .8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.btn-customize:hover {
    background: rgba(var(--bs-primary-rgb), .08);
    border-color: rgba(var(--bs-primary-rgb), .3);
    color: var(--bs-primary);
}
.btn-customize.primary {
    background: var(--bs-primary);
    color: #fff;
    border-color: var(--bs-primary);
}
.btn-customize.primary:hover {
    background: #6558d6;
    color: #fff;
}
.btn-customize.active {
    background: #28c76f;
    color: #fff;
    border-color: #28c76f;
}

/* ─── Grid container in edit mode ─── */
[data-customizable="1"] .row.dash-grid {
    gap: 8px;
}
[data-customizable="1"] .dash-widget {
    cursor: grab;
    position: relative;
    transition: transform .15s, box-shadow .15s, opacity .15s;
    animation: dashWidgetPulse 2s ease-in-out infinite alternate;
}
@keyframes dashWidgetPulse {
    from { box-shadow: 0 0 0 0 rgba(var(--bs-primary-rgb), 0); }
    to { box-shadow: 0 0 0 4px rgba(var(--bs-primary-rgb), .08); }
}
[data-customizable="1"] .dash-widget:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(var(--bs-primary-rgb), .15), 0 0 0 2px var(--bs-primary);
    animation: none;
}
[data-customizable="1"] .dash-widget:active {
    cursor: grabbing;
}
[data-customizable="1"] .dash-widget.dragging {
    opacity: .4;
    transform: scale(.98);
    cursor: grabbing;
}
[data-customize="1"] .dash-widget.dragging-over {
    box-shadow: 0 0 0 3px #28c76f, 0 8px 24px rgba(40,199,111,.15);
    transform: translateY(-4px);
}

/* ─── Widget grip handle ─── */
.dash-widget-grip {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    background: var(--bs-primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    opacity: 0;
    pointer-events: none;
    transition: all .2s;
    z-index: 10;
    box-shadow: 0 3px 8px rgba(var(--bs-primary-rgb), .3);
}
[data-customizable="1"] .dash-widget .dash-widget-grip {
    opacity: 1;
    pointer-events: auto;
}
.dash-widget-grip:hover {
    transform: scale(1.15);
    box-shadow: 0 5px 12px rgba(var(--bs-primary-rgb), .4);
}

/* ─── Widget hide button ─── */
.dash-widget-hide {
    position: absolute;
    top: 8px;
    left: 8px;
    width: 26px;
    height: 26px;
    background: rgba(234,84,85,.9);
    color: #fff;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: all .2s;
    z-index: 10;
}
[data-customizable="1"] .dash-widget .dash-widget-hide {
    opacity: 1;
    pointer-events: auto;
}
.dash-widget-hide:hover {
    transform: scale(1.15);
    background: #ea5455;
}

/* ─── Hidden widgets panel ─── */
.hidden-widgets-panel {
    display: none;
    padding: 12px 16px;
    background: rgba(0,0,0,.02);
    border: 1px dashed var(--bs-border-color);
    border-radius: 12px;
    margin-bottom: 16px;
}
.hidden-widgets-panel.open { display: block; }
.hidden-widgets-panel h6 {
    font-size: .82rem;
    color: var(--bs-secondary-color);
    margin-bottom: 10px;
}
.hidden-widget-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.hidden-widget-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 50px;
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
}
.hidden-widget-chip:hover {
    background: rgba(40,199,111,.1);
    border-color: #28c76f;
    color: #28c76f;
    transform: translateY(-1px);
}

/* ─── Save indicator ─── */
.dash-save-indicator {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #28c76f;
    color: #fff;
    padding: 10px 18px;
    border-radius: 50px;
    font-size: .85rem;
    font-weight: 700;
    box-shadow: 0 8px 24px rgba(40,199,111,.4);
    opacity: 0;
    pointer-events: none;
    transition: all .3s;
    transform: translateY(20px);
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 6px;
}
.dash-save-indicator.show {
    opacity: 1;
    transform: translateY(0);
}

/* ─── Sortable placeholder ─── */
.dash-widget-placeholder {
    background: rgba(var(--bs-primary-rgb), .12);
    border: 2px dashed var(--bs-primary);
    border-radius: 12px;
    min-height: 100px;
    transition: all .15s;
}

@media (max-width: 767px) {
    .dash-customize-bar { padding: 8px 12px; font-size: .75rem; }
    .btn-customize { padding: 5px 10px; font-size: .72rem; }
    .dash-widget-grip { top: 6px; right: 6px; width: 24px; height: 24px; }
    .dash-widget-hide { top: 6px; left: 6px; width: 22px; height: 22px; }
}

/* ═══════════════════════════════════════════════════
   FORCE FIX — override any conflicts
   ═══════════════════════════════════════════════════ */
[data-customizable="1"] .dash-widget {
    position: relative !important;
}
[data-customizable="1"] .dash-widget .dash-widget-grip {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    left: auto !important;
    bottom: auto !important;
    width: 28px !important;
    height: 28px !important;
    min-width: 28px !important;
    max-width: 28px !important;
    min-height: 28px !important;
    max-height: 28px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 10 !important;
    overflow: hidden !important;
}
[data-customizable="1"] .dash-widget .dash-widget-hide {
    position: absolute !important;
    top: 8px !important;
    left: 8px !important;
    right: auto !important;
    bottom: auto !important;
    width: 26px !important;
    height: 26px !important;
    min-width: 26px !important;
    max-width: 26px !important;
    min-height: 26px !important;
    max-height: 26px !important;
    padding: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    z-index: 10 !important;
    overflow: hidden !important;
    border-radius: 50% !important;
}
