/* ============================================
   HAL STANDALONE - CHAT WIDGET CSS
   Version: 9.0.0
   Drop-in styles for the chat modal
   ============================================ */

/* ============================================
   CSS VARIABLES (Override via config)
   ============================================ */
:root {
    --hal-black: #0a0a0a;
    --hal-black-light: #151515;
    --hal-grey-dark: #252525;
    --hal-grey: #666666;
    --hal-grey-light: #a0a0a0;
    --hal-white: #ffffff;
    --hal-primary: #FFD700;
    --hal-success: #22c55e;
    --hal-error: #ef4444;
}

/* ============================================
   CHAT MODAL
   ============================================ */
.chat-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.chat-modal.active {
    display: flex;
}

.chat-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
}

.chat-modal-container {
    position: relative;
    width: 90%;
    max-width: 500px;
    height: 70vh;
    max-height: 600px;
    background: var(--hal-black);
    border: 1px solid var(--hal-grey-dark);
    display: flex;
    flex-direction: column;
    z-index: 1;
}

/* ============================================
   HEADER
   ============================================ */
.chat-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--hal-grey-dark);
    background: rgba(255, 255, 255, 0.02);
}

.chat-modal-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-hal-name {
    font-family: inherit;
    font-size: 1.2rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--hal-white);
}

/* ============================================
   HAL STATUS INDICATOR
   ============================================ */
.hal-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.hal-indicator {
    width: 8px;
    height: 8px;
    background: var(--hal-success);
    border-radius: 50%;
    position: relative;
}

/* Ring pulse - listening state */
.hal-indicator-ring::before {
    content: '';
    position: absolute;
    inset: -4px;
    border: 2px solid var(--hal-success);
    border-radius: 50%;
    animation: hal-ring-pulse 2s ease-out infinite;
}

@keyframes hal-ring-pulse {
    0% { transform: scale(0.8); opacity: 1; }
    100% { transform: scale(1.8); opacity: 0; }
}

/* Typing dots - processing state */
.hal-indicator-typing {
    display: flex;
    gap: 3px;
    background: transparent;
    width: auto;
    height: auto;
}

.hal-indicator-typing span {
    width: 5px;
    height: 5px;
    background: var(--hal-success);
    border-radius: 50%;
    animation: hal-typing 1.4s ease-in-out infinite;
}

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

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

/* Logging off - end state */
.hal-indicator-offline {
    background: var(--hal-error);
    animation: hal-offline-pulse 1s ease-in-out infinite;
}

.hal-indicator-offline::before {
    display: none;
}

@keyframes hal-offline-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.hal-status-text {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--hal-grey);
}

.hal-status-text.offline {
    color: var(--hal-error);
}

/* ============================================
   CLOSE BUTTON
   ============================================ */
.chat-modal-close {
    background: none;
    border: none;
    color: var(--hal-grey-light);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.3s ease;
}

.chat-modal-close:hover {
    color: var(--hal-white);
}

/* ============================================
   CHAT BODY
   ============================================ */
.chat-modal-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--hal-primary) var(--hal-black);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.chat-modal-body::-webkit-scrollbar {
    width: 8px;
}

.chat-modal-body::-webkit-scrollbar-track {
    background: var(--hal-black);
    border-left: 1px solid var(--hal-grey-dark);
}

.chat-modal-body::-webkit-scrollbar-thumb {
    background: var(--hal-primary);
    border-radius: 0;
}

.chat-modal-body::-webkit-scrollbar-thumb:hover {
    background: var(--hal-white);
}

/* ============================================
   MESSAGES
   ============================================ */
.chat-message {
    max-width: 85%;
    padding: 0.8rem 1rem;
    line-height: 1.5;
    font-size: 0.95rem;
}

.chat-message.hal {
    align-self: flex-start;
    background: rgba(255, 255, 255, 0.05);
    border-left: 2px solid var(--hal-primary);
    color: var(--hal-white);
}

.chat-message.user {
    align-self: flex-end;
    background: var(--hal-primary);
    color: var(--hal-black);
}

.chat-message .soft-prompt {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--hal-grey);
}

/* ============================================
   CONNECTING STATE
   ============================================ */
.chat-connecting {
    color: var(--hal-grey-light);
    font-style: italic;
}

.chat-connecting::after {
    content: '';
    animation: ellipsis 1.5s infinite;
}

@keyframes ellipsis {
    0% { content: ''; }
    25% { content: '.'; }
    50% { content: '..'; }
    75% { content: '...'; }
}

/* ============================================
   CLASSIFIED CURSOR (Easter Egg)
   ============================================ */
.classified-cursor {
    animation: blink 0.5s step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ============================================
   FOOTER / INPUT
   ============================================ */
.chat-modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--hal-grey-dark);
}

.chat-input-form {
    display: flex;
    gap: 0.75rem;
}

.chat-input {
    flex: 1;
    background: var(--hal-black-light);
    border: 1px solid var(--hal-grey-dark);
    color: var(--hal-white);
    padding: 0.75rem 1rem;
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    min-height: 44px;
    max-height: 150px;
}

.chat-input:focus {
    outline: none;
    border-color: var(--hal-primary);
}

.chat-input::placeholder {
    color: var(--hal-grey);
}

.chat-send-btn {
    background: var(--hal-primary);
    border: none;
    color: var(--hal-black);
    padding: 0 1.25rem;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    transition: all 0.3s ease;
}

.chat-send-btn:hover {
    background: var(--hal-white);
}

.chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================
   COMPLETION OVERLAY
   ============================================ */
.chat-overlay-complete {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.5s ease;
    z-index: 10;
}

.chat-overlay-complete.active {
    opacity: 1;
}

.chat-sending-text {
    color: var(--hal-white);
    font-size: 1.1rem;
    text-align: center;
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.chat-sticker {
    background: var(--hal-primary);
    color: var(--hal-black);
    padding: 2rem 3rem;
    text-align: center;
    transform: scale(0) rotate(-10deg);
    opacity: 0;
    transition: none;
}

.chat-sticker.slap {
    animation: stickerSlap 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes stickerSlap {
    0% { transform: scale(3) rotate(-10deg); opacity: 0; }
    50% { transform: scale(0.9) rotate(2deg); opacity: 1; }
    75% { transform: scale(1.05) rotate(-1deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.chat-sticker h3 {
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: uppercase;
    margin: 0 0 0.5rem;
}

.chat-sticker p {
    margin: 0;
    font-size: 1rem;
}

.chat-sticker .chat-ended-hint {
    margin-top: 1rem;
    font-size: 0.85rem;
    opacity: 0.7;
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */
@media (max-width: 768px) {
    .chat-modal-container {
        width: 100%;
        height: 100%;
        max-height: none;
        border: none;
    }
    
    .chat-message {
        max-width: 90%;
    }
}

/* ============================================
   BODY LOCK (When modal open)
   ============================================ */
body.modal-open {
    overflow: hidden;
}
