:root {
    --bg-color: #000000;
    --text-primary: #ffffff;
    --text-secondary: #a8a8a8;
    --border-color: #262626;
    --blue-accent: #0095f6;
    --blue-hover: #1877f2;
    --bubble-sent: #3797f0;
    /* Default solid blue fallback */
    /* Gradient for sent bubbles like actual IG */
    --bubble-sent-gradient: linear-gradient(to right, #7b3dff, #4788ff);
    --bubble-received: #262626;
    --input-bg: #262626;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-family);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 480px;
    /* Mobile width constraint on desktop */
    height: 100%;
    position: relative;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

/* Common Utilities */
.view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-color);
    transition: opacity 0.3s ease;
    z-index: 1;
}

.view.hidden {
    opacity: 0;
    pointer-events: none;
    z-index: 0;
}

.view.active {
    opacity: 1;
    z-index: 10;
}

/* Login View */
.login-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
}

.avatar-large {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    margin-bottom: 2rem;
    border: 2px solid var(--border-color);
    object-fit: cover;
}

h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

#login-form {
    width: 100%;
}

.input-group {
    margin-bottom: 1rem;
    width: 100%;
}

input[type="text"] {
    width: 100%;
    padding: 14px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: white;
    font-size: 14px;
    outline: none;
}

input[type="text"]:focus {
    border-color: var(--text-secondary);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background-color: var(--blue-accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    margin-top: 1rem;
}

/* Chat View */
.chat-header {
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-color);
    justify-content: space-between;
    flex-shrink: 0;
}

.back-btn {
    font-size: 24px;
    margin-right: 16px;
    cursor: pointer;
}

.user-info {
    flex: 1;
    display: flex;
    align-items: center;
}

.avatar-header {
    position: relative;
    width: 32px;
    height: 32px;
    margin-right: 12px;
}

.avatar-header img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.online-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: #00ff00;
    border: 2px solid black;
    border-radius: 50%;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.username {
    font-weight: 600;
    font-size: 14px;
}

.status {
    font-size: 12px;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    gap: 20px;
    font-size: 24px;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.message {
    display: flex;
    align-items: flex-end;
    max-width: 80%;
}

/* Common Bubble Styles */
.message .bubble {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Received (AI) */
.message.received {
    align-self: flex-start;
}

.message.received .msg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    margin-right: 8px;
    object-fit: cover;
}

.message.received .bubble {
    background-color: var(--bubble-received);
    color: white;
    border-radius: 22px;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.4;
}

/* Sent (User) */
.message.sent {
    align-self: flex-end;
}

.message.sent .bubble {
    background: var(--bubble-sent-gradient);
    color: white;
    border-radius: 22px;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.4;
}

/* Chat Input */
.chat-input-area {
    padding: 8px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.cam-icon-circle {
    width: 36px;
    height: 36px;
    background: var(--bubble-received);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--blue-accent);
    font-size: 20px;
    margin-right: 4px;
}

#chat-form {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
    background: var(--input-bg);
    border-radius: 22px;
    padding: 0 16px;
    height: 44px;
}

#message-input {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    padding: 0;
    height: 100%;
    font-size: 14px;
}

.hidden-btn {
    background: transparent;
    border: none;
    color: var(--blue-accent);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: none;
    /* Hidden by default until typing */
}

/* Right icons in input when empty */
.right-icons {
    display: flex;
    gap: 12px;
    color: white;
    font-size: 22px;
}

/* Utility to toggle visibility of send vs icons */
.typing .right-icons {
    display: none;
}

.typing .hidden-btn {
    display: block;
}

/* Typing Indicator */
.message.typing-indicator .bubble {
    background-color: var(--bubble-received);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 4px;
    min-width: 50px;
}

.dot {
    width: 6px;
    height: 6px;
    background-color: #8e8e8e;
    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.0);
    }
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(2px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    transition: opacity 0.2s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal-content {
    background: #262626;
    border-radius: 12px;
    padding: 24px;
    width: 85%;
    max-width: 320px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    transform: scale(1);
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal-content {
    transform: scale(0.9);
}

.modal-content h3 {
    margin-bottom: 12px;
    font-size: 18px;
    font-weight: 600;
}

.modal-content p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
    white-space: pre-wrap;
    line-height: 1.5;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-actions button {
    margin-top: 0;
    padding: 10px 20px;
    font-size: 14px;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: white;
    border-radius: 6px;
    padding: 10px 20px;
    cursor: pointer;
    font-weight: 600;
}