/* ========================================
   HELP CHATBOT - STED archbuild
   Black & white space-time themed
   ======================================== */

/* Toggle Button */
#sted-chat-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #000;
    border: 1.5px solid rgba(255,255,255,0.25);
    cursor: pointer;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4);
    padding: 0;
    outline: none;
    overflow: hidden;
}

#sted-chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 30px rgba(255,255,255,0.12);
    border-color: rgba(255,255,255,0.5);
}

/* Space-time graphic toggle icon */
#sted-chat-toggle .toggle-icon {
    width: 36px;
    height: 36px;
    position: relative;
}

/* Planet / celestial body */
#sted-chat-toggle .space-planet {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fff;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    margin: -6px 0 0 -6px;
    box-shadow: 0 0 8px rgba(255,255,255,0.4);
}

/* Orbit ring 1 — tilted ellipse */
#sted-chat-toggle .space-orbit-1 {
    position: absolute;
    width: 30px;
    height: 14px;
    border: 1px solid rgba(255,255,255,0.5);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    margin: -7px 0 0 -15px;
    transform: rotate(-25deg);
    animation: orbitSpin1 8s linear infinite;
}

/* Orbit ring 2 — perpendicular ellipse */
#sted-chat-toggle .space-orbit-2 {
    position: absolute;
    width: 28px;
    height: 12px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    top: 50%;
    left: 50%;
    margin: -6px 0 0 -14px;
    transform: rotate(55deg);
    animation: orbitSpin2 12s linear infinite;
}

/* Small orbiting moon */
#sted-chat-toggle .space-moon {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(255,255,255,0.8);
    border-radius: 50%;
    top: 3px;
    left: 50%;
    margin-left: -2px;
    animation: moonOrbit 4s linear infinite;
    transform-origin: 2px 15px;
}

/* Tiny stars scattered */
#sted-chat-toggle .space-stars {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image:
        radial-gradient(1px 1px at 15% 20%, rgba(255,255,255,0.7) 0%, transparent 100%),
        radial-gradient(1px 1px at 75% 15%, rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(1px 1px at 85% 75%, rgba(255,255,255,0.6) 0%, transparent 100%),
        radial-gradient(1px 1px at 25% 80%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 55% 90%, rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(1px 1px at 10% 55%, rgba(255,255,255,0.3) 0%, transparent 100%);
    animation: starTwinkle 5s ease-in-out infinite alternate;
}

@keyframes orbitSpin1 {
    from { transform: rotate(-25deg); }
    to { transform: rotate(335deg); }
}

@keyframes orbitSpin2 {
    from { transform: rotate(55deg); }
    to { transform: rotate(415deg); }
}

@keyframes moonOrbit {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Close icon (X) when open */
#sted-chat-toggle.active .toggle-icon { display: none; }
#sted-chat-toggle.active::after {
    content: '\00d7';
    font-size: 28px;
    color: #fff;
    line-height: 1;
}

/* Pulse ring */
#sted-chat-toggle::before {
    content: '';
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.3);
    opacity: 0;
    animation: chatPulse 4s ease-in-out infinite;
}

#sted-chat-toggle.active::before { animation: none; opacity: 0; }

@keyframes chatPulse {
    0%, 100% { opacity: 0; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.15); }
}

/* Chat Panel */
#sted-chat-panel {
    position: fixed;
    bottom: 110px;
    right: 30px;
    width: 380px;
    height: 520px;
    background: #0a0a0a;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 16px;
    z-index: 9998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    font-family: 'Inter', -apple-system, sans-serif;
}

#sted-chat-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* Header */
.chat-header {
    padding: 18px 20px 14px;
    background: #0a0a0a;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    position: relative;
    overflow: hidden;
}

/* Starfield in header */
.chat-header::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image:
        radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(1px 1px at 60% 20%, rgba(255,255,255,0.35) 0%, transparent 100%),
        radial-gradient(1px 1px at 80% 60%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 40% 70%, rgba(255,255,255,0.25) 0%, transparent 100%),
        radial-gradient(1px 1px at 10% 80%, rgba(255,255,255,0.35) 0%, transparent 100%),
        radial-gradient(1px 1px at 90% 40%, rgba(255,255,255,0.3) 0%, transparent 100%),
        radial-gradient(1px 1px at 50% 50%, rgba(255,255,255,0.4) 0%, transparent 100%);
    animation: starTwinkle 6s ease-in-out infinite alternate;
    pointer-events: none;
}

@keyframes starTwinkle {
    0% { opacity: 0.3; }
    50% { opacity: 0.7; }
    100% { opacity: 0.4; }
}

.chat-header-content {
    position: relative;
    z-index: 1;
}

.chat-header-title {
    font-size: 15px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: #fff;
    margin: 0;
    font-weight: 500;
}

.chat-header-line {
    width: 30px;
    height: 1.5px;
    background: rgba(255,255,255,0.4);
    margin-top: 10px;
    border: none;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

/* Message Bubbles */
.chat-msg {
    max-width: 85%;
    animation: msgFadeIn 0.3s ease;
}

.chat-msg.bot {
    align-self: flex-start;
}

.chat-msg.user {
    align-self: flex-end;
}

.chat-msg .msg-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.65;
    font-weight: 300;
}

.chat-msg.bot .msg-bubble {
    background: #161616;
    color: rgba(255,255,255,0.88);
    border-left: 3px solid rgba(255,255,255,0.35);
    border-radius: 2px 12px 12px 2px;
}

.chat-msg.user .msg-bubble {
    background: #fff;
    color: #000;
    font-weight: 400;
    border-radius: 12px 12px 2px 12px;
}

.chat-msg .msg-bubble a {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.chat-msg.user .msg-bubble a {
    color: #000;
}

.chat-msg .msg-bubble strong {
    font-weight: 500;
    color: #fff;
}

.chat-msg.user .msg-bubble strong {
    color: #000;
}

@keyframes msgFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Bot avatar label */
.chat-msg.bot .msg-label {
    font-size: 10px;
    color: rgba(255,255,255,0.4);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-bottom: 4px;
    font-weight: 500;
}

/* Quick Reply Chips */
.chat-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    animation: msgFadeIn 0.4s ease;
}

.chat-quick-replies button {
    padding: 7px 14px;
    border: 1px solid rgba(255,255,255,0.25);
    background: transparent;
    color: rgba(255,255,255,0.8);
    font-size: 12px;
    font-family: inherit;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.25s ease;
    letter-spacing: 0.3px;
    font-weight: 400;
    white-space: nowrap;
}

.chat-quick-replies button:hover {
    background: #fff;
    color: #000;
    border-color: #fff;
}

/* Typing Indicator */
.chat-typing {
    display: flex;
    gap: 5px;
    padding: 12px 16px;
    align-self: flex-start;
}

.chat-typing span {
    width: 6px;
    height: 6px;
    background: rgba(255,255,255,0.6);
    border-radius: 50%;
    animation: typingDot 1.2s ease-in-out infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-4px); }
}

/* Input Area */
.chat-input-area {
    padding: 14px 16px;
    background: #0f0f0f;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input-area input {
    flex: 1;
    padding: 10px 14px;
    background: #1a1a1a;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    color: #fff;
    font-size: 13.5px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
    font-weight: 300;
}

.chat-input-area input::placeholder {
    color: rgba(255,255,255,0.3);
}

.chat-input-area input:focus {
    border-color: rgba(255,255,255,0.25);
}

.chat-input-area button {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.chat-input-area button:hover {
    background: #d4d4d4;
    transform: scale(1.05);
}

.chat-input-area button svg {
    width: 18px;
    height: 18px;
    fill: #000;
}

/* ========================================
   RESPONSIVE - TABLET
   ======================================== */
@media (max-width: 1024px) {
    #sted-chat-panel {
        width: 350px;
        height: 480px;
    }
}

/* ========================================
   RESPONSIVE - MOBILE
   ======================================== */
@media (max-width: 768px) {
    #sted-chat-toggle {
        bottom: 20px;
        right: 20px;
        width: 56px;
        height: 56px;
    }

    #sted-chat-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 100%;
        max-height: 100dvh;
        border-radius: 0;
        border: none;
    }

    #sted-chat-panel.open {
        transform: translateY(0) scale(1);
    }

    .chat-header {
        padding: 16px 16px 14px;
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .chat-input-area {
        padding-bottom: max(14px, env(safe-area-inset-bottom));
    }

    .chat-msg .msg-bubble {
        font-size: 14px;
    }

    .chat-quick-replies button {
        font-size: 13px;
        padding: 8px 16px;
    }
}
