/**
 * AkraTech AI Voice Agent Widget — Styles
 * Staging-only: staging.akratech.com
 */

/* ── Widget Root (Voice Agent — Bottom-Right Corner) ────────────────────── */
#akratech-ai-voice-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    transition: bottom 0.3s ease, right 0.3s ease;
}

/* ── Chatbot (Botpress) — Positioned to Bottom-Left Corner ─────────────── */
.bpFabWrapper,
div[class*="bpFabWrapper"],
[class*="bpFABWebchat"],
[class*="bpMessagePreview"] {
    left: 24px !important;
    right: auto !important;
}

@media (max-width: 480px) {
    #akratech-ai-voice-widget {
        bottom: 16px;
        right: 12px;
    }

    .bpFabWrapper,
    div[class*="bpFabWrapper"],
    [class*="bpFABWebchat"],
    [class*="bpMessagePreview"] {
        left: 12px !important;
        right: auto !important;
        bottom: 16px !important;
    }
}

/* ── Bubble / Trigger Button (Pill Launcher) ─────────────────────────────── */
#akratech-voice-bubble {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 18px 8px 10px;
    background: linear-gradient(135deg, #ffffff 0%, #f0f9ff 55%, #e0f2fe 100%);
    color: #0f172a;
    border: 1.5px solid #7dd3fc;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 8px 24px -4px rgba(14, 165, 233, 0.28), 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, border-color 0.2s ease;
    position: relative;
    overflow: visible;
}

#akratech-voice-bubble:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 12px 30px -4px rgba(14, 165, 233, 0.38), 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #38bdf8;
}

#akratech-voice-bubble:focus-visible {
    outline: 3px solid #38bdf8;
    outline-offset: 3px;
}

#akratech-voice-bubble:active { transform: translateY(0); }

/* Avatar Circle */
.akra-avatar-wrap {
    position: relative;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.akra-avatar-circle {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
}

.akra-avatar-svg {
    width: 38px;
    height: 38px;
    display: block;
    border-radius: 50%;
}

.akra-online-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    background: #10b981;
    border: 2px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.6);
}

/* Two-Line Text */
.akra-text-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    line-height: 1.2;
    user-select: none;
}

.akra-subtitle {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.07em;
    color: #0284c7;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.akra-sparkle-icon {
    width: 11px;
    height: 11px;
    color: #0ea5e9;
    flex-shrink: 0;
}

.akra-title {
    font-size: 14.5px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.01em;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Pulse ring */
.akra-pulse {
    position: absolute;
    inset: -3px;
    border-radius: 50px;
    border: 2px solid rgba(56, 189, 248, 0.5);
    animation: akraPulse 2.2s ease-out infinite;
    pointer-events: none;
}

#akratech-voice-bubble.open .akra-pulse { display: none; }

@keyframes akraPulse {
    0%   { transform: scale(1); opacity: 0.75; }
    70%  { transform: scale(1.1); opacity: 0; }
    100% { transform: scale(1.1); opacity: 0; }
}

/* ── Panel Container ─────────────────────────────────────────────────────── */
#akratech-voice-panel {
    position: absolute;
    bottom: calc(100% + 14px);
    right: 0;
    width: 380px;
    max-width: calc(100vw - 32px);
    background: linear-gradient(180deg, #f0f7ff 0%, #ffffff 130px, #ffffff 100%);
    border: 1.5px solid #dbeafe;
    border-radius: 24px;
    box-shadow:
        0 20px 45px -10px rgba(15, 23, 42, 0.16),
        0 8px 20px -4px rgba(14, 165, 233, 0.1),
        0 0 0 1px rgba(224, 242, 254, 0.8);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: akraPanelIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform-origin: bottom right;
    z-index: 10000;
}

@keyframes akraPanelIn {
    from { opacity: 0; transform: scale(0.88) translateY(12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Top Header Bar ──────────────────────────────────────────────────────── */
.akra-panel-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px 8px;
    background: transparent;
}

.akra-connection-indicator {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: #ffffff;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid #e0f2fe;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.akra-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

.akra-status-dot.idle       { background: #94a3b8; }
.akra-status-dot.connecting { background: #f59e0b; animation: akraBlink 0.8s ease-in-out infinite alternate; }
.akra-status-dot.listening  { background: #10b981; box-shadow: 0 0 6px rgba(16, 185, 129, 0.7); }
.akra-status-dot.speaking   { background: #0284c7; box-shadow: 0 0 6px rgba(2, 132, 199, 0.7); animation: akraBlink 0.5s ease-in-out infinite alternate; }
.akra-status-dot.error      { background: #ef4444; }

@keyframes akraBlink {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0.35; transform: scale(0.9); }
}

#akratech-voice-status-text {
    font-size: 11.5px;
    font-weight: 600;
    color: #475569;
    letter-spacing: 0.01em;
}

#akratech-voice-close {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    color: #64748b;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    padding: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

#akratech-voice-close:hover {
    background: #f1f5f9;
    color: #0f172a;
    transform: scale(1.05);
}

#akratech-voice-close:focus-visible {
    outline: 2px solid #38bdf8;
    outline-offset: 2px;
}

/* ── Hero / Centered Avatar & Titles ─────────────────────────────────────── */
.akra-panel-hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 4px 20px 14px;
}

.akra-hero-avatar-wrap {
    position: relative;
    margin-bottom: 10px;
}

.akra-hero-avatar {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    position: relative;
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
    box-shadow: 0 8px 22px -4px rgba(14, 165, 233, 0.32);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3px;
    border: 2px solid #ffffff;
}

.akra-hero-avatar-svg {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 50%;
}

.akra-hero-online-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #10b981;
    border: 2.5px solid #ffffff;
    border-radius: 50%;
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.7);
}

.akra-hero-title {
    margin: 0 0 3px;
    font-size: 18.5px;
    font-weight: 700;
    color: #0f172a;
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.akra-hero-subtitle {
    margin: 0;
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
    line-height: 1.4;
}

/* ── Large Rounded Status / Message Box ──────────────────────────────────── */
.akra-message-card {
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 18px;
    margin: 0 18px 16px;
    padding: 16px 16px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 120px;
    justify-content: center;
    transition: border-color 0.2s ease, background 0.2s ease;
    position: relative;
}

.akra-message-card.state-idle {
    background: #f8fafc;
    border-color: #e2e8f0;
}

.akra-message-card.state-connecting {
    background: #fffbeb;
    border-color: #fde68a;
}

.akra-message-card.state-listening {
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.akra-message-card.state-speaking {
    background: #f0f9ff;
    border-color: #bae6fd;
}

.akra-message-card.state-error,
.akra-message-card.state-denied {
    background: #fef2f2;
    border-color: #fecaca;
}

.akra-card-header {
    margin-bottom: 6px;
}

.akra-card-icon {
    font-size: 26px;
    line-height: 1;
    display: inline-block;
}

.akra-card-text {
    font-size: 13.5px;
    color: #334155;
    line-height: 1.5;
    margin: 0 0 12px;
    max-width: 95%;
}

.akra-card-text strong {
    color: #0f172a;
    font-weight: 600;
}

/* ── Audio Visualizer (Wave Bars) ────────────────────────────────────────── */
.akra-visualizer {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 28px;
    margin-bottom: 12px;
}

.akra-visualizer.active,
.akra-visualizer.connecting {
    display: flex;
}

.akra-visualizer span {
    display: block;
    width: 4px;
    height: 8px;
    background: linear-gradient(180deg, #38bdf8 0%, #0284c7 100%);
    border-radius: 4px;
    transition: height 0.15s ease;
}

.akra-visualizer.connecting span {
    animation: akraBarSlow 1.4s ease-in-out infinite alternate;
}

.akra-visualizer.active span:nth-child(1) { animation: akraBar 1.2s ease-in-out 0.0s infinite alternate; }
.akra-visualizer.active span:nth-child(2) { animation: akraBar 1.2s ease-in-out 0.2s infinite alternate; }
.akra-visualizer.active span:nth-child(3) { animation: akraBar 1.2s ease-in-out 0.4s infinite alternate; }
.akra-visualizer.active span:nth-child(4) { animation: akraBar 1.2s ease-in-out 0.2s infinite alternate; }
.akra-visualizer.active span:nth-child(5) { animation: akraBar 1.2s ease-in-out 0.0s infinite alternate; }

@keyframes akraBar     { from { height: 6px; }  to { height: 26px; } }
@keyframes akraBarSlow { from { height: 6px; }  to { height: 14px; } }

/* ── Card Action Buttons ─────────────────────────────────────────────────── */
.akra-card-actions {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.akra-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 50px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.15s ease;
    white-space: nowrap;
    text-decoration: none;
}

.akra-btn:focus-visible {
    outline: 3px solid #38bdf8;
    outline-offset: 2px;
}

.akra-btn-primary {
    background: linear-gradient(135deg, #0284c7 0%, #0057b8 100%);
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.35);
    width: 100%;
    max-width: 240px;
}

.akra-btn-primary:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(2, 132, 199, 0.45);
    filter: brightness(1.05);
}

.akra-btn-primary:active:not(:disabled) { transform: translateY(0); }

.akra-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.akra-btn-secondary {
    background: #ffffff;
    color: #0284c7;
    border: 1.5px solid #bae6fd;
    box-shadow: 0 2px 6px rgba(2, 132, 199, 0.1);
    width: 100%;
    max-width: 220px;
}

.akra-btn-secondary:hover:not(:disabled) {
    background: #f0f9ff;
    border-color: #38bdf8;
    transform: translateY(-1px);
}

.akra-btn-secondary:active:not(:disabled) { transform: translateY(0); }

/* ── Bottom Control Bar ──────────────────────────────────────────────────── */
.akra-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px 14px;
    background: #ffffff;
    border-top: 1px solid #f1f5f9;
    gap: 12px;
}

.akra-mic-status-wrapper {
    display: flex;
    align-items: center;
}

.akra-mic-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 13px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 12.5px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
}

.akra-mic-toggle-btn.active {
    background: #ecfdf5;
    border-color: #a7f3d0;
    color: #047857;
}

.akra-mic-toggle-btn.muted {
    background: #fef3c7;
    border-color: #fde68a;
    color: #b45309;
}

.akra-mic-toggle-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.akra-mic-toggle-btn:disabled {
    cursor: default;
    opacity: 0.8;
}

.akra-end-call-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #ef4444;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.28);
}

.akra-end-call-btn:hover:not(:disabled) {
    background: #dc2626;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

.akra-end-call-btn:active:not(:disabled) { transform: translateY(0); }

.akra-end-call-btn:disabled {
    background: #e2e8f0;
    color: #94a3b8;
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
}

/* ── Mobile Responsive ───────────────────────────────────────────────────── */
@media (max-width: 480px) {
    #akratech-ai-voice-widget {
        bottom: 16px;
        right: 12px;
    }

    #akratech-voice-bubble {
        padding: 6px 14px 6px 8px;
        gap: 8px;
    }

    .akra-avatar-circle {
        width: 34px;
        height: 34px;
    }

    .akra-avatar-svg {
        width: 34px;
        height: 34px;
    }

    .akra-subtitle {
        font-size: 9px;
    }

    .akra-title {
        font-size: 13.5px;
    }

    #akratech-voice-panel {
        right: -8px;
        width: calc(100vw - 24px);
        max-width: 100vw;
        bottom: calc(100% + 10px);
        border-radius: 20px;
    }

    .akra-hero-avatar {
        width: 58px;
        height: 58px;
    }

    .akra-hero-title {
        font-size: 17px;
    }

    .akra-hero-subtitle {
        font-size: 11.5px;
    }

    .akra-message-card {
        margin: 0 14px 14px;
        padding: 14px 12px 16px;
    }

    .akra-bottom-bar {
        padding: 10px 14px 12px;
    }
}

@media (max-width: 340px) {
    .akra-subtitle { display: none; }
    #akratech-voice-bubble {
        padding: 6px 10px 6px 6px;
    }
}
