/* Tutkulu Zeka Chat — v2 */
:root {
    --red: #C8102E; --red-dark: #A00D24; --red-glow: #E8304A;
    --brown: #3C1518; --brown-deep: #2A0E10; --brown-light: #5A2328;
    --gold: #D4A853; --dark: #1A0A0D; --dark-card: #231214;
    --cream: #FFF8F0; --cream-dim: #BBA998; --sidebar-w: 280px;
}
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
    font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
    background: var(--dark); color: var(--cream);
    display: flex; -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }

/* ═══ SIDEBAR ═══ */
.sidebar {
    width: var(--sidebar-w); min-width: var(--sidebar-w); background: var(--brown-deep);
    border-right: 1px solid rgba(200,16,46,.12); display: flex; flex-direction: column;
    height: 100vh; z-index: 100; transition: transform .25s ease;
}
.sidebar-header { padding: 1rem; }
.new-chat-btn {
    width: 100%; padding: .75rem; background: rgba(200,16,46,.15);
    border: 1px dashed rgba(200,16,46,.4); border-radius: .5rem;
    color: var(--cream); font-size: .9rem; font-weight: 600;
    cursor: pointer; transition: background .15s; display: flex; align-items: center; gap: .5rem; justify-content: center;
}
.new-chat-btn:hover { background: rgba(200,16,46,.25); }
.conv-list {
    flex: 1; overflow-y: auto; padding: .25rem .5rem;
    scrollbar-width: thin; scrollbar-color: var(--brown-light) transparent;
}
.conv-list::-webkit-scrollbar { width: 4px; }
.conv-list::-webkit-scrollbar-thumb { background: var(--brown-light); border-radius: 4px; }
.conv-item {
    padding: .65rem .75rem; border-radius: .5rem; cursor: pointer; font-size: .85rem;
    color: var(--cream-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: background .12s; display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
.conv-item:hover { background: rgba(200,16,46,.1); color: var(--cream); }
.conv-item.active { background: rgba(200,16,46,.2); color: var(--cream); }
.conv-title { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.conv-delete {
    opacity: 0; font-size: .75rem; color: var(--cream-dim);
    background: none; border: none; cursor: pointer; padding: .2rem .4rem; border-radius: 4px;
}
.conv-item:hover .conv-delete { opacity: .6; }
.conv-delete:hover { opacity: 1 !important; background: rgba(200,16,46,.3); color: var(--cream); }
.sidebar-footer {
    padding: 1rem; border-top: 1px solid rgba(200,16,46,.1);
    display: flex; align-items: center; justify-content: space-between;
}
.user-info { display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.user-avatar {
    width: 28px; height: 28px; background: var(--red-dark); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: .7rem; font-weight: 700; color: white;
}
.logout-btn {
    background: none; border: none; color: var(--cream-dim); font-size: .8rem;
    cursor: pointer; padding: .3rem .6rem; border-radius: 4px; transition: background .12s;
}
.logout-btn:hover { background: rgba(200,16,46,.15); color: var(--cream); }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 90; }
.sidebar-overlay.open { display: block; }

/* ═══ CHAT MAIN ═══ */
.chat-main { flex: 1; display: flex; flex-direction: column; height: 100vh; min-width: 0; }
.chat-header {
    height: 56px; padding: 0 1.25rem; display: flex; align-items: center; gap: 1rem;
    border-bottom: 1px solid rgba(200,16,46,.1); background: var(--brown-deep); flex-shrink: 0;
}
.menu-btn {
    display: none; background: none; border: none; color: var(--cream);
    font-size: 1.25rem; cursor: pointer; padding: .3rem .5rem; border-radius: 4px;
}
.menu-btn:hover { background: rgba(200,16,46,.15); }
.header-brand { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1rem; }
.brand-icon { font-size: 1.25rem; }
.header-status {
    margin-left: auto; display: flex; align-items: center; gap: .4rem;
    font-size: .75rem; color: var(--cream-dim);
}
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: #10B981; flex-shrink: 0; }

/* ═══ MESSAGES ═══ */
.chat-messages {
    flex: 1; overflow-y: auto; padding: 1.5rem clamp(1rem,4vw,3rem);
    display: flex; flex-direction: column; gap: 1.25rem;
    scrollbar-width: thin; scrollbar-color: var(--brown-light) transparent;
}
.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--brown-light); border-radius: 6px; }

/* Welcome */
.welcome-msg {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center; padding: 3rem 1rem; flex: 1;
}
.welcome-icon { font-size: 3rem; margin-bottom: 1rem; }
.welcome-msg h2 { font-size: 1.5rem; margin-bottom: .5rem; }
.welcome-msg p { color: var(--cream-dim); margin-bottom: 2rem; max-width: 400px; line-height: 1.6; }
.quick-prompts { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; max-width: 600px; }
.quick-prompt {
    background: rgba(200,16,46,.12); border: 1px solid rgba(200,16,46,.25);
    color: var(--cream); padding: .6rem 1rem; border-radius: 9999px;
    font-size: .85rem; cursor: pointer; transition: all .15s;
}
.quick-prompt:hover { background: rgba(200,16,46,.25); border-color: rgba(200,16,46,.5); transform: translateY(-1px); }

/* Messages */
.msg-row { display: flex; align-items: flex-start; gap: .75rem; max-width: 800px; animation: msgIn .3s ease; }
.msg-row.user { align-self: flex-end; flex-direction: row-reverse; }
.msg-row.assistant { align-self: flex-start; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.msg-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: .85rem;
}
.msg-row.assistant .msg-avatar { background: linear-gradient(135deg, var(--red), var(--red-dark)); }
.msg-row.user .msg-avatar { background: var(--brown); }
.msg-bubble {
    padding: .85rem 1.1rem; border-radius: 1rem; font-size: .92rem; line-height: 1.65;
    max-width: 600px; word-wrap: break-word; position: relative;
}
.msg-row.user .msg-bubble { background: var(--red-dark); color: white; border-bottom-right-radius: 4px; }
.msg-row.assistant .msg-bubble {
    background: var(--dark-card); border: 1px solid rgba(200,16,46,.1); border-bottom-left-radius: 4px;
}
.msg-bubble img { max-width: 100%; border-radius: .5rem; margin-top: .5rem; }
.msg-actions {
    position: absolute; top: -.5rem; right: .5rem; opacity: 0; transition: opacity .15s;
    display: flex; gap: .25rem;
}
.msg-bubble:hover .msg-actions { opacity: 1; }
.msg-action-btn {
    background: var(--brown-deep); border: 1px solid rgba(200,16,46,.2); color: var(--cream-dim);
    width: 24px; height: 24px; border-radius: 4px; cursor: pointer; font-size: .65rem;
    display: flex; align-items: center; justify-content: center; transition: all .12s;
}
.msg-action-btn:hover { background: var(--red-dark); color: white; }
.typing-indicator { display: flex; gap: 4px; padding: .5rem 0; }
.typing-indicator span {
    width: 6px; height: 6px; border-radius: 50%; background: var(--cream-dim);
    animation: typeBounce 1.2s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: .15s; }
.typing-indicator span:nth-child(3) { animation-delay: .3s; }
@keyframes typeBounce { 0%,60%,100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }

/* ═══ INPUT ═══ */
.input-area {
    padding: .75rem clamp(1rem,4vw,3rem) 1rem;
    border-top: 1px solid rgba(200,16,46,.08); background: var(--dark); flex-shrink: 0;
}
.input-wrapper {
    display: flex; align-items: flex-end; gap: .5rem;
    background: var(--dark-card); border: 1px solid rgba(200,16,46,.15);
    border-radius: 1rem; padding: .5rem .5rem .5rem .75rem;
    max-width: 800px; margin: 0 auto; transition: border-color .15s;
}
.input-wrapper:focus-within { border-color: rgba(200,16,46,.4); }
.msg-input {
    flex: 1; background: none; border: none; outline: none;
    color: var(--cream); font-size: .92rem; font-family: inherit;
    resize: none; max-height: 120px; line-height: 1.5; padding: .3rem 0;
}
.msg-input::placeholder { color: var(--cream-dim); opacity: .5; }
.send-btn {
    width: 36px; height: 36px; border-radius: 50%; background: var(--red);
    border: none; color: white; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: background .15s, opacity .15s;
}
.send-btn:disabled { opacity: .3; cursor: default; }
.send-btn:not(:disabled):hover { background: var(--red-glow); }

/* ═══ PLUS MENU ═══ */
.plus-menu-container { position: relative; }
.plus-btn {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(200,16,46,.15); border: 1px solid rgba(200,16,46,.3);
    color: var(--cream); font-size: 1.25rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: background .15s, transform .2s;
}
.plus-btn:hover { background: rgba(200,16,46,.3); }
.plus-btn.open { transform: rotate(45deg); }
.plus-menu {
    position: absolute; bottom: calc(100% + 8px); left: 0;
    background: var(--brown-deep); border: 1px solid rgba(200,16,46,.2);
    border-radius: .75rem; overflow: hidden; min-width: 220px;
    box-shadow: 0 8px 32px rgba(0,0,0,.4); animation: menuIn .15s ease;
}
@keyframes menuIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.plus-item {
    display: flex; align-items: center; gap: .5rem; width: 100%;
    padding: .75rem 1rem; background: none; border: none;
    color: var(--cream); font-size: .88rem; cursor: pointer;
    text-align: left; transition: background .12s;
}
.plus-item:hover { background: rgba(200,16,46,.15); }
.plus-item.soon { opacity: .45; cursor: default; }
.plus-item.soon:hover { background: none; }
.soon-badge {
    font-size: .65rem; background: var(--gold); color: var(--dark);
    padding: .1rem .4rem; border-radius: 9999px; font-weight: 600; margin-left: auto;
}

/* ═══ MODAL ═══ */
.modal {
    position: fixed; inset: 0; z-index: 200;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,.6); backdrop-filter: blur(4px);
}
.modal.hidden { display: none; }
.modal-content {
    background: var(--brown-deep); border: 1px solid rgba(200,16,46,.2);
    border-radius: 1rem; width: min(90vw, 500px); max-height: 80vh; overflow-y: auto;
    animation: modalIn .2s ease;
}
@keyframes modalIn { from { opacity: 0; transform: scale(.95); } to { opacity: 1; transform: scale(1); } }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.25rem 1.5rem; border-bottom: 1px solid rgba(200,16,46,.1);
}
.modal-header h3 { font-size: 1.1rem; }
.modal-close {
    background: none; border: none; color: var(--cream-dim); font-size: 1.5rem;
    cursor: pointer; line-height: 1; transition: color .12s;
}
.modal-close:hover { color: var(--cream); }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid rgba(200,16,46,.1); text-align: right; }
.image-prompt {
    width: 100%; background: var(--dark-card); border: 1px solid rgba(200,16,46,.15);
    border-radius: .5rem; padding: .75rem; color: var(--cream);
    font-family: inherit; font-size: .9rem; resize: vertical; outline: none; transition: border-color .15s;
}
.image-prompt:focus { border-color: var(--red); }
.image-prompt::placeholder { color: var(--cream-dim); opacity: .5; }
.image-preview { text-align: center; margin-top: 1rem; }
.image-preview img { max-width: 100%; border-radius: .5rem; }
.image-loading { text-align: center; padding: 2rem; }
.spinner {
    width: 32px; height: 32px; border: 3px solid var(--brown-light);
    border-top-color: var(--red); border-radius: 50%;
    animation: spin .8s linear infinite; margin: 0 auto 1rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ AUTH ═══ */
.auth-modal { padding: 2rem; text-align: center; }
.auth-brand { margin-bottom: 2rem; }
.auth-icon { font-size: 3rem; }
.auth-brand h2 { margin: .5rem 0 .25rem; font-size: 1.5rem; }
.auth-brand p { color: var(--cream-dim); font-size: .9rem; }
.auth-input {
    width: 100%; padding: .8rem 1rem; margin-bottom: .75rem;
    background: var(--dark-card); border: 1px solid rgba(200,16,46,.15);
    border-radius: .5rem; color: var(--cream); font-size: .9rem;
    font-family: inherit; outline: none; transition: border-color .15s;
}
.auth-input:focus { border-color: var(--red); }
.auth-input::placeholder { color: var(--cream-dim); opacity: .6; }
.cta-btn {
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--red), var(--red-dark));
    color: white; font-size: .95rem; font-weight: 600;
    padding: .75rem 2rem; border-radius: 9999px; border: none;
    cursor: pointer; transition: transform .12s, box-shadow .12s;
    box-shadow: 0 4px 16px rgba(200,16,46,.3);
}
.cta-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(200,16,46,.4); }
.cta-btn:active { transform: scale(.97); }
.auth-btn { width: 100%; margin-top: .5rem; }
.auth-switch { margin-top: 1rem; font-size: .85rem; color: var(--cream-dim); }
.auth-switch a { color: var(--gold); text-decoration: none; font-weight: 600; cursor: pointer; }
.auth-error { color: var(--red-glow); font-size: .85rem; margin-top: .75rem; }

/* ═══ TOAST ═══ */
.toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 300; display: flex; flex-direction: column; gap: .5rem; }
.toast {
    background: var(--brown-deep); border: 1px solid rgba(200,16,46,.3); border-radius: .5rem;
    padding: .75rem 1rem; font-size: .85rem; color: var(--cream);
    box-shadow: 0 4px 16px rgba(0,0,0,.4); animation: toastIn .3s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ═══ RESPONSIVE ═══ */
@media (max-width: 768px) {
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .menu-btn { display: flex; }
    .chat-messages { padding: 1rem; }
    .input-area { padding: .5rem .75rem .75rem; }
    .msg-bubble { max-width: 85vw; }
    .quick-prompts { flex-direction: column; align-items: center; }
}
@media (max-width: 480px) {
    .modal-content { width: 95vw; margin: .5rem; }
    .msg-avatar { width: 28px; height: 28px; font-size: .75rem; }
}
@media (min-width: 1440px) {
    .chat-messages { padding: 2rem 4rem; }
    .input-area { padding: 1rem 4rem; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0s !important; transition-duration: 0s !important; }
}
