/* Cyber War Chatbot */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=block');

.cw-chat {
    --cw-chat-accent: var(--accent, #dc143c);
    --cw-chat-bg: #111111;
    --cw-chat-surface: rgba(255, 255, 255, 0.05);
    --cw-chat-border: rgba(255, 255, 255, 0.12);
    --cw-chat-text: var(--text, #ffffff);
    --cw-chat-muted: var(--muted, rgba(255, 255, 255, 0.72));
    position: fixed;
    right: 22px;
    bottom: 22px;
    left: auto;
    z-index: 9985;
    font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body[data-theme="light"] .cw-chat {
    --cw-chat-bg: #ffffff;
    --cw-chat-surface: rgba(0, 0, 0, 0.04);
    --cw-chat-border: rgba(0, 0, 0, 0.1);
}

.cw-chat__panel {
    position: absolute;
    right: 0;
    left: auto;
    bottom: 72px;
    width: min(420px, calc(100vw - 44px));
    height: min(580px, calc(100vh - 120px));
    display: flex;
    flex-direction: column;
    padding: 14px;
    border: 2px solid rgba(220, 20, 60, 0.45);
    border-radius: 24px;
    background: var(--cw-chat-bg);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(18px) scale(0.96);
    transform-origin: right bottom;
    transition: opacity 260ms ease, transform 260ms ease, visibility 260ms ease;
    box-sizing: border-box;
}

.cw-chat__panel::before {
    content: "";
    position: absolute;
    inset: 9px;
    border: 2px dashed rgba(220, 20, 60, 0.42);
    border-radius: 18px;
    pointer-events: none;
    z-index: 3;
}

body[data-theme="light"] .cw-chat__panel {
    border-color: rgba(220, 20, 60, 0.35);
}

body[data-theme="light"] .cw-chat__panel::before {
    border-color: rgba(220, 20, 60, 0.38);
}

.cw-chat.is-open .cw-chat__panel {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.cw-chat__bg-canvas {
    position: absolute;
    inset: 14px;
    width: calc(100% - 28px);
    height: calc(100% - 28px);
    z-index: 0;
    pointer-events: none;
    border-radius: 16px;
}

.cw-chat__header,
.cw-chat__body,
.cw-chat__typing,
.cw-chat__chips,
.cw-chat__footer {
    position: relative;
    z-index: 1;
}

.cw-chat__header {
    padding: 14px 14px 12px;
    margin-bottom: 2px;
    border: 1px solid var(--cw-chat-border);
    border-radius: 14px;
    background:
        linear-gradient(135deg, rgba(220, 20, 60, 0.16) 0%, transparent 55%),
        rgba(17, 17, 17, 0.78);
    overflow: hidden;
}

body[data-theme="light"] .cw-chat__header {
    background:
        linear-gradient(135deg, rgba(220, 20, 60, 0.1) 0%, transparent 55%),
        rgba(255, 255, 255, 0.82);
}

.cw-chat__header-top {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.cw-chat__avatar {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    border: 2px solid rgba(220, 20, 60, 0.55);
    background: rgba(220, 20, 60, 0.12);
    display: grid;
    place-items: center;
    flex-shrink: 0;
}

.cw-chat__avatar img {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    object-fit: cover;
}

.cw-chat__meta {
    flex: 1;
    min-width: 0;
}

.cw-chat__title {
    margin: 0;
    font-size: 11px;
    font-weight: 700;
    color: var(--cw-chat-text);
    letter-spacing: 0.4px;
    line-height: 1.25;
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cw-chat__status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 3px;
    font-size: 11px;
    font-weight: 600;
    color: #00ff88;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.cw-chat__status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #00ff88;
    animation: cw-chat-pulse 1.8s ease-in-out infinite;
}

@keyframes cw-chat-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.55; transform: scale(0.85); }
}

.cw-chat__close {
    width: 34px;
    height: 34px;
    border: 1px solid var(--cw-chat-border);
    border-radius: 10px;
    background: var(--cw-chat-surface);
    color: var(--cw-chat-text);
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: border-color 140ms ease, background 140ms ease, filter 140ms ease;
}

.cw-chat__close:hover {
    border-color: rgba(220, 20, 60, 0.45);
    filter: brightness(1.08);
}

.cw-chat__body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 12px;
    margin: 4px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    background: transparent;
    border-radius: 12px;
}

.cw-chat__body::-webkit-scrollbar {
    width: 5px;
}

.cw-chat__body::-webkit-scrollbar-thumb {
    background: rgba(220, 20, 60, 0.35);
    border-radius: 99px;
}

.cw-chat__msg {
    display: flex;
    gap: 8px;
    max-width: 92%;
    animation: cw-chat-msg-in 280ms ease both;
}

@keyframes cw-chat-msg-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cw-chat__msg--bot {
    align-self: flex-start;
}

.cw-chat__msg--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.cw-chat__msg-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: 1px solid var(--cw-chat-border);
    background: rgba(17, 17, 17, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    color: var(--cw-chat-accent);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.cw-chat__msg--user .cw-chat__msg-icon {
    background: rgba(220, 20, 60, 0.92);
    border-color: rgba(220, 20, 60, 0.92);
    color: #ffffff;
}

body[data-theme="light"] .cw-chat__msg-icon {
    background: rgba(255, 255, 255, 0.88);
    border-color: rgba(0, 0, 0, 0.1);
    color: var(--cw-chat-accent);
}

body[data-theme="light"] .cw-chat__msg--user .cw-chat__msg-icon {
    background: #dc143c;
    border-color: #dc143c;
    color: #ffffff;
}

.cw-chat__bubble {
    padding: 10px 12px;
    border-radius: 14px;
    border: 1px solid var(--cw-chat-border);
    background: rgba(17, 17, 17, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--cw-chat-text);
    font-size: 13px;
    line-height: 1.55;
}

body[data-theme="light"] .cw-chat__msg--bot .cw-chat__bubble {
    background: rgba(255, 255, 255, 0.88);
    border-color: rgba(0, 0, 0, 0.1);
    color: #111111;
}

.cw-chat__msg--user .cw-chat__bubble {
    background: rgba(220, 20, 60, 0.92);
    border-color: rgba(220, 20, 60, 0.92);
    color: #ffffff;
}

body[data-theme="light"] .cw-chat__msg--user .cw-chat__bubble {
    background: #dc143c;
    border-color: #dc143c;
    color: #ffffff;
}

.cw-chat__bubble a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.cw-chat__msg--user .cw-chat__bubble a {
    color: #ffffff;
}

body[data-theme="light"] .cw-chat__msg--bot .cw-chat__bubble a {
    color: #dc143c;
}

.cw-chat__msg--user .cw-chat__time {
    color: rgba(255, 255, 255, 0.78);
}

.cw-chat__bubble strong {
    font-weight: 700;
}

.cw-chat__time {
    display: block;
    margin-top: 5px;
    font-size: 10px;
    opacity: 0.55;
}

.cw-chat__typing {
    display: none;
    align-self: flex-start;
    padding: 0 14px 4px;
}

.cw-chat.is-typing .cw-chat__typing {
    display: block;
}

.cw-chat__typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    border-radius: 14px;
    border: 1px solid var(--cw-chat-border);
    background: rgba(17, 17, 17, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

body[data-theme="light"] .cw-chat__typing-dots {
    background: rgba(255, 255, 255, 0.78);
}

.cw-chat__typing-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--cw-chat-accent);
    animation: cw-chat-dot 1.1s ease-in-out infinite;
}

.cw-chat__typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.cw-chat__typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes cw-chat-dot {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
    40% { transform: translateY(-4px); opacity: 1; }
}

.cw-chat__chips {
    padding: 4px 2px 8px;
    margin-top: 2px;
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    border-top: 1px dashed rgba(220, 20, 60, 0.22);
}

.cw-chat__chip {
    border: 1px solid rgba(220, 20, 60, 0.35);
    border-radius: 999px;
    background: rgba(17, 17, 17, 0.62);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: var(--cw-chat-text);
    font-size: 11px;
    font-weight: 600;
    padding: 7px 11px;
    cursor: pointer;
    transition: background 140ms ease, border-color 140ms ease, filter 140ms ease;
    white-space: nowrap;
}

.cw-chat__chip:hover {
    background: rgba(220, 20, 60, 0.2);
    border-color: rgba(220, 20, 60, 0.55);
    filter: brightness(1.05);
}

body[data-theme="light"] .cw-chat__chip {
    background: rgba(255, 255, 255, 0.72);
}

.cw-chat__footer {
    padding: 10px 2px 2px;
    margin-top: 2px;
    border-top: 1px dashed rgba(220, 20, 60, 0.28);
    background: rgba(17, 17, 17, 0.82);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 0 0 12px 12px;
}

body[data-theme="light"] .cw-chat__footer {
    background: rgba(255, 255, 255, 0.88);
    border-top-color: rgba(220, 20, 60, 0.22);
}

.cw-chat__input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 6px 6px 14px;
    border: 1px solid var(--cw-chat-border);
    border-radius: 14px;
    background: var(--cw-chat-surface);
    transition: border-color 160ms ease;
}

.cw-chat__input-wrap:focus-within {
    border-color: rgba(220, 20, 60, 0.45);
}

.cw-chat__input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--cw-chat-text);
    font: inherit;
    font-size: 13px;
}

.cw-chat__input::placeholder {
    color: var(--cw-chat-muted);
}

.cw-chat__send {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 10px;
    background: var(--cw-chat-accent);
    color: #ffffff;
    cursor: pointer;
    display: grid;
    place-items: center;
    transition: filter 140ms ease;
    flex-shrink: 0;
}

.cw-chat__send:hover {
    filter: brightness(1.08);
}

.cw-chat__send:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.cw-chat__toggle {
    width: 58px;
    height: 58px;
    border: 2px dashed rgba(220, 20, 60, 0.65);
    outline: 2px solid rgba(220, 20, 60, 0.35);
    outline-offset: 3px;
    border-radius: 18px;
    background: var(--cw-chat-accent);
    color: #ffffff;
    cursor: pointer;
    display: grid;
    place-items: center;
    position: relative;
    transition: filter 140ms ease, transform 180ms ease, border-color 180ms ease;
}

.cw-chat__toggle:hover {
    filter: brightness(1.06);
    transform: translateY(-2px);
}

.cw-chat.is-open .cw-chat__toggle {
    border-color: rgba(255, 255, 255, 0.35);
}

.cw-chat__toggle-ring {
    position: absolute;
    inset: -6px;
    border: 1px solid rgba(220, 20, 60, 0.35);
    border-radius: 22px;
    animation: cw-chat-ring 2.4s ease-out infinite;
    pointer-events: none;
}

.cw-chat.is-open .cw-chat__toggle-ring {
    display: none;
}

@keyframes cw-chat-ring {
    0% { transform: scale(0.92); opacity: 0.8; }
    100% { transform: scale(1.18); opacity: 0; }
}

.cw-chat__toggle-icon {
    width: 26px;
    height: 26px;
    transition: transform 220ms ease, opacity 220ms ease;
}

.cw-chat__toggle-icon--close {
    position: absolute;
    opacity: 0;
    transform: rotate(-90deg) scale(0.7);
}

.cw-chat.is-open .cw-chat__toggle-icon--open {
    opacity: 0;
    transform: rotate(90deg) scale(0.7);
}

.cw-chat.is-open .cw-chat__toggle-icon--close {
    opacity: 1;
    transform: rotate(0) scale(1);
}

.cw-chat__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #00ff88;
    color: #0a0a0a;
    font-size: 10px;
    font-weight: 800;
    display: grid;
    place-items: center;
    border: 2px solid var(--cw-chat-bg);
}

.cw-chat.is-open .cw-chat__badge {
    display: none;
}

@media (max-width: 860px) {
    .cw-chat {
        right: 14px;
        left: auto;
        bottom: 14px;
    }

    .cw-chat__panel {
        bottom: 68px;
        width: min(370px, calc(100vw - 28px));
        height: min(540px, calc(100vh - 100px));
        padding: 12px;
        border-radius: 20px;
    }

    .cw-chat__panel::before {
        inset: 7px;
        border-radius: 15px;
    }

    .cw-chat__bg-canvas {
        inset: 12px;
        width: calc(100% - 24px);
        height: calc(100% - 24px);
        border-radius: 14px;
    }

    .cw-chat__toggle {
        width: 52px;
        height: 52px;
        border-radius: 16px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .cw-chat__panel,
    .cw-chat__toggle,
    .cw-chat__toggle-icon,
    .cw-chat__msg,
    .cw-chat__toggle-ring,
    .cw-chat__status-dot,
    .cw-chat__typing-dots span {
        animation: none;
        transition: opacity 120ms ease, visibility 120ms ease;
    }

    .cw-chat__panel {
        transform: none;
    }

    .cw-chat.is-open .cw-chat__panel {
        transform: none;
    }
}
