@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400&display=swap');

:root {
    --bg-main: #fcfcfd;
    --bg-panel: #ffffff;
    --bg-chat: #f9fafb;
    --border: #e4e4e7;
    --text-main: #18181b;
    --text-muted: #71717a;
    /* --clr ve --txt PHP içinden dinamik olarak gelecek */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { 
    position: fixed; 
    top: 0; left: 0; right: 0; bottom: 0; 
    width: 100%; height: 100%; 
    overflow: hidden; 
    font-family: 'Inter', sans-serif; 
    background: transparent; 
    color: var(--text-main); 
    -webkit-font-smoothing: antialiased; 
    margin: 0; padding: 0; 
}

.app { 
    height: 100%; 
    display: flex; flex-direction: column; 
    width: 100%; max-width: 900px; 
    margin: 0 auto; 
    background: var(--bg-panel); 
    overflow: hidden; position: relative; 
}

@media (min-width: 861px) {
    html, body { position: static; overflow: auto; background: #f4f4f5; padding: 20px; }
    .app { height: calc(100vh - 40px); border-radius: 20px; border: 1px solid var(--border); box-shadow: 0 10px 40px rgba(0,0,0,0.08); }
}

.header { 
    padding: 1rem 1.5rem; 
    background: rgba(255, 255, 255, 0.85); 

    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0,0,0,0.05); 
    display: flex; align-items: center; gap: 14px; 
    flex-shrink: 0; z-index: 10; position: sticky; top: 0;
}
.avatar { width: 42px; height: 42px; border-radius: 12px; background: var(--clr); color: var(--txt); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.1rem; flex-shrink: 0; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
.header-info { flex: 1; min-width: 0; }
.header-title { font-weight: 600; font-size: 1.05rem; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -0.01em; }
.header-status { font-size: 0.8rem; color: var(--text-muted); display: flex; align-items: center; gap: 5px; font-weight: 500; margin-top: 2px; }
.header-status .status-dot { color: #10b981; font-size: 0.4rem; animation: pulse 2s infinite; margin-right: 2px; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }

.header-actions { display: flex; gap: 6px; }
.action-btn { background: transparent; border: none; color: var(--text-muted); width: 38px; height: 38px; border-radius: 50%; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; justify-content: center; font-size: 1.05rem; }
.action-btn:hover { background: #f4f4f5; color: #ef4444; transform: scale(1.05); }

.chat { 
    flex: 1 1 auto; 
    overflow-y: auto; 
    -webkit-overflow-scrolling: touch; 
    padding: 1.5rem; 
    scroll-behavior: smooth; 
    background: var(--bg-chat); 
    display: flex; flex-direction: column; 
}
.row { display: flex; width: 100%; margin-bottom: 1.5rem; animation: springUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.1) forwards; opacity: 0; transform-origin: bottom; }
.bubble { max-width: 85%; padding: 0.9rem 1.2rem; font-size: 0.95rem; line-height: 1.6; word-break: break-word; }

.row.user { justify-content: flex-end; }
.row.user .bubble { background: var(--clr); color: var(--txt); border-radius: 20px 20px 4px 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
.row.ai .bubble { background: #ffffff; border: 1px solid rgba(0,0,0,0.04); box-shadow: 0 4px 15px rgba(0,0,0,0.03); border-radius: 20px 20px 20px 4px; color: var(--text-main); }

.prose { margin: 0; }
.prose p { margin: 0 0 0.8rem 0; }
.prose p:last-child { margin-bottom: 0; }
.prose strong { font-weight: 600; color: inherit; }
.prose ul, .prose ol { padding-left: 1.2rem; margin: 0 0 0.8rem 0; }
.prose pre { background: #18181b !important; color: #e4e4e7; border-radius: 12px; padding: 1rem; overflow-x: auto; margin: 0.8rem 0; font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; }
.prose code:not(pre code) { background: rgba(0,0,0,0.06); color: #ef4444; padding: 2px 6px; border-radius: 6px; font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; }
.row.user .prose code:not(pre code) { background: rgba(255,255,255,0.2); color: inherit; }
.prose a { color: inherit; text-decoration: underline; text-underline-offset: 3px; }
.prose img { max-width: 100%; border-radius: 12px; margin-top: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }

@keyframes springUp { from { opacity: 0; transform: translateY(20px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }

.dots { display: flex; align-items: center; gap: 4px; height: 24px; padding: 0 4px; }
.dots span { width: 6px; height: 6px; background: #a1a1aa; border-radius: 50%; animation: blink 1.4s infinite; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.4; transform: scale(0.8); } 40% { opacity: 1; transform: scale(1.2); background: var(--text-main); } }

.footer { padding: 1rem 1.5rem calc(1.5rem + env(safe-area-inset-bottom)) 1.5rem; background: linear-gradient(180deg, rgba(255,255,255,0) 0%, #ffffff 20%); flex-shrink: 0; z-index: 10; }
.input-container { background: #ffffff; border: 1px solid rgba(0,0,0,0.08); border-radius: 26px; display: flex; flex-direction: column; padding: 0.4rem; transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 4px 20px rgba(0,0,0,0.04); }
.input-container:focus-within { border-color: rgba(0,0,0,0.15); box-shadow: 0 8px 30px rgba(0,0,0,0.08); }
.input-row { display: flex; align-items: flex-end; gap: 8px; position: relative; }

#msgInput { flex: 1; background: transparent; border: none; outline: none; resize: none; font-family: 'Inter', sans-serif; font-size: 1rem; color: var(--text-main); line-height: 1.5; padding: 10px 4px; max-height: 150px; overflow-y: auto; }
#msgInput::placeholder { color: #a1a1aa; }
#msgInput::-webkit-scrollbar { display: none; }

.btn-icon { width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s ease; flex-shrink: 0; font-size: 1.1rem; padding: 0; margin-bottom: 3px; }
.btn-attach { background: transparent; color: #a1a1aa; margin-left: 4px; }
.btn-attach:hover { background: #e4e4e7; color: var(--text-main); transform: rotate(90deg); }
.btn-send { background: var(--clr); color: var(--txt); margin-right: 4px; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.btn-send:hover { filter: brightness(0.9); transform: scale(1.05); }
.btn-send:active { transform: scale(0.95); }
.btn-send:disabled { background: #e4e4e7; color: #a1a1aa; cursor: not-allowed; transform: none; box-shadow: none; }

#prevArea { padding: 0 12px; display: none; margin-bottom: 8px; margin-top: 8px; }
#prevArea.show { display: flex; flex-wrap: wrap; gap: 8px; }
.prev-wrap { position: relative; animation: springUp 0.3s ease forwards; }
.prev-wrap img { width: 64px; height: 64px; object-fit: cover; border-radius: 12px; border: 1px solid var(--border); box-shadow: 0 2px 8px rgba(0,0,0,0.05); }
.prev-rm { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; background: #fff; border: 1px solid var(--border); border-radius: 50%; font-size: 10px; color: #ef4444; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.2s; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.prev-rm:hover { background: #fee2e2; transform: scale(1.1); border-color: #fca5a5; }

.modal-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.4); display: flex; align-items: center; justify-content: center; z-index: 50; opacity: 0; pointer-events: none; transition: opacity 0.3s; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal-content { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 20px; width: 90%; max-width: 340px; padding: 24px; box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25); transform: scale(0.95) translateY(10px); transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.modal-overlay.show .modal-content { transform: scale(1) translateY(0); }
.modal-title { font-weight: 700; font-size: 1.1rem; margin-bottom: 8px; color: var(--text-main); display: flex; align-items: center; gap: 8px; letter-spacing: -0.01em; }
.modal-body { font-size: 0.95rem; color: var(--text-muted); margin-bottom: 24px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal-btn { padding: 10px 18px; border-radius: 12px; font-size: 0.9rem; font-weight: 600; cursor: pointer; border: none; transition: all 0.2s; }
.modal-btn-cancel { background: #f4f4f5; color: var(--text-main); }
.modal-btn-cancel:hover { background: #e4e4e7; }
.modal-btn-confirm { background: #ef4444; color: #fff; box-shadow: 0 4px 12px rgba(239,68,68,0.2); }
.modal-btn-confirm:hover { background: #dc2626; transform: translateY(-1px); }

.toast { position: absolute; top: 20px; left: 50%; transform: translateX(-50%) translateY(-20px); background: #18181b; color: #fff; padding: 12px 20px; border-radius: 30px; font-size: 0.9rem; font-weight: 500; box-shadow: 0 10px 25px rgba(0,0,0,0.2); opacity: 0; pointer-events: none; transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1); z-index: 100; display: flex; align-items: center; gap: 10px; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast i { color: #10b981; font-size: 1rem; }

@media (max-width: 640px) { .app { border-radius: 0; } .header { padding: 1rem 1.25rem; } .chat { padding: 1.25rem; } .footer { padding: 0.75rem 1rem 1rem 1rem; } }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #a1a1aa; }