@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;700&display=swap');

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

:root {
    --blue: #29a7ff;
    --blue-dark: #1e8fd4;
    --green: #a9e03b;
    --orange: #ff7324;
    --bg: #ffffff;
    --bg-gray: #f3f4f6;
    --text: #111827;
    --text-body: #4b5563;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --user-bubble: #29a7ff;
    --assistant-bubble: #f3f4f6;
    --sidebar-width: 280px;
}

html, body {
    height: 100%;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.screen { display: flex; height: 100%; width: 100%; }
.hidden { display: none !important; }

/* tiroir-glow animated brand text */
.tiroir-glow {
    text-transform: lowercase;
    background-image: linear-gradient(
        115deg,
        #a9e03b 0%, #29a7ff 18%, #ff7324 36%,
        #a9e03b 54%, #29a7ff 72%, #ff7324 90%, #a9e03b 108%
    );
    color: transparent;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.08em;
    background-repeat: repeat;
    background-size: 250% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    font-weight: 700;
    animation: 12s linear infinite drawerFlow;
}
@keyframes drawerFlow {
    0% { background-position: 0%; }
    50% { background-position: 100%; }
    100% { background-position: 0%; }
}

/* Auth Screen */
#auth-screen {
    justify-content: center;
    align-items: center;
    flex-direction: column;
    background: var(--bg);
}
.auth-container {
    text-align: center;
    width: 100%;
    max-width: 400px;
    padding: 2rem;
}
.auth-logo {
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem;
}
.logo {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}
.tagline {
    color: var(--text-muted);
    margin-bottom: 2rem;
    font-size: 1rem;
}

/* Hanko Elements Styling */
hanko-auth {
    --color: var(--text);
    --color-shade-1: var(--text-body);
    --brand-color: var(--blue);
    --brand-color-shade-1: var(--blue-dark);
    --background-color: var(--bg);
    --border-radius: 12px;
    --input-min-width: 100%;
}

/* Sidebar */
#sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100%;
}
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}
.sidebar-header .sidebar-logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.sidebar-header .sidebar-logo img {
    width: 28px;
    height: 28px;
}
.sidebar-header .sidebar-logo span {
    font-size: 1.1rem;
}
#new-chat-btn {
    background: linear-gradient(90deg, var(--blue), var(--blue-dark));
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
}
#new-chat-btn:hover { transform: scale(1.05); }

#conversation-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}
.conv-item {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
    font-size: 0.9rem;
    color: var(--text-body);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background 0.15s;
}
.conv-item:hover { background: var(--bg-gray); }
.conv-item.active {
    background: var(--bg-gray);
    color: var(--text);
    font-weight: 500;
}
.conv-item .conv-title {
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}
.conv-item .conv-delete {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0 4px;
    font-size: 1rem;
}
.conv-item:hover .conv-delete { display: block; }

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
}
#logout-btn {
    width: 100%;
    padding: 0.5rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    transition: all 0.2s;
}
#logout-btn:hover { border-color: var(--blue); color: var(--blue); }

/* Chat Area */
#chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg);
    position: relative;
}
#chat-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    color: var(--text);
    background: var(--bg);
}
#menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.3rem;
    cursor: pointer;
}

#messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-muted);
    font-size: 1.1rem;
    pointer-events: none;
    text-align: center;
}
#empty-state img {
    width: 48px;
    height: 48px;
    margin: 0 auto 0.75rem;
    opacity: 0.5;
}
#chat-area:has(.message) #empty-state { display: none; }

.message {
    max-width: 75%;
    padding: 0.75rem 1rem;
    border-radius: 16px;
    line-height: 1.6;
    word-wrap: break-word;
    white-space: pre-wrap;
    font-size: 0.95rem;
}
.message.user {
    align-self: flex-end;
    background: var(--user-bubble);
    color: white;
    border-bottom-right-radius: 4px;
}
.message.assistant {
    align-self: flex-start;
    background: var(--assistant-bubble);
    color: var(--text);
    border-bottom-left-radius: 4px;
}
.message.assistant .thinking {
    display: inline-block;
    color: var(--text-muted);
    animation: pulse 1.5s infinite;
}
@keyframes pulse { 50% { opacity: 0.4; } }

/* Input */
#chat-form {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg);
}
.input-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}
#message-input {
    flex: 1;
    background: var(--bg-gray);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    outline: none;
    transition: border-color 0.2s;
}
#message-input:focus { border-color: var(--blue); }
#send-btn {
    background: linear-gradient(90deg, var(--blue), var(--blue-dark));
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.1rem;
    cursor: pointer;
    flex-shrink: 0;
    transition: all 0.2s;
}
#send-btn:hover { transform: scale(1.05); }
#send-btn:disabled { opacity: 0.4; cursor: default; transform: none; }

/* Sidebar overlay (mobile) */
#sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 9;
}

/* Mobile */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        z-index: 10;
        transition: left 0.2s ease;
        box-shadow: 2px 0 12px rgba(0,0,0,0.1);
    }
    #sidebar.open { left: 0; }
    #menu-btn { display: block; }
    .message { max-width: 90%; }
}
