/* Call Flow Builder Styles */

/* ==========================================================================
   MAIN CONTAINER
   ========================================================================== */

.callflow-container {
    display: flex;
    gap: 20px;
    padding: 20px;
    min-height: calc(100vh - 100px);
}

/* ==========================================================================
   LEFT COLUMN - OPTIONS PALETTE
   ========================================================================== */

.options-palette {
    width: 250px;
    flex-shrink: 0;
    background: linear-gradient(180deg, #f9fbfd 0%, #f2f6fb 100%);
    border: 1px solid #d6e2f1;
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    height: fit-content;
    position: sticky;
    top: 20px;
    -webkit-user-select: none;
    user-select: none;
}

.options-palette h3 {
    margin-top: 0;
    margin-bottom: 25px;
    font-size: 18px;
    color: #333;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Scroll wrapper - column on desktop */
.options-scroll-wrapper {
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
    touch-action: pan-x pan-y;
}

.option-item {
    background: #fff;
    border: 1px solid #d6e2f1;
    border-radius: 50px;
    padding-top: 8px;
    padding-bottom: 8px;
    padding-left: 20px;
    margin-bottom: 12px;
    cursor: grab;
    transition: all 0.25s ease;
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.06);
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}
.option-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.option-item:last-child {
    margin-bottom: 0;
}

.option-item:hover {
    background: #f0f6ff;
    border-color: #4dbed0;
    box-shadow: 0 4px 12px rgba(77, 190, 208, 0.2);
}

.option-item:active {
    cursor: grabbing;
}

.option-item.dragging {
    opacity: 0.5;
}

.option-item strong {
    font-size: 13px;
    font-weight: 600;
    color: #1f2937;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.option-item p {
    margin: 5px 0 0 0;
    font-size: 12px;
    color: #666;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* ==========================================================================
   RIGHT COLUMN - FLOW CHART
   ========================================================================== */

.flow-chart {
    flex: 1;
    background: #fdfefe;
    border: 1px solid #d6e2f1;
    border-radius: 18px;
    padding: 20px;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.flow-chart h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 18px;
    color: #333;
}

.flow-chart.drag-over {
    background: #eef5ff;
    border-color: #4dbed0;
}

/* ==========================================================================
   FLOW ITEMS
   ========================================================================== */

.flow-item {
    background: #fff;
    border: 1px solid #d6e2f1;
    border-radius: 50px;
    padding: 8px 11px;
    position: relative;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 2;
}

.flow-item.locked {
    border-color: #c7ced6;
    background: #f8fafc;
}

.flow-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.12);
    border-color: #4dbed0;
}

.flow-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.flow-item-title {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 14px;
    color: #1f2937;
    letter-spacing: 0.01em;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.flow-item-title .icon {
    font-size: 1.4rem;
    font-weight: 700;
}

.flow-item-title .icon.grey { color: #6c757d; }
.flow-item-title .icon.orange { color: #fd7e14; }
.flow-item-title .icon.cyan { color: #0dcaf0; }
.flow-item-title .icon.dblue { color: #0b5ee8; }
.flow-item-title .icon.purple { color: #a855f7; }
.flow-item-title .icon.green { color: #22c55e; }
.flow-item-title .icon.red { color: #fc05ec; }
.flow-item-title .icon.blue { color: #3b82f6; }
.flow-item-title .icon.lgreen { color: #4af61c; }

.flow-item-actions {
    display: flex;
    gap: 8px;
}

.flow-item-actions button {
    padding: 6px 10px;
    border: 1px solid #d6e2f1;
    background: #f8fafc;
    border-radius: 50px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: #1f2937;
    transition: all 0.2s ease;
}

.flow-item-actions button:hover {
    background: #eef5ff;
    border-color: #4dbed0;
}

.flow-item-actions button.remove {
    color: #dc2626;
    border-color: #f9d4d4;
}

.flow-item-actions button.remove:hover {
    background: #fff1f2;
    border-color: #dc2626;
}

.flow-item-actions button.settings {
    color: #4dc7fa;
    border-color: #d6e2f1;
    font-size: 14px;
    padding: 4px 10px;
}

.flow-item-actions button.settings:hover {
    background: #e3f2fd;
}

.flow-item.dragging-reorder {
    opacity: 0.5;
    border-style: dashed;
    pointer-events: none;
}

/* ==========================================================================
   ICON COLORS
   ========================================================================== */

.icon-grey { color: #6c757d; }
.icon-orange { color: #fd7e14; }
.icon-cyan { color: #0dcaf0; }
.icon-dblue { color: #0b5ee8; }
.icon-purple { color: #a855f7; }
.icon-green { color: #22c55e; }
.icon-red { color: #fc05ec; }
.icon-blue { color: #6c66f1; }
.icon-lgreen { color: #4af61c; }

/* ==========================================================================
   CONNECTOR LINES
   ========================================================================== */

.flow-connector {
    width: 2px;
    height: 16px;
    background: #cfd8e3;
    margin: 9px auto;
    position: relative;
}

.flow-connector::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid #cfd8e3;
}

/* ==========================================================================
   BUSINESS HOURS BRANCHES
   ========================================================================== */

.branch-container {
    display: flex;
    gap: 32px;
    margin-top: 40px;
    position: relative;
}

.branch-container::before {
    content: '';
    position: absolute;
    top: -40px;
    left: 50%;
    width: 2px;
    height: 32px;
    background: #cfd8e3;
}

.branch-container::after {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 8px solid #cfd8e3;
}

.branch {
    flex: 1;
    border: 1px dashed #d6e2f1;
    border-radius: 14px;
    padding: 16px;
    background: #fff;
    min-height: 200px;
    box-shadow: inset 0 0 0 1px #eef2f7;
}

.branch-header {
    font-weight: 700;
    color: #0f172a;
    padding: 8px 12px;
    border-radius: 25px;
    text-align: center;
    background: #eef2f7;
    border: 1px solid #d6e2f1;
}

.branch.open .branch-header {
    background: rgba(0, 212, 170, 0.15);
    border-color: rgba(0, 212, 170, 0.35);
    color: #00b894;
}

.branch.closed .branch-header {
    background: rgba(255, 107, 107, 0.15);
    border-color: rgba(255, 107, 107, 0.35);
    color: #ff6b6b;
}

.branch.drag-over {
    background: #eef5ff;
    border-color: #4dbed0;
    border-style: solid;
}

.branch .flow-item {
    margin-bottom: 0px;
}

.bg-green {
    background: rgba(4, 247, 199, 0.01);
}

.bg-red {
    background: rgba(245, 25, 5, 0.01);
}

/* ==========================================================================
   DRAG AND DROP STATES
   ========================================================================== */

.drag-placeholder {
    background: #f0f6ff;
    border: 2px dashed #4dbed0;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    min-height: 60px;
    opacity: 0.65;
    transition: all 0.2s ease;
    pointer-events: none;
}

.drag-placeholder::after {
    content: 'Drop here';
    display: block;
    text-align: center;
    color: #2563eb;
    font-style: italic;
    font-size: 14px;
}

.drop-indicator {
    height: 4px;
    background: #4dbed0;
    margin: 10px 0;
    border-radius: 2px;
    transition: all 0.2s ease;
}

/* ==========================================================================
   SORTABLEJS CLASSES
   ========================================================================== */

.sortable-ghost {
    opacity: 0.4 !important;
    background: #d0e8ff !important;
    border: 2px dashed #4dbed0 !important;
}

.sortable-chosen {
    opacity: 1 !important;
}

.sortable-drag {
    opacity: 0 !important;
}

.sortable-fallback {
    position: fixed !important;
    opacity: 1 !important;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35) !important;
    z-index: 2147483647 !important;
    pointer-events: none !important;
    background: white !important;
    border-radius: 12px !important;
    border: 2px solid #4dbed0 !important;
    transform: scale(1.05) rotate(2deg) !important;
}

/* ==========================================================================
   DROP ZONE HIGHLIGHT (for custom touch drag)
   ========================================================================== */

.drop-highlight {
    background: #e8f4fd !important;
    border-color: #4dbed0 !important;
    box-shadow: inset 0 0 0 2px #4dbed0 !important;
}

.flow-content.drop-highlight {
    background: #e8f4fd !important;
}

.branch.drop-highlight {
    background: #e8f4fd !important;
    border-style: solid !important;
}

/* ==========================================================================
   EMPTY STATE & HINTS
   ========================================================================== */

.empty-state {
    text-align: center;
    color: #999;
    padding: 0px 20px 30px 20px;
    font-style: italic;
}

/* Desktop drag hint / Mobile tap hint toggle */
.desktop-drag-hint {
    display: block;
}

.mobile-drag-hint {
    display: none;
}

/* Mobile tap hint in palette */
.mobile-tap-hint {
    display: none;
    font-size: 13px;
    color: #64748b;
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #f0f6ff;
    border-radius: 8px;
    border: 1px solid #d6e2f1;
    line-height: 1.4;
}

.mobile-tap-hint i {
    color: #4dbed0;
}

/* ==========================================================================
   LOCK & REORDER INDICATORS
   ========================================================================== */

.lock-indicator {
    display: inline-block;
    margin-left: 8px;
    color: #9e9e9e;
    font-size: 14px;
}

/*.reorder-handle {
    cursor: move;
    color: #94a3b8;
    margin-right: 8px;
    font-size: 20px;
    padding-bottom: 5px;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

*/

/* ==========================================================================
   BACK BUTTON
   ========================================================================== */

.back-btn-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background-color: #4dcbdf;
    border-radius: 50%;
    color: #fff;
    text-decoration: none;
    font-size: 18px;
    transition: background-color 0.2s ease, transform 0.2s ease;
    box-shadow: 0 2px 5px rgba(33, 150, 243, 0.3);
}

@media (max-width: 767.98px) {
    .back-btn-circle {
        width: 22px;
        height: 22px;
        font-size: 12px;
    }
}
.back-btn-circle:hover {
    background-color: #209bb9;
    color: #fff;
    transform: scale(1.05);
}

.back-btn-circle:active {
    transform: scale(0.95);
}

/* ==========================================================================
   SAVE BAR
   ========================================================================== */

.callflow-save-bar {
    display: flex;
    justify-content: center;
    padding: 20px 0;
    margin-top: 30px;
    border-top: 1px solid #e9ecef;
}

.callflow-save-bar .btn {
    padding: 12px 40px;
    font-size: 16px;
    font-weight: 500;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

/* ==========================================================================
   MOBILE/TABLET LAYOUT - Stacked view up to 1024px
   ========================================================================== */

@media (max-width: 1024px) {
    
    .callflow-container {
        flex-direction: column;
        gap: 16px;
        padding: 12px;
        min-height: auto;
    }
    
    .options-palette {
        width: 100%;
        position: relative;
        top: 0;
        padding: 12px;
        overflow: visible;
        height: auto;
    }
    
    .options-palette h3 {
        font-size: 14px;
        margin-bottom: 12px;
        color: #666;
    }
    
    .options-scroll-wrapper {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: scroll;
        -webkit-overflow-scrolling: touch;
        gap: 10px;
        padding-bottom: 8px;
        scrollbar-width: none;
        padding-right: 40px;
        touch-action: pan-x pan-y;
    }
    
    .options-scroll-wrapper::-webkit-scrollbar {
        display: none;
    }
    
    .option-item {
        flex: 0 0 auto;
        min-width: 130px;
        max-width: 145px;
        padding: 10px 14px;
        margin-bottom: 0;
        border-radius: 12px;
        cursor: pointer;
    }
    
    .option-item:hover {
        box-shadow: none;
    }
    
    .option-item strong {
        font-size: 12px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        display: block;
    }
    
    .option-item p {
        font-size: 10px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin: 4px 0 0 0;
    }
    
    .option-item i {
        font-size: 14px;
    }
    
    .options-palette::after {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 50px;
        background: linear-gradient(to right, transparent, #f2f6fb);
        pointer-events: none;
        z-index: 2;
        border-radius: 0 18px 18px 0;
    }
    
    .flow-chart {
        min-height: 55vh;
        padding: 16px;
    }
    
    .flow-chart h3 {
        font-size: 16px;
        margin-bottom: 12px;
    }
    
    .branch-container {
        flex-direction: column;
        gap: 16px;
        margin-top: 30px;
    }
    
    .branch-container::before {
        top: -30px;
        height: 22px;
    }
    
    .branch {
        min-height: 150px;
        padding: 12px;
    }
    
    .branch-header {
        font-size: 13px;
        padding: 6px 12px;
    }
    
    .flow-item {
        padding: 10px 14px;
        border-radius: 30px;
    }
    
    .flow-item-title {
        font-size: 13px;
        gap: 6px;
    }
    
    .flow-item-actions button {
        padding: 4px 8px;
        font-size: 11px;
    }
    
/*    .reorder-handle {
        font-size: 16px;
        margin-right: 6px;
    }
    
*/    
    
    #saveCallFlowButton {
        width: 100%;
    }
    
    .drag-placeholder {
        min-height: 50px;
        padding: 10px;
    }
    
    .empty-state {
        padding: 0 10px 20px 10px;
        font-size: 13px;
    }
    
    /* Hint visibility for mobile/tablet */
    .mobile-tap-hint {
        display: block;
    }
    
    .desktop-drag-hint {
        display: none;
    }
    
    .mobile-drag-hint {
        display: block;
    }
}

/* ==========================================================================
   VERY SMALL SCREENS (375px and below)
   ========================================================================== */

@media (max-width: 375px) {
    .callflow-container {
        padding: 8px;
    }
    
    .options-palette {
        padding: 10px;
    }
    
    .option-item {
        min-width: 110px;
        max-width: 120px;
        padding: 8px 12px;
    }
    
    .option-item p {
        display: none;
    }
    
    .flow-chart {
        padding: 12px;
        min-height: 50vh;
    }
    
    .flow-item {
        padding: 8px 12px;
    }
    
    .flow-item-title {
        font-size: 12px;
    }
    
    .branch {
        padding: 10px;
        min-height: 120px;
    }
}

/* ==========================================================================
   DESKTOP LAYOUT (1025px and above)
   ========================================================================== */
@media (min-width: 1025px) {
    .options-palette {
        width: 250px;
    }
    
    .option-item {
        cursor: grab;
    }
    
    .option-item:hover {
        box-shadow: 0 4px 12px rgba(77, 190, 208, 0.2);
    }
    
    .available-options-inner {
        display: block;
    }
}

/* ==========================================================================
   MOBILE/TABLET LAYOUT (below 1025px)
   ========================================================================== */
@media (max-width: 1024px) {
    .available-options-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    
    .available-options-scroll::-webkit-scrollbar {
        display: none;
    }
    
    .available-options-inner {
        display: inline-flex;
        gap: 1rem;
    }
    
    .available-options-inner .option-item {
        flex-shrink: 0;
    }
}