/* SAKTI CRM - Custom Stylesheet (SB Admin 2 Theme Harmonization) */
:root {
    --sakti-primary: #4e73df;
    --sakti-primary-hover: #2e59d9;
    --sakti-accent: #36b9cc;
    --sakti-success: #1cc88a;
    --sakti-warning: #f6c23e;
    --sakti-danger: #e74a3b;
    --sakti-bg: #f8f9fc;
    --sakti-card-border: #e3e6f0;
}

body {
    font-family: 'Nunito', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #5a5c69;
    background-color: var(--sakti-bg);
}

.bg-gradient-sakti {
    background: linear-gradient(180deg, #4e73df 10%, #224abe 100%);
}

.btn-primary {
    background-color: var(--sakti-primary) !important;
    border-color: var(--sakti-primary) !important;
    color: #ffffff !important;
}

.btn-primary:hover, .btn-primary:focus {
    background-color: var(--sakti-primary-hover) !important;
    border-color: var(--sakti-primary-hover) !important;
    color: #ffffff !important;
}

.text-primary {
    color: var(--sakti-primary) !important;
}

.bg-primary {
    background-color: var(--sakti-primary) !important;
}

/* Subtle background fallbacks (BS5 to BS4) */
.bg-primary-subtle {
    background-color: rgba(78, 115, 223, 0.12) !important;
}
.bg-success-subtle {
    background-color: rgba(28, 200, 138, 0.12) !important;
}
.bg-info-subtle {
    background-color: rgba(54, 185, 204, 0.12) !important;
}
.bg-warning-subtle {
    background-color: rgba(246, 194, 62, 0.15) !important;
}
.bg-danger-subtle {
    background-color: rgba(231, 74, 59, 0.12) !important;
}

.border-primary {
    border-color: var(--sakti-primary) !important;
}

/* Flex Gap polyfills */
.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }
.gap-4 { gap: 1.5rem !important; }

/* Margin/Padding polyfills for me/ms (BS5 -> BS4) */
.me-1 { margin-right: 0.25rem !important; }
.me-2 { margin-right: 0.5rem !important; }
.me-3 { margin-right: 1rem !important; }
.me-4 { margin-right: 1.5rem !important; }
.me-auto { margin-right: auto !important; }

.ms-1 { margin-left: 0.25rem !important; }
.ms-2 { margin-left: 0.5rem !important; }
.ms-3 { margin-left: 1rem !important; }
.ms-4 { margin-left: 1.5rem !important; }
.ms-auto { margin-left: auto !important; }

.pe-1 { padding-right: 0.25rem !important; }
.pe-2 { padding-right: 0.5rem !important; }
.pe-3 { padding-right: 1rem !important; }
.ps-1 { padding-left: 0.25rem !important; }
.ps-2 { padding-left: 0.5rem !important; }
.ps-3 { padding-left: 1rem !important; }

/* Font size polyfills */
.fs-1 { font-size: 2.25rem !important; }
.fs-2 { font-size: 1.85rem !important; }
.fs-3 { font-size: 1.5rem !important; }
.fs-4 { font-size: 1.25rem !important; }
.fs-5 { font-size: 1rem !important; }
.fs-6 { font-size: 0.875rem !important; }

/* Font weight polyfills */
.fw-bold { font-weight: 700 !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-medium { font-weight: 500 !important; }
.fw-light { font-weight: 300 !important; }

/* Rounded polyfills */
.rounded-pill { border-radius: 50rem !important; }
.rounded-circle { border-radius: 50% !important; }
.rounded-1 { border-radius: 0.2rem !important; }
.rounded-2 { border-radius: 0.35rem !important; }
.rounded-3 { border-radius: 0.5rem !important; }
.rounded-4 { border-radius: 0.75rem !important; }

/* Alert close button compatibility */
.btn-close {
    box-sizing: content-box;
    width: 1em;
    height: 1em;
    padding: .25em .25em;
    color: #000;
    background: transparent;
    border: 0;
    opacity: .5;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}
.btn-close::before {
    content: "×";
    font-size: 1.4rem;
    line-height: 1;
}
.btn-close:hover {
    opacity: .75;
}

/* Card Improvements */
.card {
    border: 1px solid var(--sakti-card-border);
    border-radius: 0.35rem;
    box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
    background-color: #ffffff;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.metric-card {
    border-left: 0.25rem solid var(--sakti-primary);
}

.metric-card.success {
    border-left-color: var(--sakti-success);
}

.metric-card.warning {
    border-left-color: var(--sakti-warning);
}

.metric-card.danger {
    border-left-color: var(--sakti-danger);
}

/* Funnel Steps Indicator */
.funnel-container {
    display: flex;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    gap: 0.5rem;
}

.funnel-step {
    flex: 1;
    min-width: 140px;
    padding: 0.75rem;
    border-radius: 0.35rem;
    background-color: #eaecf4;
    text-align: center;
    position: relative;
    font-weight: 600;
    font-size: 0.8rem;
    color: #6e707e;
}

.funnel-step.completed {
    background-color: rgba(28, 200, 138, 0.18);
    color: #169b6b;
}

.funnel-step.active {
    background-color: rgba(78, 115, 223, 0.15);
    color: var(--sakti-primary);
    box-shadow: 0 0 0 2px var(--sakti-primary);
}

/* Timeline Components */
.timeline-list {
    position: relative;
    padding-left: 2rem;
    list-style: none;
}

.timeline-list::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0.75rem;
    width: 2px;
    background-color: #dee2e6;
}

.timeline-item {
    position: relative;
    margin-bottom: 1.5rem;
}

.timeline-badge {
    position: absolute;
    left: -2rem;
    top: 0.25rem;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background-color: var(--sakti-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    box-shadow: 0 0 0 4px #ffffff;
}

.timeline-badge.voice {
    background-color: #e74a3b;
}

.timeline-badge.conversion {
    background-color: var(--sakti-success);
}

/* Voice Recorder Component */
.voice-recorder-box {
    background: rgba(231, 74, 59, 0.05);
    border: 2px dashed rgba(231, 74, 59, 0.35);
    border-radius: 0.5rem;
    padding: 1.25rem;
    text-align: center;
}

.pulse-recording {
    animation: pulse-red 1.5s infinite;
}

@keyframes pulse-red {
    0% {
        box-shadow: 0 0 0 0 rgba(231, 74, 59, 0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(231, 74, 59, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(231, 74, 59, 0);
    }
}

/* Trinary Network Tree Styling */
.trinary-tree {
    overflow: hidden;
    padding: 1.5rem 0;
    text-align: center;
}

#treeViewport {
    user-select: none;
    background: radial-gradient(#d1d3e2 1.5px, transparent 1.5px);
    background-size: 24px 24px;
}

.trinary-tree-wrapper {
    display: inline-flex;
    justify-content: center;
    padding: 24px;
}

.tree-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.tree-node-card {
    width: 170px;
    margin: 0 10px;
    border: 2px solid #e3e6f0;
    border-radius: 0.5rem;
    background: #ffffff;
    color: #212529;
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
    display: inline-block;
    padding: 0.75rem;
    cursor: pointer;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    z-index: 2;
    position: relative;
}

.tree-node-card:hover {
    transform: translateY(-3px);
    border-color: var(--sakti-primary);
    box-shadow: 0 8px 20px rgba(0,0,0,0.14);
}

.tree-node-card.pos-1 {
    border-top: 4px solid #36b9cc; /* Left - Vibrant Cyan */
}
.tree-node-card.pos-2 {
    border-top: 4px solid #1cc88a; /* Center - Emerald Green */
}
.tree-node-card.pos-3 {
    border-top: 4px solid #6f42c1; /* Right - Vibrant Purple */
}

.tree-node-card.pos-root {
    border-top: 4px solid #f6c23e; /* Root - Gold/Amber */
}

.tree-node-card.vacant {
    background: #f8f9fc;
    border: 2px dashed #d1d3e2;
    cursor: default;
    opacity: 0.75;
}

/* Tree Connectors: Parent down stem */
.tree-stem-down {
    width: 4px;
    height: 22px;
    margin: 0 auto;
    position: relative;
    z-index: 2;
    border-radius: 2px;
}

/* Tree Children Container */
.tree-children-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.tree-child-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-width: 190px;
    padding-top: 22px;
}

/* Left horizontal arm */
.tree-child-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 50%;
    height: 4px;
    background: #94a3b8;
    border-radius: 2px 0 0 2px;
    z-index: 1;
}

/* Right horizontal arm */
.tree-child-wrapper::after {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    right: 0;
    height: 4px;
    background: #94a3b8;
    border-radius: 0 2px 2px 0;
    z-index: 1;
}

.tree-child-wrapper:first-child::before { display: none; }
.tree-child-wrapper:last-child::after { display: none; }
.tree-child-wrapper:only-child::before,
.tree-child-wrapper:only-child::after { display: none; }

.tree-v-drop {
    width: 4px;
    height: 22px;
    border-radius: 2px;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 3;
}

.tree-v-drop-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid;
    position: absolute;
    top: -3px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 4;
    box-shadow: 0 0 4px rgba(0,0,0,0.15);
}

/* Mobile Bottom Navigation */
.mobile-bottom-nav {
    z-index: 1040;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.08);
    background-color: #ffffff !important;
    border-top: 1px solid #e3e6f0;
}

.mobile-bottom-nav .nav-link {
    padding: 0.25rem 0.5rem;
}

/* Custom Audio Player */
audio {
    width: 100%;
    height: 38px;
    border-radius: 20px;
}
