/* === DEĞİŞKENLER VE TEMEL AYARLAR === */
:root {
    --primary-green: #00FF1E;
    --dark-gray: #262626;
    --light-gray: #3a3a3a;
    --white: #FFFFFF;
    --main-bg: #16161B;
    --border-color: #444;
    --text-gray: rgba(255, 255, 255, 0.7);
    --font-sans: 'Inter', sans-serif;
    --border-radius: 12px;
    --sidebar-width: 280px;
    --sidebar-collapsed-width: 80px;
    --mobile-sidebar-width: 280px; 
}

/* === AÇIK MOD DEĞİŞKENLERİ === */
body.light-mode {
    --main-bg: #F3F4F6;
    --dark-gray: #FFFFFF;
    --light-gray: #E5E7EB;
    --white: #111827;
    --border-color: #E5E7EB;
    --text-gray: #6B7280;
}

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

html, body {
    height: 100%;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

body {
    font-family: var(--font-sans);
    background-color: var(--main-bg);
    color: var(--white);
    line-height: 1.6;
}

body.sidebar-mobile-open {
    position: fixed;
    width: 100%;
    top: calc(var(--scroll-top, 0) * -1px);
}

a { color: inherit; text-decoration: none; }
[data-lucide] { width: 1em; height: 1em; color: currentColor; }

.mobile-sidebar-toggle-btn {
    display: none; 
}

/* === ANA ARAYÜZ STİLLERİ === */
.chat-app-body {
    overflow: hidden;
    position: relative;
    width: 100vw;
    height: 100%;
}

.app-layout {
    display: flex;
    height: 100%;
    width: 100%;
    transition: transform 0.3s ease; 
}

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.sidebar-mobile-open .sidebar-overlay { 
    opacity: 1;
    visibility: visible;
}

/* --- SOL SIDEBAR --- */
.app-sidebar {
    width: var(--sidebar-width);
    background-color: var(--main-bg);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 1rem;
    flex-shrink: 0;
    transition: width 0.3s ease, padding 0.3s ease, transform 0.3s ease, background-color 0.3s ease;
    border-right: 1px solid var(--border-color);
    z-index: 2000; 
}
.sidebar-top {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}
.sidebar-header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 0.5rem 0;
}
.sidebar-header .sidebar-logo-link {
    grid-column: 2 / 3;
}
.sidebar-header .sidebar-toggle-btn {
    grid-column: 3 / 4;
    justify-self: end;
}
.sidebar-logo-link {
    display: flex;
    align-items: center;
}
.sidebar-logo {
    height: 30px;
    transition: height 0.3s ease;
}
.collapsed-logo {
    display: none;
}
.app-sidebar.collapsed .full-logo {
    display: none;
}
.app-sidebar.collapsed .collapsed-logo {
    display: block;
}
.sidebar-toggle-btn {
    background: none;
    border: none;
    color: var(--white);
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sidebar-toggle-btn svg {
    width: 22px;
    height: 22px;
}
.sidebar-toggle-btn:hover {
    background-color: var(--dark-gray);
}
.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background-color: var(--dark-gray);
    color: var(--white);
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 2rem;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background-color 0.2s;
    white-space: nowrap;
}
.new-chat-btn:hover {
    background-color: var(--light-gray);
}
.new-chat-btn i {
    width: 20px;
    height: 20px;
}
.recent-chats .recent-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-gray);
    padding: 0 0.5rem;
    margin-bottom: 0.5rem;
    white-space: nowrap;
}
.recent-chats ul {
    list-style: none;
}
.recent-chats li {
    position: relative;
    display: flex;
    align-items: center;
    border-radius: var(--border-radius);
}
.recent-chats li:hover {
    background-color: var(--dark-gray);
}
.recent-chats li .chat-link {
    display: block;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-grow: 1;
    padding-right: 2.5rem;
    position: relative;
    z-index: 1;
}
.recent-chats li .chat-options-btn {
    display: none; /* Bu kural sadece menüyü açan ana butonu gizler */
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-gray);
    padding: 0.25rem;
    border-radius: 50%;
    cursor: pointer;
    z-index: 2;
}
.recent-chats li:hover .chat-options-btn {
    display: block;
}
.chat-options-btn:hover {
    background-color: var(--light-gray);
    color: var(--white);
}
.chat-options-menu {
    position: absolute;
    right: 0;
    top: 2.5rem; /* Butonun biraz altına konumlandır */
    background-color: #3a3a3a;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    z-index: 10;
    width: 150px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    list-style: none;
}
body.light-mode .chat-options-menu {
    background-color: #FFFFFF;
}

.chat-options-menu.menu-opens-up {
    top: auto; /* 'top' değerini sıfırla */
    bottom: 2.5rem; /* Butonun biraz üstüne konumlandır */
}

.chat-options-menu button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    background: none;
    border: none;
    color: var(--white);
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    text-align: left;
}
body.light-mode .chat-options-menu button {
    color: #111827;
}
.chat-options-menu button:hover {
    background-color: var(--light-gray);
}
body.light-mode .chat-options-menu button:hover {
    background-color: var(--light-gray);
}
.chat-options-menu button [data-lucide] {
    width: 16px;
    height: 16px;
}
.chat-options-menu .delete-option {
    color: #e53e3e;
}

.pin-icon {
    width: 16px;
    height: 16px;
    margin-left: 0.75rem;
    color: var(--text-gray);
    flex-shrink: 0;
}
.app-sidebar.collapsed .pin-icon {
    display: none;
}
.sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}
.sidebar-bottom a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    white-space: nowrap;
}
.sidebar-bottom a:hover {
    background-color: var(--dark-gray);
}
.sidebar-bottom i {
    width: 20px;
    height: 20px;
    opacity: 0.8;
}
.app-sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    padding: 1rem 0.5rem;
}
.app-sidebar.collapsed .sidebar-logo-link {
    display: block;
    text-align: center;
    width: 100%;
}
.app-sidebar.collapsed .sidebar-logo {
    height: 28px; /* Küçültülmüş logo için boyut ayarı */
}
.app-sidebar.collapsed .sidebar-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}
.app-sidebar.collapsed .new-chat-btn span,
.app-sidebar.collapsed .sidebar-top .recent-title,
.app-sidebar.collapsed .sidebar-bottom a span,
.app-sidebar.collapsed #user-display-name,
.app-sidebar.collapsed .chat-options-btn { 
    display: none;
}
.app-sidebar.collapsed .new-chat-btn,
.app-sidebar.collapsed .sidebar-bottom a {
    justify-content: center;
}
.app-sidebar.collapsed .recent-chats ul {
    padding: 0 0.25rem;
}
.app-sidebar.collapsed .recent-chats li .chat-link {
    text-align: center;
    padding: 0.75rem 0.5rem;
}
.login-prompt span{ font-weight: 500; }

/* --- ANA İÇERİK --- */
.app-main-content { 
    flex-grow: 1; 
    display: flex; 
    flex-direction: column; 
    height: 100%;
    position: relative; 
    transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
    background-color: var(--main-bg);
    overflow: hidden; 
}

/* --- MOBİL ÜST BAR --- */
.mobile-main-header {
    display: none; 
    align-items: center;
    padding: 0.5rem 0.75rem;
    height: 60px;
    flex-shrink: 0; 
    border-bottom: 1px solid var(--border-color);
}
.mobile-main-header .mobile-sidebar-toggle-btn {
    display: flex;
    background: none;
    border: none;
    color: var(--white);
    padding: 0.5rem;
    cursor: pointer;
    border-radius: 50%;
}
.mobile-main-header .mobile-sidebar-toggle-btn:hover {
    background-color: var(--dark-gray);
}
.mobile-main-header .mobile-sidebar-toggle-btn svg {
    width: 24px;
    height: 24px;
}
.mobile-main-header .mobile-chat-title {
    font-weight: 500;
    margin-left: 1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- SOHBET EKRANI --- */
.chat-container {
    flex-grow: 1;
    overflow-y: auto;
    position: relative;
}

#chat-start-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 3rem;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem 1rem;
    height: 100%;
}

.start-title {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 600;
    line-height: 1.2;
}

.gradient-text { display: block; background: linear-gradient(135deg, #FFFFFF 40%, #999999 100%); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; text-fill-color: transparent; }

.suggestion-cards { 
    display: grid; 
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem; 
}

.suggestion-card {
    background-color: var(--dark-gray);
    padding: 1rem 1rem 3.5rem 1rem;
    border-radius: var(--border-radius);
    position: relative;
    cursor: pointer;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: background-color 0.2s;
}

.suggestion-card:hover { background-color: var(--light-gray); }
.suggestion-card h4 { font-size: 1rem; font-weight: 500; }
.suggestion-card p { font-size: 0.85rem; color: var(--text-gray); display: none; }
.suggestion-card svg { position: absolute; bottom: 1rem; right: 1rem; width: 28px; height: 28px; background-color: var(--primary-green); color: black; padding: 5px; border-radius: 50%; box-sizing: border-box;  }

#chat-conversation-area {
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
    padding: 1rem;
}

.message-wrapper { margin-bottom: 2rem; display: flex; flex-direction: column; }
.message-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.75rem; }
.message-header img { width: 30px; height: 30px; border-radius: 50%; }
.message-header span { font-weight: 600; }
.message-content { padding-left: calc(30px + 0.75rem); line-height: 1.7; }
.message-content p { margin-bottom: 1rem; }
.message-content code { background-color: var(--dark-gray); padding: 0.1rem 0.3rem; border-radius: 4px; font-family: monospace; }
.message-content pre { background-color: #0d1117; padding: 1rem; border-radius: var(--border-radius); overflow-x: auto; }
.message-content pre code { background: none; padding: 0; }

/* --- CHAT GİRİŞ ALANI --- */
.chat-input-container { padding: 1rem; width: 100%; max-width: 900px; margin: 0 auto; flex-shrink: 0; }
.chat-input-wrapper { background-color: var(--dark-gray); border-radius: 1.5rem; padding: 0.5rem 0.5rem 0.5rem 1.5rem; display: flex; align-items: center;  gap: 0.5rem; }
#chat-input { flex-grow: 1; background: none; border: none; color: var(--white); font-size: 1rem; resize: none; line-height: 1.5; max-height: 200px; overflow-y: auto; transition: height 0.2s ease; }
#chat-input:focus { outline: none; }
#chat-input:disabled { cursor: not-allowed; }
#send-btn { width: 44px; height: 44px; border-radius: 50%; border: none; background-color: var(--primary-green); color: #000; cursor: pointer; display: flex; justify-content: center; align-items: center; flex-shrink: 0; transition: transform 0.2s, background-color 0.2s, opacity 0.2s; }
#send-btn:hover { transform: scale(1.05); }
#send-btn:disabled { background-color: var(--light-gray); cursor: not-allowed; transform: none; opacity: 0.5; }
#send-btn i { width: 22px; height: 22px; }
.input-footer { font-size: 0.75rem; color: var(--text-gray); text-align: center; padding: 0.75rem 0; }
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.7); display: flex; justify-content: center; align-items: center; z-index: 3000; opacity: 1; transition: opacity 0.3s ease; }
.modal-overlay.hidden { opacity: 0; pointer-events: none; }
.brand-footer {
    /* Yeni Konumlandırma */
    margin-top: -70px;
    padding: 0 1rem 1rem 1rem;
    display: flex;
    justify-content: center;
    width: 100%;
    transition: opacity 0.3s ease;
}
.brand-footer.hidden {
    opacity: 0;
    pointer-events: none;
}
.brand-footer a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--text-gray);
    opacity: 0.5;
    transition: opacity 0.2s;
}
.brand-footer a:hover {
    opacity: 1;
}
.brand-footer span {
    font-size: 1rem;
}
.brand-footer-logo {
    width: 30px;
    height: 30px;
}
.modal-content { background-color: var(--dark-gray); padding: 2rem; border-radius: var(--border-radius); width: 90%; max-width: 500px; position: relative; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.modal-close-btn { position: absolute; top: 1rem; right: 1rem; background: none; border: none; color: var(--text-gray); cursor: pointer; }
.modal-close-btn:hover { color: var(--white); }
.modal-content h2 { margin-bottom: 1.5rem; }
.setting-item, .faq-item { margin-bottom: 1.5rem; }
.setting-item label, .faq-item h5 { display: block; font-weight: 600; margin-bottom: 0.5rem; }
.setting-item p, .faq-item p { font-size: 0.9rem; color: var(--text-gray); }
.setting-item select { width: 100%; padding: 0.5rem; background-color: var(--light-gray); border: 1px solid var(--border-color); color: var(--white); border-radius: 8px; }
.btn-danger { background-color: #e53e3e; color: white; padding: 0.75rem 1rem; border: none; border-radius: 8px; cursor: pointer; font-weight: 500; margin-top: 0.5rem; }
.btn-danger:hover { background-color: #c53030; }
.btn-danger:disabled { background-color: var(--light-gray); cursor: not-allowed; }
.hidden { display: none !important; }

/* YENİ EKLENDİ: Rename Modal için özel stiller */
#rename-modal .input-group {
    position: relative;
    margin: 1.5rem 0;
}
#rename-modal input {
    width: 100%;
    padding: 0.8rem 1rem;
    background-color: var(--main-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--white);
    font-size: 1rem;
}
#rename-modal input:focus {
    outline: none;
    border-color: var(--primary-green);
}
#rename-modal .auth-btn {
    width: 100%;
    padding: 0.85rem;
    background-color: var(--primary-green);
    color: #000;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
    margin-top: 0;
}
#rename-modal .auth-btn:hover {
    transform: scale(1.02);
}

/* === AÇIK MOD İÇİN ÖZEL STİLLER === */
body.light-mode .suggestion-card:hover { 
    background-color: #F3F4F6;
}
body.light-mode .sidebar-toggle-btn:hover,
body.light-mode .new-chat-btn:hover,
body.light-mode .recent-chats li:hover,
body.light-mode .sidebar-bottom a:hover,
body.light-mode #user-profile-area:hover,
body.light-mode .mobile-main-header .mobile-sidebar-toggle-btn:hover {
    background-color: var(--light-gray);
}
body.light-mode .gradient-text {
    background: linear-gradient(135deg, #222222 40%, #777777 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-fill-color: transparent;
}
body.light-mode #send-btn:disabled {
    background-color: var(--light-gray);
    opacity: 0.7;
    color: var(--text-gray);
}
body.light-mode .message-content pre {
    background-color: #f3f4f6;
    border: 1px solid var(--border-color);
}
body.light-mode .message-content code {
    background-color: var(--light-gray);
}
body.light-mode .modal-content {
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
body.light-mode .btn-danger {
    color: white;
}
body.light-mode .setting-item select {
    background-color: #F9FAFB;
}
body.light-mode .chat-input-wrapper {
    border: 1px solid var(--border-color);
}
body.light-mode #chat-input {
    color: #111827;
}

/* === MOBİL UYUMLULUK === */
@media (max-width: 768px) {
    html {
        font-size: 15px;
    }
    .app-sidebar {
        position: fixed;
        height: 100%;
        box-shadow: 5px 0 15px rgba(0,0,0,0.2);
        transform: translateX(-100%);
        width: var(--mobile-sidebar-width);
    }
    .app-sidebar.mobile-open {
        transform: translateX(0);
    }
    .sidebar-toggle-btn {
        display: none; 
    }
    .sidebar-mobile-open .app-main-content {
        transform: translateX(var(--mobile-sidebar-width));
        box-shadow: -10px 0 25px rgba(0,0,0,0.3);
        border-top-left-radius: 16px;
        border-bottom-left-radius: 16px;
        overflow: hidden; 
        pointer-events: none; 
    }
    .app-main-content {
        padding: 0; 
        border-radius: 0; 
    }
    .mobile-main-header {
        display: flex;
    }
    .chat-input-container {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background-color: var(--main-bg);
        border-top: 1px solid var(--border-color);
        padding: 0.75rem 1rem; 
        transition: background-color 0.3s ease;
    }
    .chat-container {
        padding-bottom: 100px;
    }
    .start-title {
        font-size: clamp(1.5rem, 5vw, 1.8rem);
        padding: 1rem;
    }
    .message-wrapper {
        margin-bottom: 1.5rem;
    }
    .message-header img {
        width: 28px;
        height: 28px;
    }
    .message-content {
        font-size: 0.95rem;
        padding-left: calc(28px + 0.75rem);
        overflow-wrap: break-word;
        word-break: break-word; 
    }
    .suggestion-card h4 {
        font-size: 0.9rem;
    }
    .suggestion-card p {
        display: none;
    }
    .chat-input-wrapper {
        padding: 0.5rem;
    }
    #chat-input {
        font-size: 16px;
        padding-left: 1rem;
    }
    .input-footer {
        font-size: 0.7rem;
        padding: 0.5rem;
    }
}

@media (min-width: 769px) {
    .suggestion-card p {
        display: block;
    }
    .app-sidebar.collapsed {
        transform: translateX(0) !important;
    }
}

/* KULLANICI PROFİL ALANI */
#user-profile-area { display: flex; align-items: center; justify-content: space-between; padding: 0.5rem; border-radius: var(--border-radius); transition: background-color 0.2s; }
#user-profile-area:hover { background-color: var(--dark-gray); }
.user-profile-link { display: flex; align-items: center; gap: 0.75rem; flex-grow: 1; padding: 0.25rem 0.5rem; min-width: 0; }
#user-photo { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
#user-display-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-icon-btn { background: none; border: none; color: var(--text-gray); cursor: pointer; padding: 0.5rem; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.sidebar-icon-btn:hover { background-color: var(--light-gray); color: var(--white); }