* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #075e54;
    --secondary-color: #128c7e;
    --accent-color: #25d366;
    --user-bubble: #dcf8c6;
    --assistant-bubble: #ffffff;
    --bg-color: #e5ddd5;
    --input-bg: #f0f0f0;
    --text-primary: #000000;
    --text-secondary: #667781;
    --border-color: #d1d7db;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    position: fixed;
    width: 100%;
}

.app-container {
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    position: relative;
    overflow: hidden;
}

/* Header */
.chat-header {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 16px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.header-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    background-color: white;
    flex-shrink: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.header-info h1 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.status {
    font-size: 13px;
    opacity: 0.8;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect fill="%23e5ddd5" width="100" height="100"/><circle fill="%23d9d3c8" cx="50" cy="50" r="2" opacity="0.1"/></svg>');
    background-repeat: repeat;
    padding: 16px;
}

.messages-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 100%;
}

/* Message Bubbles */
.message {
    display: flex;
    margin-bottom: 8px;
    animation: messageSlideIn 0.3s ease-out;
}

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

.message.user {
    justify-content: flex-end;
}

.message.assistant {
    justify-content: flex-start;
}

.message-bubble {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    position: relative;
    word-wrap: break-word;
    animation: bubblePop 0.2s ease-out;
}

@keyframes bubblePop {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.message.user .message-bubble {
    background-color: var(--user-bubble);
    border-bottom-right-radius: 2px;
}

.message.assistant .message-bubble {
    background-color: var(--assistant-bubble);
    border-bottom-left-radius: 2px;
    border: 1px solid var(--border-color);
}

.message-text {
    font-size: 14.5px;
    line-height: 1.5;
    margin-bottom: 4px;
    white-space: pre-wrap;
}

.message-time {
    font-size: 11px;
    color: var(--text-secondary);
    text-align: right;
    display: block;
    margin-top: 4px;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background-color: var(--assistant-bubble);
    border-radius: 18px;
    width: fit-content;
    box-shadow: var(--shadow);
    margin-left: 16px;
    margin-bottom: 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    opacity: 0.6;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* Input Area */
.input-area {
    background-color: #f0f0f0;
    padding: 8px 16px;
    border-top: 1px solid var(--border-color);
    position: sticky;
    bottom: 0;
    z-index: 10;
}

.input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
    background-color: white;
    border-radius: 24px;
    padding: 8px 12px;
    box-shadow: var(--shadow);
}

#messageInput {
    flex: 1;
    border: none;
    outline: none;
    font-size: 15px;
    padding: 6px 8px;
    background: transparent;
    font-family: inherit;
}

#messageInput::placeholder {
    color: var(--text-secondary);
}

.send-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: var(--secondary-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.send-button:hover {
    background-color: var(--accent-color);
    transform: scale(1.05);
}

.send-button:active {
    transform: scale(0.95);
}

.send-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .app-container {
        max-width: 100%;
    }

    .message-bubble {
        max-width: 85%;
    }

    .messages-container {
        padding: 12px;
    }
}

/* Scrollbar Styling */
.messages-container::-webkit-scrollbar {
    width: 6px;
}

.messages-container::-webkit-scrollbar-track {
    background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.messages-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Loading state for send button */
.send-button.loading {
    pointer-events: none;
    opacity: 0.6;
}

.send-button.loading svg {
    animation: spin 1s linear infinite;
}

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

/* Profile Screen Styles */
.profile-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: white;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.profile-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
}

.back-button {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: rgba(0, 0, 0, 0.1);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
}

.back-button:hover {
    background-color: rgba(0, 0, 0, 0.2);
    transform: scale(1.05);
}

.character-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 40px 0;
    position: relative;
}

.character {
    position: relative;
    width: 200px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease;
    transform: translateY(-140px);
}

.gif-container {
    position: fixed;
    top: 55%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    z-index: 2;
    pointer-events: none;
}

.character-gif {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.character:hover {
    transform: translateY(-140px) scale(1.05);
}

.character img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
}

.character.spinning img {
    animation: characterSpin 1.2s linear;
}

.character.spinning .gif-container {
    /* GIF container stays in place - no rotation */
    transform: translateX(-50%) !important;
}

.character.spinning .character-gif {
    /* GIF itself stays in place - no rotation */
    transform: none !important;
}

@keyframes characterSpin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(var(--spin-rotation, 360deg));
    }
}

.spin-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    background-color: var(--secondary-color);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin: 20px auto;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.spin-button:hover {
    background-color: var(--accent-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.spin-button:active {
    transform: translateY(0);
}

.spin-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    transform: none;
}

.spin-button svg {
    animation: spinIcon 2s linear infinite;
}

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

.character-info {
    text-align: center;
    margin-top: 20px;
}

.character-info h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.character-info p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Tap feedback */
.character.tap-feedback {
    animation: tapBounce 0.3s ease;
}

@keyframes tapBounce {
    0% {
        transform: translateY(-140px) scale(1);
    }
    50% {
        transform: translateY(-140px) scale(0.95);
    }
    100% {
        transform: translateY(-140px) scale(1);
    }
}

/* Screen transitions */
.app-container,
.profile-screen {
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.profile-screen.hidden {
    opacity: 0;
    transform: translateX(100%);
}

.app-container.hidden {
    opacity: 0;
    transform: translateX(-100%);
}

/* Mobile optimizations for profile screen */
@media (max-width: 768px) {
    .profile-container {
        padding: 15px;
    }
    
    .character {
        width: 150px;
        height: 150px;
    }
    
    .back-button {
        top: 15px;
        left: 15px;
        width: 35px;
        height: 35px;
    }
    
    .character-info h2 {
        font-size: 20px;
    }
}

/* Prevent keyboard from pushing content up */
@media (max-width: 768px) {
    body {
        position: fixed;
        height: 100vh;
        overflow: hidden;
    }
    
    .app-container {
        height: 100vh;
        overflow: hidden;
    }
    
    .messages-container {
        height: calc(100vh - 120px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .input-area {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-width: 800px;
        margin: 0 auto;
    }
}


