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

html {
    font-size: 16px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
    background:
        linear-gradient(rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.35)),
        linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
    color: var(--color-text-primary);
}

.container {
    width: 100%;
    max-width: 800px;
    height: min(90vh, calc(100vh - 16px));
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.header {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    padding: 20px 16px;
    text-align: center;
    flex-shrink: 0;
}

.header h1 {
    font-size: 1.75rem;
    margin-bottom: 4px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.subtitle {
    font-size: 0.875rem;
    opacity: 0.9;
    font-weight: 400;
    letter-spacing: 0.3px;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    background: var(--color-bg-light);
    display: flex;
    flex-direction: column;
}

.welcome-message {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    padding: 40px 20px;
    color: var(--color-text-secondary);
    margin: auto;
}

.welcome-message h2 {
    color: var(--color-primary);
    margin-bottom: 10px;
    font-size: 1.5rem;
}

.welcome-message p {
    font-size: 1rem;
    opacity: 0.8;
}

.message {
    margin-bottom: 16px;
    display: flex;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    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-content {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    line-height: 1.5;
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-content {
    background: white;
    color: var(--color-text-primary);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-content a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.message-content a:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

.message.user .message-content a {
    color: white;
}

.input-container {
    padding: 16px;
    background: white;
    border-top: 1px solid var(--color-border-light);
    display: flex;
    gap: 10px;
    flex-shrink: 0;
}

#userInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--color-border-light);
    border-radius: 24px;
    font-size: 15px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    color: var(--color-text-primary);
}

#userInput::placeholder {
    color: var(--color-text-tertiary);
}

#userInput:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-transparent-10);
}

#sendButton {
    padding: 12px 28px;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 24px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

#sendButton:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--color-primary-transparent-40);
}

#sendButton:active:not(:disabled) {
    transform: translateY(0);
}

#sendButton:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

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

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

.chat-container::-webkit-scrollbar-thumb {
    background: var(--color-primary-transparent-20);
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--color-primary-transparent-40);
}

/* Loading indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--color-text-secondary);
    border-radius: 50%;
    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);
    }
}

/* ========== MOBILE RESPONSIVE DESIGN ========== */

/* Small phones (320px - 480px) */
@media (max-width: 480px) {
    html {
        font-size: 14px;
    }

    .header {
        padding: 16px 12px;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .subtitle {
        font-size: 0.75rem;
    }

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

    .welcome-message {
        padding: 30px 16px;
    }

    .welcome-message h2 {
        font-size: 1.25rem;
    }

    .message-content {
        max-width: 95%;
        padding: 10px 14px;
        font-size: 0.95rem;
    }

    .input-container {
        padding: 12px;
        gap: 8px;
    }

    #userInput {
        padding: 10px 14px;
        font-size: 14px;
    }

    #sendButton {
        padding: 10px 24px;
        font-size: 14px;
    }
}

/* Medium phones (481px - 768px) */
@media (max-width: 768px) {
    .container {
        height: min(90vh, calc(100vh - 16px));
        border-radius: 16px;
    }

    .header {
        padding: 18px 14px;
    }

    .header h1 {
        font-size: 1.625rem;
    }

    .chat-container {
        padding: 18px 14px;
    }

    .message-content {
        max-width: 90%;
        padding: 11px 15px;
    }

    .input-container {
        padding: 14px;
        gap: 9px;
    }

    #userInput {
        padding: 11px 15px;
        font-size: 14px;
    }

    #sendButton {
        padding: 11px 26px;
        font-size: 14px;
    }
}

/* Landscape orientation */
@media (max-height: 600px) {
    .container {
        height: min(100vh, 100%);
        border-radius: 8px;
    }

    .header {
        padding: 12px;
    }

    .header h1 {
        font-size: 1.25rem;
        margin-bottom: 2px;
    }

    .subtitle {
        font-size: 0.75rem;
    }

    .chat-container {
        padding: 12px;
    }

    .message-content {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .input-container {
        padding: 10px;
        gap: 8px;
    }

    #userInput {
        padding: 8px 12px;
        font-size: 13px;
    }

    #sendButton {
        padding: 8px 20px;
        font-size: 13px;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    body {
        background: linear-gradient(135deg, #460000 0%, #330000 100%);
    }

    .container {
        background: #1e1e1e;
        color: #f0f0f0;
    }

    .chat-container {
        background: #252525;
    }

    .welcome-message {
        color: #aaa;
    }

    .welcome-message h2 {
        color: var(--color-primary-light);
    }

    .message.assistant .message-content {
        background: #333;
        color: #f0f0f0;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    }

    #userInput {
        background: #333;
        color: #f0f0f0;
        border-color: #444;
    }

    #userInput::placeholder {
        color: #999;
    }

    #userInput:focus {
        border-color: var(--color-primary);
        box-shadow: 0 0 0 3px var(--color-primary-transparent-10);
    }

    .input-container {
        background: #1e1e1e;
        border-top-color: #333;
    }
}
