/* ── CSS Variables ─────────────────────────────────────── */
:root {
--sidebar-w: 280px;
--sidebar-collapsed-w: 0px;
--bg-main: #ffffff;
--bg-sidebar: #f3f4f6;
--bg-card: #f9fafb;
--bg-card-hover: #e5e7eb;
--bg-input: #f1f5f9;
--accent-1: #5ea4d5;
--accent-2: #f89462;
--accent-3: #06d6a0;
--accent-story: #ffb347;
--accent-poem: #4ea8de;
--text-primary: #22223b;
--text-secondary: #4a4e69;
--text-muted: #9a8c98;
--border: rgba(0, 0, 0, 0.08);
--bubble-user-bg: linear-gradient(135deg, #ffd166, #06d6a0);
--bubble-ai-bg: #f9fafb;
--radius: 18px;
--radius-sm: 10px;
--shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

/* ── Base ──────────────────────────────────────────────── */
*,
*::before,
*::after {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html,
body {
height: 100%;
overflow: hidden;
}
body {
font-family: "Nunito", sans-serif;
background: var(--bg-main);
color: var(--text-primary);
display: flex;
}

/* ── Sidebar ───────────────────────────────────────────── */
#sidebar {
width: var(--sidebar-w);
min-width: var(--sidebar-w);
height: 100vh;
background: var(--bg-sidebar);
border-right: 1px solid var(--border);
display: flex;
flex-direction: column;
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
overflow: hidden;
position: relative;
z-index: 100;
}
#sidebar.collapsed {
width: 0;
min-width: 0;
border-right: none;
}

.sidebar-header {
padding: 20px 16px 16px;
border-bottom: 1px solid var(--border);
flex-shrink: 0;
}
.brand {
display: flex;
align-items: center;
gap: 10px;
text-decoration: none;
}
/* branding as images instead of orange gradient */
.brand-icon {
width: 50rem; 
height: 50rem;
flex-shrink: 0;
}
.brand-icon img {
width: 100%;
height: 100%;
object-fit: contain;
display: block;
}
.brand-text {
/* we'll turn into an inline image; remove text gradient styling */
font-family: "Baloo 2", cursive;
font-weight: 800;
font-size: 1.2rem;
white-space: nowrap;
}
.brand-text img {
height: 79px;
object-fit: contain;
display: block;
}

.new-chat-btn {
margin: 14px 12px 0;
padding: 10px 14px;
background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
border: none;
border-radius: var(--radius-sm);
color: white;
font-family: "Nunito", sans-serif;
font-weight: 700;
font-size: 0.9rem;
cursor: pointer;
display: flex;
align-items: center;
gap: 8px;
transition:
    opacity 0.2s,
    transform 0.15s;
width: calc(100% - 24px);
white-space: nowrap;
}
.new-chat-btn:hover {
opacity: 0.9;
transform: translateY(-1px);
}

/* Type selector pills */
.type-selector {
padding: 14px 12px 10px;
display: flex;
gap: 8px;
border-bottom: 1px solid var(--border);
}
.type-pill {
flex: 1;
padding: 8px 6px;
border-radius: 50px;
border: 1.5px solid var(--border);
background: transparent;
color: var(--text-secondary);
font-family: "Nunito", sans-serif;
font-size: 0.8rem;
font-weight: 700;
cursor: pointer;
text-align: center;
transition: all 0.2s;
white-space: nowrap;
}
.type-pill.active[data-type="story"] {
border-color: var(--accent-story);
background: rgba(255, 179, 71, 0.12);
color: var(--accent-story);
}
.type-pill.active[data-type="poem"] {
border-color: var(--accent-poem);
background: rgba(168, 224, 99, 0.12);
color: var(--accent-poem);
}

/* Sidebar menu */
.sidebar-menu {
flex: 1;
overflow-y: auto;
padding: 12px 8px;
scrollbar-width: thin;
scrollbar-color: var(--text-muted) transparent;
}
.sidebar-menu-label {
font-size: 0.7rem;
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.1em;
color: var(--text-muted);
padding: 8px 8px 4px;
}
.sidebar-link {
display: flex;
align-items: center;
gap: 10px;
padding: 10px 10px;
border-radius: 8px;
color: var(--text-secondary);
text-decoration: none;
font-size: 0.85rem;
font-weight: 600;
transition: all 0.15s;
cursor: pointer;
white-space: nowrap;
overflow: hidden;
}
.sidebar-link:hover {
background: var(--bg-card-hover);
color: var(--text-primary);
}
.sidebar-link .si-icon {
font-size: 1rem;
flex-shrink: 0;
}

/* Rate limit badge in sidebar */
.rate-badge {
margin: 0 12px 12px;
padding: 12px;
background: var(--bg-card);
border-radius: var(--radius-sm);
border: 1px solid var(--border);
}
.rate-badge-label {
font-size: 0.72rem;
color: var(--text-muted);
font-weight: 700;
text-transform: uppercase;
letter-spacing: 0.08em;
margin-bottom: 6px;
}
.rate-bar-wrap {
background: rgba(255, 255, 255, 0.07);
border-radius: 50px;
height: 6px;
overflow: hidden;
margin-bottom: 5px;
}
.rate-bar {
height: 100%;
border-radius: 50px;
background: linear-gradient(90deg, var(--accent-2), var(--accent-1));
transition: width 0.4s ease;
}
.rate-text {
font-size: 0.75rem;
color: var(--text-secondary);
font-weight: 600;
}

/* ── Main chat area ────────────────────────────────────── */
#main {
flex: 1;
display: flex;
flex-direction: column;
height: 100vh;
min-width: 0;
overflow: hidden;
}

/* Topbar */
#topbar {
height: 58px;
display: flex;
align-items: center;
padding: 0 16px;
border-bottom: 1px solid var(--border);
gap: 12px;
flex-shrink: 0;
background: var(--bg-main);
}
#toggle-sidebar {
background: none;
border: 1px solid var(--border);
color: var(--text-secondary);
width: 36px;
height: 36px;
border-radius: 8px;
cursor: pointer;
display: grid;
place-items: center;
font-size: 1.1rem;
transition: all 0.2s;
flex-shrink: 0;
}
#toggle-sidebar:hover {
background: var(--bg-card);
color: var(--text-primary);
}

.topbar-title {
font-family: "Baloo 2", cursive;
font-weight: 700;
font-size: 1rem;
background: linear-gradient(90deg, var(--accent-1), var(--accent-2));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.topbar-badge {
margin-left: auto;
font-size: 0.75rem;
font-weight: 700;
padding: 4px 10px;
border-radius: 50px;
background: var(--bg-card);
border: 1px solid var(--border);
color: var(--text-secondary);
white-space: nowrap;
}

/* Chat messages */
#chat-messages {
flex: 1;
overflow-y: auto;
padding: 24px 16px;
display: flex;
flex-direction: column;
gap: 20px;
scrollbar-width: thin;
scrollbar-color: var(--text-muted) transparent;
}

/* Welcome screen */
#welcome-screen {
background-image: url("/images/mainlogo.png");
background-repeat: no-repeat;
background-position: center;
background-size: contain;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
flex: 1;
text-align: center;
padding: 40px 20px;
gap: 20px;
}
.welcome-icon {
width: 80px;
height: 80px;
background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
border-radius: 24px;
display: grid;
place-items: center;
font-size: 40px;
animation: float 3s ease-in-out infinite;
}
@keyframes float {
0%,
100% {
    transform: translateY(0);
}
50% {
    transform: translateY(-10px);
}
}
.welcome-title {
font-family: "Baloo 2", cursive;
font-size: clamp(1.6rem, 5vw, 2.4rem);
font-weight: 800;
line-height: 1.2;
}
.welcome-title span {
background: linear-gradient(
    90deg,
    var(--accent-1),
    var(--accent-2),
    var(--accent-3)
);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.welcome-subtitle {
color: var(--text-secondary);
font-size: 0.95rem;
max-width: 380px;
line-height: 1.6;
}
.suggestion-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 10px;
width: 100%;
max-width: 600px;
}
.suggestion-card {
background: var(--bg-card);
border: 1px solid var(--border);
border-radius: var(--radius-sm);
padding: 14px;
cursor: pointer;
text-align: left;
transition: all 0.2s;
}
.suggestion-card:hover {
background: var(--bg-card-hover);
border-color: var(--accent-2);
transform: translateY(-2px);
}
.suggestion-card .sc-emoji {
font-size: 1.5rem;
margin-bottom: 6px;
display: block;
}
.suggestion-card .sc-title {
font-size: 0.82rem;
font-weight: 700;
color: var(--text-primary);
margin-bottom: 2px;
}
.suggestion-card .sc-desc {
font-size: 0.75rem;
color: var(--text-muted);
}

/* Message bubbles */
.msg-row {
display: flex;
gap: 12px;
max-width: 820px;
width: 100%;
margin: 0 auto;
animation: msgIn 0.3s ease;
}
@keyframes msgIn {
from {
    opacity: 0;
    transform: translateY(12px);
}
to {
    opacity: 1;
    transform: translateY(0);
}
}
.msg-row.user {
flex-direction: row-reverse;
}

.msg-avatar {
width: 36px;
height: 36px;
border-radius: 10px;
display: grid;
place-items: center;
font-size: 1.1rem;
flex-shrink: 0;
}
.msg-avatar.ai-av {
background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
}
.msg-avatar.user-av {
background: linear-gradient(135deg, #4facfe, #00f2fe);
}

.msg-bubble {
border-radius: var(--radius);
padding: 14px 18px;
font-size: 0.92rem;
line-height: 1.75;
max-width: calc(100% - 60px);
word-wrap: break-word;
white-space: pre-wrap;
}
.msg-bubble.user {
background: linear-gradient(135deg, #6a11cb, #a855f7);
color: white;
border-bottom-right-radius: 4px;
}
.msg-bubble.ai {
background: var(--bg-card);
color: var(--text-primary);
border-bottom-left-radius: 4px;
border: 1px solid var(--border);
}
.msg-bubble.ai.poem {
font-family: "Baloo 2", cursive;
font-size: 0.95rem;
}
.msg-type-tag {
display: inline-flex;
align-items: center;
gap: 4px;
font-size: 0.7rem;
font-weight: 700;
padding: 2px 8px;
border-radius: 50px;
margin-bottom: 8px;
}
.msg-type-tag.story {
background: rgba(255, 179, 71, 0.15);
color: var(--accent-story);
}
.msg-type-tag.poem {
background: rgba(168, 224, 99, 0.15);
color: var(--accent-poem);
}

/* Typing indicator */
.typing-indicator {
display: flex;
align-items: center;
gap: 4px;
padding: 14px 18px;
background: var(--bg-card);
border-radius: var(--radius);
border-bottom-left-radius: 4px;
border: 1px solid var(--border);
width: fit-content;
}
.typing-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: var(--accent-2);
animation: bounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) {
animation-delay: 0.2s;
}
.typing-dot:nth-child(3) {
animation-delay: 0.4s;
}
@keyframes bounce {
0%,
60%,
100% {
    transform: translateY(0);
}
30% {
    transform: translateY(-8px);
}
}

/* ── Input area ────────────────────────────────────────── */
#input-area {
padding: 12px 16px 20px;
border-top: 1px solid var(--border);
background: var(--bg-main);
flex-shrink: 0;
}
.input-wrap {
max-width: 820px;
margin: 0 auto;
background: var(--bg-input);
border: 1.5px solid var(--border);
border-radius: var(--radius);
display: flex;
flex-direction: column;
gap: 0;
transition: border-color 0.2s;
}
.input-wrap:focus-within {
border-color: var(--accent-2);
}
#prompt-input {
background: none;
border: none;
outline: none;
color: var(--text-primary);
font-family: "Nunito", sans-serif;
font-size: 0.92rem;
padding: 14px 16px 6px;
resize: none;
min-height: 52px;
max-height: 200px;
line-height: 1.6;
}
#prompt-input::placeholder {
color: var(--text-muted);
}
.input-toolbar {
display: flex;
align-items: center;
padding: 8px 10px;
gap: 6px;
}
.input-type-switch {
display: flex;
gap: 4px;
}
.it-btn {
padding: 5px 12px;
border-radius: 50px;
border: 1.5px solid var(--border);
background: none;
font-family: "Nunito", sans-serif;
font-size: 0.75rem;
font-weight: 700;
color: var(--text-muted);
cursor: pointer;
transition: all 0.15s;
}
.it-btn.active[data-type="story"] {
border-color: var(--accent-story);
background: rgba(255, 179, 71, 0.12);
color: var(--accent-story);
}
.it-btn.active[data-type="poem"] {
border-color: var(--accent-poem);
background: rgba(168, 224, 99, 0.12);
color: var(--accent-poem);
}
.char-counter {
margin-left: auto;
font-size: 0.72rem;
color: var(--text-muted);
font-weight: 600;
}
#send-btn {
width: 38px;
height: 38px;
border-radius: 10px;
border: none;
background: linear-gradient(135deg, var(--accent-1), var(--accent-2));
color: white;
cursor: pointer;
display: grid;
place-items: center;
font-size: 1rem;
transition:
    opacity 0.2s,
    transform 0.15s;
flex-shrink: 0;
}
#send-btn:hover:not(:disabled) {
opacity: 0.85;
transform: scale(1.05);
}
#send-btn:disabled {
opacity: 0.4;
cursor: not-allowed;
transform: none;
}

.input-hint {
text-align: center;
font-size: 0.7rem;
color: var(--text-muted);
margin-top: 8px;
}

/* ── Toast ─────────────────────────────────────────────── */
.toast-container {
z-index: 9999 !important;
}

/* ── Overlay (mobile) ──────────────────────────────────── */
#sidebar-overlay {
display: none;
position: fixed;
inset: 0;
background: rgba(0, 0, 0, 0.5);
z-index: 99;
}

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
#sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 200;
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
    min-width: var(--sidebar-w) !important;
}
#sidebar.mobile-open {
    transform: translateX(0);
}
#sidebar.collapsed {
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
}
#sidebar-overlay.show {
    display: block;
}
.suggestion-grid {
    grid-template-columns: 1fr 1fr;
}
}

@media (max-width: 480px) {
.suggestion-grid {
    grid-template-columns: 1fr;
}
.welcome-icon {
    width: 60px;
    height: 60px;
    font-size: 30px;
}
}