:root {
    --primary-pink: #ffb6c1;
    /* Baby pink */
    --primary-pink-dark: #ff9fb0;
    --primary-pink-light: #ffd9df;
    --bg-pink: #fff5f7;
    --chat-bg: #ffffff;
    --text-main: #333333;
    --text-muted: #666666;
    --ai-msg-bg: #fff0f3;
    --user-msg-bg: #ffb6c1;
    --user-msg-text: #5e0018;
    --shadow-sm: 0 4px 6px rgba(255, 182, 193, 0.1);
    --shadow-md: 0 10px 20px rgba(255, 182, 193, 0.15);
    --border-radius: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-pink);
    background-image: radial-gradient(circle at top left, var(--primary-pink-light) 0%, transparent 40%),
        radial-gradient(circle at bottom right, var(--primary-pink-light) 0%, transparent 40%);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

/* App Container */
.app-container {
    width: 100%;
    max-width: 600px;
    height: 95vh;
    background-color: var(--chat-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    border: 1px solid rgba(255, 182, 193, 0.3);
}

/* Header */
.chat-header {
    padding: 1.2rem 1.5rem;
    background-color: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--primary-pink-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar {
    width: 45px;
    height: 45px;
    background: linear-gradient(135deg, var(--primary-pink), var(--primary-pink-dark));
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    box-shadow: var(--shadow-sm);
}

.header-info h1 {
    font-size: 1.2rem;
    font-weight: 600;
}

.header-info .status {
    font-size: 0.85rem;
    color: var(--primary-pink-dark);
    font-weight: 500;
}

.water-reminder {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    background-color: #e0f2fe;
    color: #0284c7;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(2, 132, 199, 0.1);
    animation: gentlePulse 4s infinite;
    cursor: pointer;
    border: 1px solid #bae6fd;
    transition: all 0.2s ease;
}

.water-reminder:hover {
    background-color: #bae6fd;
    transform: scale(1.05);
}

.water-reminder i {
    width: 16px;
    height: 16px;
    color: #0ea5e9;
}

@keyframes gentlePulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }
}

/* Chat Area */
.chat-container {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    scroll-behavior: smooth;
}

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

.chat-container::-webkit-scrollbar-thumb {
    background-color: var(--primary-pink-light);
    border-radius: 10px;
}

/* Messages */
.message {
    max-width: 80%;
    display: flex;
    flex-direction: column;
    animation: fadeIn 0.3s ease-out forwards;
    transform: translateY(10px);
    opacity: 0;
}

@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-content {
    padding: 1rem 1.2rem;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.message-content p+p {
    margin-top: 0.5rem;
}

/* User Message */
.user-message {
    align-self: flex-end;
}

.user-message .message-content {
    background: linear-gradient(135deg, var(--primary-pink), var(--primary-pink-dark));
    color: var(--user-msg-text);
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 10px rgba(255, 182, 193, 0.3);
}

/* AI Message */
.ai-message {
    align-self: flex-start;
}

.ai-message .message-content {
    background-color: var(--ai-msg-bg);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--primary-pink-light);
}

/* Code block inside message */
.message-content pre {
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    border: 1px solid var(--primary-pink-light);
}

.message-content code {
    font-family: monospace;
}

.message-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 5px;
    align-self: flex-end;
}

.ai-message .message-time {
    align-self: flex-start;
}

.chat-image {
    max-width: 100%;
    border-radius: 12px;
    margin-bottom: 0.5rem;
    border: 2px solid rgba(255, 255, 255, 0.4);
}

/* Loader */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 1rem 1.2rem;
    background-color: var(--ai-msg-bg);
    border-radius: 20px;
    border-bottom-left-radius: 4px;
    width: fit-content;
    align-items: center;
}

.dot {
    width: 6px;
    height: 6px;
    background-color: var(--primary-pink-dark);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
    animation-delay: -0.32s;
}

.dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Image Preview Container */
.image-preview-container {
    padding: 0.8rem 1.5rem;
    background-color: var(--bg-pink);
    border-top: 1px solid var(--primary-pink-light);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.image-preview {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 2px solid white;
}

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

.remove-image {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: white;
    color: var(--primary-pink-dark);
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 2px;
}

.image-file-name {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Input Area */
.input-area {
    padding: 1rem 1.5rem;
    background-color: var(--chat-bg);
    border-top: 1px solid var(--primary-pink-light);
    display: flex;
    align-items: flex-end;
    gap: 0.8rem;
}

.action-btn {
    background: none;
    border: none;
    color: var(--primary-pink-dark);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.action-btn:hover {
    background-color: var(--bg-pink);
    transform: scale(1.05);
}

.send-btn {
    background: linear-gradient(135deg, var(--primary-pink), var(--primary-pink-dark));
    color: white;
    box-shadow: var(--shadow-sm);
}

.send-btn:hover {
    background: linear-gradient(135deg, var(--primary-pink-dark), var(--primary-pink));
    color: white;
}

.send-btn:disabled {
    background: #e0e0e0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.input-wrapper {
    flex: 1;
    background-color: var(--bg-pink);
    border-radius: 20px;
    padding: 0.8rem 1.2rem;
    border: 1px solid var(--primary-pink-light);
    transition: all 0.2s ease;
}

.input-wrapper:focus-within {
    border-color: var(--primary-pink);
    box-shadow: 0 0 0 3px rgba(255, 182, 193, 0.2);
}

textarea {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    resize: none;
    font-size: 0.95rem;
    color: var(--text-main);
    max-height: 100px;
    line-height: 1.4;
}

textarea::placeholder {
    color: #a0a0a0;
}

/* Modal */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal {
    background: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    width: 85%;
    max-width: 400px;
    box-shadow: var(--shadow-md);
    border: 1px solid var(--primary-pink-light);
    text-align: center;
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.close-modal:hover {
    background-color: var(--bg-pink);
    color: var(--primary-pink-dark);
}

.modal h2 {
    color: var(--primary-pink-dark);
    margin-bottom: 1rem;
    font-size: 1.4rem;
}

.modal p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

.modal input {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid var(--primary-pink-light);
    border-radius: 12px;
    margin-bottom: 1rem;
    outline: none;
    font-size: 1rem;
}

.modal input:focus {
    border-color: var(--primary-pink-dark);
}

.save-btn {
    width: 100%;
    padding: 0.8rem;
    background: linear-gradient(135deg, var(--primary-pink), var(--primary-pink-dark));
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.save-btn:hover {
    transform: translateY(-2px);
}

.modal-footer {
    margin-top: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- Responsive Adjustments --- */
@media screen and (max-width: 600px) {
    body {
        align-items: flex-start;
        /* So keyboard doesn't push it weirdly */
        height: 100dvh;
        /* Dynamic viewport height for mobile keyboards */
    }

    .app-container {
        height: 100dvh;
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        border: none;
    }

    .chat-header {
        padding: 1rem;
    }

    .chat-container {
        padding: 1rem;
    }

    .message {
        max-width: 92%;
    }

    .message-content {
        padding: 0.8rem 1rem;
    }

    .input-area {
        padding: 0.8rem 1rem;
        padding-bottom: env(safe-area-inset-bottom, 0.8rem);
        /* Safe area for iOS */
    }

    .action-btn {
        width: 38px;
        height: 38px;
    }

    .input-wrapper {
        padding: 0.6rem 1rem;
    }

    .water-reminder span {
        display: none;
        /* Hide text on very small screens, keep just the icon */
    }

    .water-reminder {
        padding: 0.4rem;
    }
}