/**
 * Chat'brutit - Multiple Personalities Chatbot
 * Matches SitePrincipal dark modern theme
 */

/* ============================================
   Chat Container & Toggle Button
   ============================================ */
#chat-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

#chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(220, 38, 38, 0.4),
                0 0 0 0 rgba(220, 38, 38, 0.4);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

#chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(220, 38, 38, 0.5),
                0 0 0 8px rgba(220, 38, 38, 0.1);
}

#chat-toggle.active {
    transform: scale(0.9);
}

.chat-toggle-icon {
    font-size: 28px;
    line-height: 1;
}

/* ============================================
   Chat Panel
   ============================================ */
#chat-panel {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    height: 520px;
    background: #141414;
    border: 1px solid #262626;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5),
                0 0 0 1px rgba(220, 38, 38, 0.1);
}

#chat-panel.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ============================================
   Chat Header
   ============================================ */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #0a0a0a;
    border-bottom: 1px solid #262626;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar {
    font-size: 28px;
    line-height: 1;
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
    color: #fafafa;
    letter-spacing: -0.01em;
}

.chat-anger {
    font-size: 18px;
    line-height: 1;
    transition: transform 0.2s ease;
}

.chat-anger.anger-shake {
    animation: angerShake 0.5s ease-in-out infinite;
}

@keyframes angerShake {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    25% { transform: translateX(-3px) rotate(-5deg); }
    75% { transform: translateX(3px) rotate(5deg); }
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-reset,
.chat-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid #262626;
    background: transparent;
    color: #a3a3a3;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.chat-reset:hover,
.chat-close:hover {
    background: #1a1a1a;
    border-color: #dc2626;
    color: #dc2626;
}

/* ============================================
   Chat Messages Area
   ============================================ */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scrollbar-width: thin;
    scrollbar-color: #262626 transparent;
}

#chat-messages::-webkit-scrollbar {
    width: 6px;
}

#chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chat-messages::-webkit-scrollbar-thumb {
    background: #262626;
    border-radius: 3px;
}

#chat-messages::-webkit-scrollbar-thumb:hover {
    background: #363636;
}

/* ============================================
   Chat Messages
   ============================================ */
.chat-message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-message--user {
    align-self: flex-end;
}

.chat-message--bot {
    align-self: flex-start;
}

.chat-message__content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.chat-message--user .chat-message__content {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.chat-message--bot .chat-message__content {
    background: #1a1a1a;
    color: #fafafa;
    border: 1px solid #262626;
    border-bottom-left-radius: 4px;
}

.chat-message__time {
    font-size: 11px;
    color: #525252;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    padding: 0 4px;
}

.chat-message--user .chat-message__time {
    text-align: right;
}

/* Message Animation */
.chat-message--animate {
    animation: messageSlideIn 0.3s ease forwards;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Typing Indicator
   ============================================ */
.chat-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
    background: #1a1a1a;
    border: 1px solid #262626;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    align-self: flex-start;
}

.chat-typing__dot {
    width: 8px;
    height: 8px;
    background: #525252;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.chat-typing__dot:nth-child(1) {
    animation-delay: -0.32s;
}

.chat-typing__dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        background: #525252;
    }
    40% {
        transform: scale(1);
        background: #dc2626;
    }
}

/* ============================================
   Chat Input Area
   ============================================ */
.chat-input-area {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #0a0a0a;
    border-top: 1px solid #262626;
}

#chat-input {
    flex: 1;
    background: #141414;
    border: 1px solid #262626;
    border-radius: 12px;
    padding: 12px 16px;
    font-size: 14px;
    color: #fafafa;
    font-family: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#chat-input::placeholder {
    color: #525252;
}

#chat-input:focus {
    outline: none;
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

#chat-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.chat-send {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
    border: none;
    color: #ffffff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.chat-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
}

.chat-send:active:not(:disabled) {
    transform: scale(0.95);
}

.chat-send:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================
   Responsive Design
   ============================================ */
@media (max-width: 480px) {
    #chat-container {
        bottom: 16px;
        right: 16px;
    }

    #chat-panel {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        max-height: 600px;
        bottom: 72px;
        right: 0;
        border-radius: 12px;
    }

    #chat-toggle {
        width: 56px;
        height: 56px;
    }

    .chat-toggle-icon {
        font-size: 24px;
    }

    .chat-header {
        padding: 12px 16px;
    }

    .chat-title {
        font-size: 14px;
    }

    #chat-messages {
        padding: 16px;
        gap: 12px;
    }

    .chat-message__content {
        padding: 10px 14px;
        font-size: 13px;
    }

    .chat-input-area {
        padding: 12px 16px;
        gap: 10px;
    }

    #chat-input {
        padding: 10px 14px;
        font-size: 14px;
    }

    .chat-send {
        width: 40px;
        height: 40px;
    }
}

/* ============================================
   Pulse Animation for Toggle Button
   ============================================ */
@keyframes pulse {
    0% {
        box-shadow: 0 4px 20px rgba(220, 38, 38, 0.4),
                    0 0 0 0 rgba(220, 38, 38, 0.4);
    }
    70% {
        box-shadow: 0 4px 20px rgba(220, 38, 38, 0.4),
                    0 0 0 15px rgba(220, 38, 38, 0);
    }
    100% {
        box-shadow: 0 4px 20px rgba(220, 38, 38, 0.4),
                    0 0 0 0 rgba(220, 38, 38, 0);
    }
}

#chat-toggle:not(.active) {
    animation: pulse 2s infinite;
}

/* ============================================
   Personality Roll Animation
   ============================================ */
.chat-personality-roll {
    display: flex;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

.roll-animation {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 20px 30px;
    background: linear-gradient(135deg, #1a1a1a 0%, #262626 100%);
    border: 2px solid #dc2626;
    border-radius: 16px;
    box-shadow: 0 0 30px rgba(220, 38, 38, 0.3);
}

.roll-dice {
    font-size: 48px;
    animation: rollDice 1s ease-in-out infinite;
}

@keyframes rollDice {
    0%, 100% {
        transform: rotate(0deg) scale(1);
    }
    25% {
        transform: rotate(90deg) scale(1.2);
    }
    50% {
        transform: rotate(180deg) scale(1);
    }
    75% {
        transform: rotate(270deg) scale(1.2);
    }
}

.roll-text {
    font-size: 14px;
    color: #a3a3a3;
    font-weight: 500;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.roll-result {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 30px;
    background: linear-gradient(135deg, #1a1a1a 0%, #262626 100%);
    border: 2px solid #22c55e;
    border-radius: 16px;
    box-shadow: 0 0 30px rgba(34, 197, 94, 0.3);
    animation: resultPop 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes resultPop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.roll-avatar {
    font-size: 48px;
    animation: bounceIn 0.6s ease;
}

@keyframes bounceIn {
    0% {
        transform: scale(0);
    }
    50% {
        transform: scale(1.3);
    }
    100% {
        transform: scale(1);
    }
}

.roll-name {
    font-size: 16px;
    font-weight: 600;
    color: #fafafa;
    text-align: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
