/* =============================================================================
   NEXORA CONTACT DOCK - BESPOKE MULTIPURPOSE FLOATING LAUNCHER
   -----------------------------------------------------------------------------
   Inspired by LastSepehran contact dock with luxury glassmorphism, morphing
   animations, demo adaptability, and responsive FAB controls.
   ============================================================================= */

:root {
    --cd-grad-start: #b91c1c;
    --cd-grad-end: #d97706;
    --cd-accent: #fbbf24;
    --cd-panel-bg: rgba(18, 22, 28, 0.97);
    --cd-panel-border: rgba(217, 119, 6, 0.38);
    --cd-panel-head-bg: linear-gradient(90deg, rgba(217, 119, 6, 0.22), rgba(30, 41, 59, 0.45));
    --cd-action-bg: rgba(255, 255, 255, 0.05);
    --cd-action-border: rgba(255, 255, 255, 0.09);
    --cd-action-hover-bg: rgba(255, 255, 255, 0.1);
    --cd-text-main: #f1f5f9;
    --cd-text-muted: #94a3b8;
}

.contact-dock {
    position: fixed;
    bottom: 24px;
    z-index: 99998;
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-family: var(--body-font, inherit);
    pointer-events: none; /* Only children capture clicks */
}

/* Position Left (Default like LastSepehran) */
.contact-dock.cd-pos-left {
    left: 24px;
    right: auto;
    direction: ltr; /* Keeps dock and panel strictly anchored to bottom-left */
    align-items: flex-start;
}

/* Position Right */
.contact-dock.cd-pos-right {
    right: 24px;
    left: auto;
    direction: rtl; /* Keeps dock and panel strictly anchored to bottom-right */
    align-items: flex-start;
}

/* ---------- Collapsed / Toggle Pill Button ---------- */
.contact-dock-toggle {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    position: relative;
    isolation: isolate;
    background-color: #1e293b;
    color: #ffffff;
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 13px 22px 13px 18px;
    font-size: 14.5px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32), 0 4px 14px rgba(0, 0, 0, 0.2);
    transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease, border-color 0.25s ease, background-color 0.25s ease;
    direction: rtl;
    text-align: right;
    overflow: hidden;
    white-space: nowrap;
    user-select: none;
    pointer-events: auto;
}

/* Vibrant gradient overlay layer */
.contact-dock-toggle::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--cd-grad-start, #b91c1c), var(--cd-grad-end, #d97706));
    border-radius: inherit;
    z-index: 1;
    opacity: 1;
    transition: opacity 0.32s ease;
    pointer-events: none;
}

.contact-dock-toggle:hover {
    transform: translateY(-3px);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.42), 0 6px 18px rgba(0, 0, 0, 0.25);
}

.contact-dock-toggle:active {
    transform: translateY(-1px) scale(0.99);
}

.contact-dock-toggle:focus-visible {
    outline: 3px solid var(--cd-accent, #fbbf24);
    outline-offset: 3px;
}

/* State: When Dock is Open */
.contact-dock.cd-open .contact-dock-toggle {
    border-color: var(--cd-panel-border, rgba(217, 119, 6, 0.35));
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.contact-dock.cd-open .contact-dock-toggle::before {
    opacity: 0;
}

.contact-dock.cd-open .contact-dock-toggle:hover {
    background-color: #253349;
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.55);
}

/* ---------- Icon Morphing Animation ---------- */
.cd-ico-wrap {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.cd-toggle-ico,
.cd-close-ico {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: transform 0.34s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.22s ease;
    will-change: transform, opacity;
}

.cd-toggle-ico {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.cd-close-ico {
    opacity: 0;
    transform: rotate(90deg) scale(0.4);
    pointer-events: none;
}

.contact-dock.cd-open .cd-toggle-ico {
    opacity: 0;
    transform: rotate(-90deg) scale(0.4);
    pointer-events: none;
}

.contact-dock.cd-open .cd-close-ico {
    opacity: 1;
    transform: rotate(0deg) scale(1);
    pointer-events: auto;
}

/* ---------- Text Cross-Slide Animation ---------- */
.cd-toggle-label {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    line-height: 1.3;
    overflow: hidden;
    vertical-align: middle;
}

.cd-label-open,
.cd-label-close {
    display: inline-block;
    white-space: nowrap;
    transition: opacity 0.24s ease, transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), max-width 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform, opacity, max-width;
}

.cd-label-open {
    max-width: 220px;
    opacity: 1;
    transform: translateY(0);
}

.cd-label-close {
    max-width: 0;
    opacity: 0;
    transform: translateY(12px);
    overflow: hidden;
    pointer-events: none;
}

.contact-dock.cd-open .cd-label-open {
    max-width: 0;
    opacity: 0;
    transform: translateY(-12px);
    overflow: hidden;
    pointer-events: none;
}

.contact-dock.cd-open .cd-label-close {
    max-width: 90px;
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

/* ---------- Attention Cue (Nudge Animation) ---------- */
.contact-dock.cd-hint .contact-dock-toggle {
    animation: cdNudge 1.6s ease-in-out 3;
}

@keyframes cdNudge {
    0%, 100% {
        transform: translateY(0) scale(1);
        box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
    }
    45% {
        transform: translateY(-6px) scale(1.04);
        box-shadow: 0 18px 38px rgba(0, 0, 0, 0.5);
    }
}

/* Optional Pulse Animation */
.contact-dock.cd-pulse-cue .contact-dock-toggle {
    animation: cdPulseGlow 2.2s infinite ease-in-out;
}

@keyframes cdPulseGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.5), 0 10px 28px rgba(0, 0, 0, 0.32);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(217, 119, 6, 0), 0 14px 34px rgba(0, 0, 0, 0.42);
    }
}

@media (prefers-reduced-motion: reduce) {
    .contact-dock.cd-hint .contact-dock-toggle,
    .contact-dock.cd-pulse-cue .contact-dock-toggle {
        animation: none;
    }
    .contact-dock-toggle,
    .contact-dock-panel,
    .contact-dock-toggle::before,
    .cd-toggle-ico,
    .cd-close-ico,
    .cd-label-open,
    .cd-label-close {
        transition: none !important;
    }
}

/* ---------- Expanded Pop-up Panel ---------- */
.contact-dock-panel {
    width: 330px;
    max-width: calc(100vw - 44px);
    align-self: flex-start;
    direction: rtl;
    text-align: right;
    background: var(--cd-panel-bg, rgba(18, 22, 28, 0.97));
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border: 1px solid var(--cd-panel-border, rgba(217, 119, 6, 0.38));
    border-radius: 18px;
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.52), 0 4px 16px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    opacity: 0;
    transform: translateY(14px) scale(0.96);
    transition: opacity 0.26s ease, transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    order: -1; /* Panel appears above toggle button */
}

.contact-dock.cd-pos-left .contact-dock-panel {
    transform-origin: bottom left;
}

.contact-dock.cd-pos-right .contact-dock-panel {
    transform-origin: bottom right;
}

.contact-dock.cd-open .contact-dock-panel {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ---------- Panel Header ---------- */
.contact-dock-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--cd-panel-head-bg, linear-gradient(90deg, rgba(217, 119, 6, 0.22), rgba(30, 41, 59, 0.45)));
    border-bottom: 1px solid rgba(255, 255, 255, 0.09);
    gap: 10px;
}

.contact-dock-head .cd-head-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.contact-dock-head .cd-head-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    font-weight: 800;
    color: var(--cd-text-main, #f1f5f9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-dock-head .cd-head-title i {
    color: var(--cd-accent, #fbbf24);
    font-size: 15px;
    flex-shrink: 0;
}

/* Status Dot & Badge */
.cd-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 700;
}

.cd-status-badge.online {
    color: #4ade80;
}

.cd-status-badge.offline {
    color: #cbd5e1;
}

.cd-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.cd-status-badge.online .cd-status-dot {
    background-color: #22c55e;
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6);
    animation: cdPulseDot 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

.cd-status-badge.offline .cd-status-dot {
    background-color: #94a3b8;
}

@keyframes cdPulseDot {
    0% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
    }
    70% {
        box-shadow: 0 0 0 7px rgba(34, 197, 94, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
    }
}

.contact-dock-head .cd-close {
    background: rgba(255, 255, 255, 0.08);
    border: 0;
    color: #cbd5e1;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
    flex-shrink: 0;
}

.contact-dock-head .cd-close:hover {
    background: #dc2626;
    color: #ffffff;
    transform: scale(1.05);
}

/* ---------- Action Items List ---------- */
.contact-dock-actions {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    max-height: 380px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.contact-dock-actions::-webkit-scrollbar {
    width: 5px;
}

.contact-dock-actions::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 999px;
}

.cd-action {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--cd-action-bg, rgba(255, 255, 255, 0.05));
    border: 1px solid var(--cd-action-border, rgba(255, 255, 255, 0.09));
    border-radius: 14px;
    padding: 10px 14px;
    text-decoration: none !important;
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}

.cd-action:hover {
    background: var(--cd-action-hover-bg, rgba(255, 255, 255, 0.1));
    border-color: rgba(255, 255, 255, 0.18);
    transform: translateX(-4px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.contact-dock.cd-pos-right .cd-action:hover {
    transform: translateX(4px);
}

/* Icon Box inside Action */
.cd-action .cd-ico {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    transition: transform 0.25s ease;
}

.cd-action:hover .cd-ico {
    transform: scale(1.08);
}

/* Action Icon Color Themes */
.cd-action.cd-type-phone .cd-ico,
.cd-action.cd-color-blue .cd-ico {
    background: rgba(37, 99, 235, 0.2);
    color: #60a5fa;
}

.cd-action.cd-type-whatsapp .cd-ico,
.cd-action.cd-color-green .cd-ico {
    background: rgba(22, 163, 74, 0.2);
    color: #4ade80;
}

.cd-action.cd-type-telegram .cd-ico,
.cd-action.cd-color-cyan .cd-ico {
    background: rgba(6, 182, 212, 0.2);
    color: #38bdf8;
}

.cd-action.cd-type-quote .cd-ico,
.cd-action.cd-color-amber .cd-ico {
    background: rgba(217, 119, 6, 0.2);
    color: #fbbf24;
}

.cd-action.cd-type-custom .cd-ico,
.cd-action.cd-color-purple .cd-ico {
    background: rgba(124, 58, 237, 0.2);
    color: #c084fc;
}

.cd-action.cd-color-rose .cd-ico {
    background: rgba(225, 29, 72, 0.2);
    color: #fb7185;
}

/* Action Text Details */
.cd-action .cd-txt {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    line-height: 1.5;
    min-width: 0;
}

.cd-action .cd-txt b {
    font-size: 13.5px;
    font-weight: 800;
    color: var(--cd-text-main, #f1f5f9);
    margin-bottom: 2px;
}

.cd-action .cd-txt em {
    font-style: normal;
    font-size: 11.5px;
    color: var(--cd-text-muted, #94a3b8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    direction: ltr;
    text-align: right;
}

.cd-action .cd-arrow {
    flex: 0 0 auto;
    font-size: 11px;
    color: #64748b;
    transition: color 0.2s ease, transform 0.2s ease;
}

.cd-action:hover .cd-arrow {
    color: var(--cd-accent, #fbbf24);
    transform: translateX(-2px);
}

.contact-dock.cd-pos-right .cd-action:hover .cd-arrow {
    transform: translateX(2px);
}

/* ---------- Presence Schedule / Note Box ---------- */
.contact-dock-note {
    margin: 0;
    padding: 10px 16px 14px;
    font-size: 11.5px;
    color: #ffffff;
    line-height: 1.7;
    border-top: 1px dashed rgba(255, 255, 255, 0.12);
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.12);
}

.contact-dock-note i {
    color: var(--cd-accent, #fbbf24);
    font-size: 13px;
    flex-shrink: 0;
}

/* =============================================================================
   RESPONSIVE DESIGN (MOBILE & TABLET)
   ============================================================================= */

@media (max-width: 575px) {
    .contact-dock {
        bottom: 16px;
        gap: 10px;
    }

    .contact-dock.cd-pos-left {
        left: 16px;
    }

    .contact-dock.cd-pos-right {
        right: 16px;
    }

    /* Transform pill into circular 54x54px FAB button */
    .contact-dock-toggle {
        padding: 0;
        width: 54px;
        height: 54px;
        min-width: 54px;
        border-radius: 50%;
        justify-content: center;
        align-self: flex-start;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    }

    .contact-dock-toggle .cd-toggle-label {
        display: none !important;
    }

    .contact-dock-toggle .cd-ico-wrap {
        width: 24px;
        height: 24px;
    }

    .contact-dock-toggle .cd-toggle-ico,
    .contact-dock-toggle .cd-close-ico {
        font-size: 20px;
    }

    /* Responsive Panel Width & Safe Bounds */
    .contact-dock-panel {
        width: calc(100vw - 32px);
        max-width: calc(100vw - 32px);
        border-radius: 16px;
    }

    .contact-dock-actions {
        max-height: 320px;
        padding: 10px;
    }

    .cd-action {
        padding: 9px 12px;
    }
}

/* Fix for conflicting legacy docks if present */
#sepehran-compare-dock {
    display: none !important;
}
