/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #2A9D8F;
    --primary-dark: #21867A;
    --secondary: #264653;
    --accent: #E76F51;
    --warning: #E9C46A;
    --success: #2A9D8F;
    --error: #E63946;
    --background: #F8F9FA;
    --surface: #FFFFFF;
    --text: #264653;
    --text-light: #6C757D;
    --border: #DEE2E6;
    --shadow: rgba(0, 0, 0, 0.1);
    --gradient: linear-gradient(135deg, #2A9D8F 0%, #264653 100%);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ===== Utilities ===== */
.hidden {
    display: none !important;
}

.container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ===== Buttons ===== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background: var(--gradient);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: transparent;
    color: var(--text-light);
    padding: 8px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
}

.btn-secondary:hover {
    background: var(--border);
    color: var(--text);
}

.btn-send {
    background: var(--primary);
    color: white;
    padding: 12px;
    border-radius: 50%;
    width: 48px;
    height: 48px;
}

.btn-send:hover {
    background: var(--primary-dark);
}

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

/* ===== Paint Icon Animation ===== */
.paint-icon {
    width: 80px;
    height: 80px;
    position: relative;
    margin: 0 auto 20px;
}

.paint-icon.small {
    width: 40px;
    height: 40px;
    margin: 0;
}

.drop {
    position: absolute;
    width: 20px;
    height: 30px;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    animation: drip 2s ease-in-out infinite;
}

.paint-icon.small .drop {
    width: 10px;
    height: 15px;
}

.drop-1 {
    background: #E63946;
    left: 10%;
    animation-delay: 0s;
}

.drop-2 {
    background: #2A9D8F;
    left: 40%;
    animation-delay: 0.3s;
}

.drop-3 {
    background: #E9C46A;
    left: 70%;
    animation-delay: 0.6s;
}

@keyframes drip {
    0%, 100% {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    50% {
        transform: translateY(10px) scale(0.95);
        opacity: 0.8;
    }
}

/* ===== Auth Container ===== */
#auth-container {
    background: var(--gradient);
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.auth-card {
    background: var(--surface);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 420px;
}

.logo {
    text-align: center;
    margin-bottom: 30px;
}

.logo h1 {
    font-size: 24px;
    color: var(--secondary);
}

.logo .subtitle {
    font-size: 14px;
    color: var(--primary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* ===== Auth Forms ===== */
.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.auth-form h2 {
    text-align: center;
    margin-bottom: 24px;
    color: var(--secondary);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text);
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

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

.toggle-text {
    text-align: center;
    margin-top: 20px;
    color: var(--text-light);
}

.toggle-text a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.toggle-text a:hover {
    text-decoration: underline;
}

.error-message {
    background: #FEE2E2;
    color: var(--error);
    padding: 12px;
    border-radius: 8px;
    margin-top: 16px;
    text-align: center;
    display: none;
}

.error-message.show {
    display: block;
}

/* ===== Chat Container ===== */
#chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* ===== Chat Header ===== */
.chat-header {
    background: var(--surface);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px var(--shadow);
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-title h1 {
    font-size: 20px;
    color: var(--secondary);
}

.user-name {
    font-size: 14px;
    color: var(--text-light);
}

.header-right {
    display: flex;
    gap: 8px;
}

/* ===== Chat Main ===== */
.chat-main {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--background);
}

.messages {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ===== Welcome Message ===== */
.welcome-message {
    text-align: center;
    padding: 40px;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 4px 20px var(--shadow);
}

.paint-palette {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.paint-palette span {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: block;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease;
}

.paint-palette span:hover {
    transform: scale(1.2);
}

.welcome-message h2 {
    color: var(--secondary);
    margin-bottom: 16px;
}

.welcome-message ul {
    text-align: left;
    display: inline-block;
    margin: 16px 0;
}

.welcome-message li {
    margin: 8px 0;
    color: var(--text-light);
}

.welcome-message .hint {
    margin-top: 24px;
    padding: 16px;
    background: #E8F5F3;
    border-radius: 8px;
    color: var(--primary-dark);
    font-style: italic;
}

/* ===== Message Bubbles ===== */
.message {
    max-width: 80%;
    padding: 16px 20px;
    border-radius: 16px;
    animation: fadeIn 0.3s ease;
}

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

.message.user {
    background: var(--gradient);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message.assistant {
    background: var(--surface);
    color: var(--text);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 10px var(--shadow);
}

.message-content {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-content p {
    margin-bottom: 8px;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul,
.message-content ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-content li {
    margin: 4px 0;
}

.message-content strong {
    color: var(--primary-dark);
}

/* ===== Image in Message ===== */
.message-image {
    margin-top: 12px;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.message-image:hover {
    transform: scale(1.02);
}

.message-image img {
    width: 100%;
    max-width: 400px;
    display: block;
    border-radius: 12px;
}

/* ===== Typing Indicator ===== */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px 20px;
    background: var(--surface);
    border-radius: 16px;
    align-self: flex-start;
    box-shadow: 0 2px 10px var(--shadow);
}

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

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

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

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

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

/* ===== Chat Footer ===== */
.chat-footer {
    background: var(--surface);
    padding: 16px 24px;
    box-shadow: 0 -2px 10px var(--shadow);
}

.chat-input-container {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
    align-items: center;
}

#chat-input {
    flex: 1;
    padding: 14px 20px;
    border: 2px solid var(--border);
    border-radius: 24px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

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

/* ===== Loading Overlay ===== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner {
    background: var(--surface);
    padding: 32px 48px;
    border-radius: 16px;
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

/* ===== Modal ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
}

.modal-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: 8px;
}

.modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 32px;
    cursor: pointer;
    padding: 8px;
}

.modal-close:hover {
    color: var(--accent);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .auth-card {
        padding: 24px;
    }

    .chat-header {
        padding: 12px 16px;
    }

    .header-title h1 {
        font-size: 16px;
    }

    .chat-main {
        padding: 16px;
    }

    .message {
        max-width: 90%;
        padding: 12px 16px;
    }

    .chat-footer {
        padding: 12px 16px;
    }

    .welcome-message {
        padding: 24px;
    }

    .paint-palette span {
        width: 30px;
        height: 30px;
    }
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--background);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-light);
}
