/* ═══════════════════════════════════════════════════════════════
 * CipherChat — Premium Glassmorphism Chat Widget
 * Scoped to #cipherchat-widget to prevent global CSS conflicts.
 * ═══════════════════════════════════════════════════════════════ */

#cipherchat-widget {
    --cc-bg-primary: #0a0e1a;
    --cc-bg-glass: rgba(15, 23, 42, 0.88);
    --cc-bg-glass-light: rgba(30, 41, 59, 0.6);
    --cc-accent-primary: #00d4ff;
    --cc-accent-secondary: #7c3aed;
    --cc-accent-glow: rgba(0, 212, 255, 0.15);
    --cc-accent-glow-strong: rgba(0, 212, 255, 0.3);
    --cc-text-primary: #f1f5f9;
    --cc-text-secondary: #94a3b8;
    --cc-text-muted: #64748b;
    --cc-border: rgba(255, 255, 255, 0.08);
    --cc-border-hover: rgba(255, 255, 255, 0.15);
    --cc-font-display: 'Syne', sans-serif;
    --cc-font-body: 'DM Sans', sans-serif;
    --cc-radius: 20px;
    --cc-radius-sm: 12px;
    --cc-shadow: 0 25px 60px rgba(0, 0, 0, 0.5), 0 0 40px rgba(0, 212, 255, 0.05);
    --cc-transition: cubic-bezier(0.34, 1.56, 0.64, 1);

    font-family: var(--cc-font-body);
    font-size: 14px;
    line-height: 1.5;
    color: var(--cc-text-primary);
    -webkit-font-smoothing: antialiased;
    position: fixed;
    z-index: 999999;
    box-sizing: border-box;
}

#cipherchat-widget *,
#cipherchat-widget *::before,
#cipherchat-widget *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Position */
#cipherchat-widget.cc-widget--bottom-right {
    bottom: 24px;
    right: 24px;
}

#cipherchat-widget.cc-widget--bottom-left {
    bottom: 24px;
    left: 24px;
}

/* ═══════════ LAUNCHER ═══════════ */

.cc-launcher {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cc-accent-primary), var(--cc-accent-secondary));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: 0 8px 32px rgba(0, 212, 255, 0.3), 0 0 0 0 rgba(0, 212, 255, 0.4);
    transition: transform 0.3s var(--cc-transition), box-shadow 0.3s ease;
    color: #fff;
    outline: none;
}

.cc-launcher:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(0, 212, 255, 0.4), 0 0 20px rgba(124, 58, 237, 0.3);
}

.cc-launcher:active {
    transform: scale(0.95);
}

.cc-launcher-icon {
    width: 28px;
    height: 28px;
    position: relative;
    z-index: 2;
}

.cc-launcher-ring {
    position: absolute;
    inset: -4px;
    border: 2px solid rgba(0, 212, 255, 0.3);
    border-radius: 50%;
    animation: cc-ring-pulse 4s ease-in-out infinite;
}

.cc-launcher-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: rgba(0, 212, 255, 0.2);
    animation: cc-pulse 4s ease-in-out infinite;
    pointer-events: none;
}

.cc-launcher.cc-hidden {
    display: none;
}

@keyframes cc-ring-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.15);
        opacity: 0.5;
    }
}

@keyframes cc-pulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.6;
    }

    50% {
        transform: scale(1.6);
        opacity: 0;
    }
}

/* ═══════════ PANEL ═══════════ */

.cc-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--cc-bg-glass);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid var(--cc-border);
    border-radius: var(--cc-radius);
    box-shadow: var(--cc-shadow);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.35s ease, transform 0.4s var(--cc-transition), visibility 0.35s;
    overflow: hidden;
}

.cc-widget--bottom-left .cc-panel {
    right: auto;
    left: 0;
}

.cc-panel.cc-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ═══════════ HEADER ═══════════ */

.cc-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(10, 14, 26, 0.6);
    border-bottom: 1px solid var(--cc-border);
    flex-shrink: 0;
}

.cc-avatar {
    position: relative;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.cc-avatar-glow {
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: conic-gradient(from 0deg, var(--cc-accent-primary), var(--cc-accent-secondary), var(--cc-accent-primary));
    opacity: 0.5;
    animation: cc-avatar-spin 6s linear infinite;
}

.cc-avatar-img {
    position: relative;
    z-index: 1;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--cc-bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.cc-avatar-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.cc-avatar-img svg {
    width: 24px;
    height: 24px;
}

/* Persona lock shimmer (gold) */
.cc-avatar.cc-persona-locked .cc-avatar-glow {
    background: conic-gradient(from 0deg, #f59e0b, #fbbf24, #f59e0b);
    opacity: 0.7;
}

@keyframes cc-avatar-spin {
    to {
        transform: rotate(360deg);
    }
}

.cc-header-info {
    flex: 1;
    min-width: 0;
}

.cc-name {
    font-family: var(--cc-font-display);
    font-weight: 700;
    font-size: 15px;
    display: block;
    color: var(--cc-text-primary);
}

.cc-status {
    font-size: 11px;
    color: var(--cc-text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.cc-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    display: inline-block;
    animation: cc-dot-blink 2s infinite;
}

@keyframes cc-dot-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.cc-minimize {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--cc-text-secondary);
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

.cc-minimize:hover {
    background: var(--cc-bg-glass-light);
    color: var(--cc-text-primary);
}

/* ═══════════ MESSAGES ═══════════ */

.cc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.cc-messages::-webkit-scrollbar {
    width: 4px;
}

.cc-messages::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.cc-message {
    display: flex;
    gap: 10px;
    max-width: 90%;
    animation: cc-msg-in 0.4s var(--cc-transition) both;
}

.cc-message--ai {
    align-self: flex-start;
}

.cc-message--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.cc-message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 13.5px;
    line-height: 1.6;
    word-wrap: break-word;
    position: relative;
}

.cc-message--ai .cc-message-bubble {
    background: var(--cc-bg-glass-light);
    border: 1px solid var(--cc-border);
    border-bottom-left-radius: 4px;
    color: var(--cc-text-primary);
}

.cc-message--user .cc-message-bubble {
    background: linear-gradient(135deg, var(--cc-accent-primary), var(--cc-accent-secondary));
    border-bottom-right-radius: 4px;
    color: #fff;
}

.cc-message-bubble p {
    margin: 0 0 8px;
}

.cc-message-bubble p:last-child {
    margin-bottom: 0;
}

.cc-message-bubble strong {
    color: var(--cc-accent-primary);
    font-weight: 600;
}

.cc-message-bubble ul,
.cc-message-bubble ol {
    margin: 4px 0;
    padding-left: 20px;
}

.cc-message-bubble li {
    margin-bottom: 2px;
}

.cc-message-bubble code {
    background: rgba(0, 212, 255, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.cc-message-sources {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid var(--cc-border);
    font-size: 11px;
    color: var(--cc-text-muted);
}

.cc-message-sources a {
    color: var(--cc-accent-primary);
    text-decoration: none;
    transition: color 0.2s;
}

.cc-message-sources a:hover {
    color: #fff;
    text-decoration: underline;
}

@keyframes cc-msg-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Typing Indicator */
.cc-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

.cc-typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cc-accent-primary);
    animation: cc-typing-wave 1.4s ease-in-out infinite;
}

.cc-typing-dot:nth-child(2) {
    animation-delay: 0.15s;
}

.cc-typing-dot:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes cc-typing-wave {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* ═══════════ BUTTONS PANEL ═══════════ */

.cc-buttons-panel {
    padding: 0 20px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.4s ease, opacity 0.3s;
    opacity: 0;
}

.cc-buttons-panel.cc-buttons--visible {
    max-height: 300px;
    padding: 12px 20px;
    opacity: 1;
}

.cc-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    background: var(--cc-bg-glass-light);
    border: 1px solid var(--cc-border);
    border-radius: var(--cc-radius-sm);
    color: var(--cc-text-primary);
    font-family: var(--cc-font-body);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: left;
    animation: cc-btn-in 0.35s var(--cc-transition) both;
    outline: none;
}

.cc-btn:hover {
    border-color: var(--cc-accent-primary);
    background: var(--cc-accent-glow);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 212, 255, 0.15);
}

.cc-btn:active {
    transform: translateY(0);
}

.cc-btn--decision_maker:hover {
    border-color: #f59e0b;
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.15);
}

.cc-btn--tech_pro:hover {
    border-color: #3b82f6;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.15);
}

.cc-btn--generic:hover {
    border-color: #10b981;
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.15);
}

.cc-btn-arrow {
    font-size: 14px;
    opacity: 0.6;
    transition: opacity 0.2s, transform 0.2s;
}

.cc-btn:hover .cc-btn-arrow {
    opacity: 1;
    transform: translateX(2px);
}

@keyframes cc-btn-in {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ═══════════ INPUT AREA ═══════════ */

.cc-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 20px 16px;
    border-top: 1px solid var(--cc-border);
    background: rgba(10, 14, 26, 0.4);
    flex-shrink: 0;
}

#cc-input {
    flex: 1;
    background: var(--cc-bg-glass-light);
    border: 1px solid var(--cc-border);
    border-radius: var(--cc-radius-sm);
    padding: 10px 14px;
    color: var(--cc-text-primary);
    font-family: var(--cc-font-body);
    font-size: 13.5px;
    resize: none;
    outline: none;
    max-height: 100px;
    overflow-y: auto;
    transition: border-color 0.2s;
    line-height: 1.5;
}

#cc-input:focus {
    border-color: var(--cc-accent-primary);
}

#cc-input::placeholder {
    color: var(--cc-text-muted);
}

.cc-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--cc-accent-primary), var(--cc-accent-secondary));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    transition: transform 0.2s, box-shadow 0.2s;
    outline: none;
}

.cc-send:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(0, 212, 255, 0.3);
}

.cc-send:active {
    transform: scale(0.95);
}

.cc-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ═══════════ FOOTER ═══════════ */

.cc-footer {
    padding: 8px 20px;
    text-align: center;
    font-size: 10px;
    color: var(--cc-text-muted);
    border-top: 1px solid var(--cc-border);
    background: rgba(10, 14, 26, 0.3);
    flex-shrink: 0;
}

/* ═══════════ MOBILE ═══════════ */

@media (max-width: 480px) {

    #cipherchat-widget.cc-widget--bottom-right,
    #cipherchat-widget.cc-widget--bottom-left {
        bottom: 16px;
        right: 16px;
        left: auto;
    }

    .cc-panel {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        transform: translateY(100%);
    }

    .cc-panel.cc-open {
        transform: translateY(0);
    }
}

/* Inline embed mode */
.cc-embed .cc-panel {
    position: relative;
    bottom: auto;
    right: auto;
    opacity: 1;
    visibility: visible;
    transform: none;
    width: 100%;
    height: 600px;
}

.cc-embed--fullpage .cc-panel {
    height: calc(100vh - 100px);
    max-height: none;
}

.cc-embed .cc-launcher {
    display: none;
}