* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 800px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

.user-info {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
}

#userDisplay {
    background: rgba(255, 255, 255, 0.2);
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9em;
}

main {
    padding: 30px;
}

.chat-container {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
}

.chat-messages {
    min-height: 400px;
    max-height: 500px;
    overflow-y: auto;
    margin-bottom: 20px;
    padding: 10px;
}

.message {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5em;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background: #667eea;
}

.ai-message .message-avatar {
    background: #764ba2;
}

.message-content {
    flex: 1;
    background: white;
    padding: 15px;
    border-radius: 15px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.message-content p {
    line-height: 1.6;
    color: #333;
}

.loading .message-content {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.input-container {
    display: flex;
    gap: 10px;
}

#questionInput {
    flex: 1;
    padding: 15px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    font-size: 1em;
    outline: none;
    transition: border-color 0.3s;
}

#questionInput:focus {
    border-color: #667eea;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 1em;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 8px 20px;
    border-radius: 20px;
    font-size: 0.9em;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: background 0.3s;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.3);
}

.info-box {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    padding: 15px;
    border-radius: 5px;
    margin-top: 20px;
}

.info-box p {
    color: #1976d2;
    margin: 0;
}

.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 15px;
    border-radius: 10px;
    margin: 10px 0;
    animation: slideIn 0.3s ease;
}

footer {
    background: #f8f9fa;
    padding: 20px;
    text-align: center;
    color: #666;
    font-size: 0.9em;
}

footer a {
    color: #667eea;
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #667eea;
    border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #764ba2;
}

/* Responsive */
@media (max-width: 768px) {
    header h1 {
        font-size: 2em;
    }

    .chat-messages {
        min-height: 300px;
        max-height: 400px;
    }

    .input-container {
        flex-direction: column;
    }

    .btn-primary {
        width: 100%;
    }
}


/* ============================================
   MARKDOWN STYLING - AI Mesajları için
   ============================================ */

.message-content h1,
.message-content h2,
.message-content h3 {
    margin: 16px 0 8px 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-content h1 {
    font-size: 1.8em;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 8px;
}

.message-content h2 {
    font-size: 1.5em;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 6px;
}

.message-content h3 {
    font-size: 1.3em;
}

/* Kod blokları */
.message-content pre {
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    border-left: 4px solid #667eea;
}

.message-content code {
    background: #f4f4f4;
    color: #e83e8c;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.message-content pre code {
    background: transparent;
    color: #d4d4d4;
    padding: 0;
    font-size: 0.95em;
}

/* Bold ve Italic */
.message-content strong {
    font-weight: 700;
    color: #2c3e50;
}

.message-content em {
    font-style: italic;
    color: #555;
}

.message-content strong em,
.message-content em strong {
    font-weight: 700;
    font-style: italic;
    color: #2c3e50;
}

/* Strikethrough */
.message-content del {
    text-decoration: line-through;
    opacity: 0.7;
}

/* Blockquote */
.message-content blockquote {
    border-left: 4px solid #667eea;
    padding: 12px 16px;
    margin: 12px 0;
    background: #f8f9fa;
    border-radius: 4px;
    font-style: italic;
    color: #555;
}

/* Links */
.message-content a {
    color: #667eea;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s;
}

.message-content a:hover {
    border-bottom-color: #667eea;
    color: #764ba2;
}

/* Lists */
.message-content ul,
.message-content ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-content li {
    margin: 6px 0;
    line-height: 1.6;
}

.message-content ul li {
    list-style-type: disc;
}

.message-content ol li {
    list-style-type: decimal;
}

/* Horizontal Rule */
.message-content hr {
    border: none;
    border-top: 2px solid #e0e0e0;
    margin: 20px 0;
}

/* Images */
.message-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 12px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Paragraphs */
.message-content p {
    margin: 8px 0;
    line-height: 1.7;
}

/* Tables */
.message-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    background: white;
    border-radius: 8px;
    overflow: hidden;
}

.message-content table th,
.message-content table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.message-content table th {
    background: #667eea;
    color: white;
    font-weight: 600;
}

.message-content table tr:hover {
    background: #f8f9fa;
}

/* Scrollbar styling for code blocks */
.message-content pre::-webkit-scrollbar {
    height: 8px;
}

.message-content pre::-webkit-scrollbar-track {
    background: #2d2d2d;
}

.message-content pre::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

.message-content pre::-webkit-scrollbar-thumb:hover {
    background: #777;
}


/* ============================================
   CHAT MENU - Üç Nokta Menüsü
   ============================================ */

.chat-history-item {
    position: relative;
    z-index: 1;
}

.chat-history-item.menu-open {
    z-index: 1001;
}

.chat-menu-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1em;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    opacity: 0;
    transition: all 0.2s;
    line-height: 1;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    pointer-events: auto;
}

.chat-history-item:hover .chat-menu-btn {
    opacity: 1;
}

.chat-menu-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Menu Overlay - Arka plan karartma (sidebar dışını kaplar) */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 260px; /* Sidebar genişliği kadar sağdan başla */
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 99;
    animation: fadeIn 0.2s ease;
    pointer-events: auto;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.chat-menu {
    position: absolute;
    top: 100%;
    right: 8px;
    margin-top: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 6px;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    display: none;
    animation: slideDown 0.2s ease;
    pointer-events: auto;
}

.chat-menu.show {
    display: block;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-menu button {
    width: 100%;
    padding: 8px 10px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.85em;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    white-space: nowrap;
    pointer-events: auto;
    z-index: 1001;
    position: relative;
}

.chat-menu button:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    transform: translateX(2px);
}

.chat-menu .delete-menu-btn {
    color: #ff6b6b;
    border-top: 1px solid var(--border-primary);
    margin-top: 4px;
    padding-top: 10px;
}

.chat-menu .delete-menu-btn:hover {
    background: rgba(255, 107, 107, 0.15);
}

.menu-icon {
    font-size: 0.85em;
    flex-shrink: 0;
    width: 14px;
    text-align: center;
    line-height: 1;
}

/* ============================================
   DELETE MODAL - Silme Onay Modalı
   ============================================ */

.delete-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.delete-modal.show {
    opacity: 1;
}

.delete-modal-content {
    background: #1a1a1a;
    border: 1px solid #3d3d3d;
    border-radius: 16px;
    padding: 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    animation: modalSlideUp 0.3s ease;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.delete-modal-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.delete-modal-content h2 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #fff;
}

.delete-modal-subtitle {
    font-size: 16px;
    color: #0070f3;
    margin-bottom: 12px;
}

.delete-modal-warning {
    font-size: 14px;
    color: #aaa;
    margin-bottom: 24px;
    line-height: 1.5;
}

.delete-modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.cancel-btn {
    background: #2a2a2e;
    color: #e0e0e0;
    border: 1px solid #3d3d3d;
}

.cancel-btn:hover {
    background: #3a3a3e;
}

.delete-btn-confirm {
    background: #ff6b6b;
    color: white;
}

.delete-btn-confirm:hover {
    background: #ff5252;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
}
