/* Modernized and dark mode ready */
:root {
    /* Light theme */
    --bg: #f8fafc;
    --container-bg: #ffffff;
    --text: #1e293b;
    --text-secondary: #64748b;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --border: #e2e8f0;
    --bubble-user: #3b82f6;
    --bubble-assistant: #f1f5f9;
    --bubble-user-text: #ffffff;
    --bubble-assistant-text: #1e293b;
    --input-bg: #ffffff;
    --input-border: #cbd5e1;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --code-bg: #f1f5f9;
    --header-bg: #ffffff;
    --nav-bg: #ffffff;
    --footer-bg: #f8fafc;
}

body {
    background: var(--bg);
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    margin: 0;
    color: var(--text);
    transition: background-color 0.3s, color 0.3s;
}
.container {
    max-width: 700px;
    margin: 40px auto;
    background: var(--container-bg);
    border-radius: 18px;
    box-shadow: var(--shadow);
    padding: 0 0 32px 0;
    transition: background 0.3s;
}
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: var(--container-bg);
    border-radius: 18px 18px 0 0;
    overflow: hidden;
}
.tab {
    flex: 1;
    text-align: center;
    padding: 18px 0;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--bg);
    border: none;
    outline: none;
    transition: color 0.2s, background 0.2s;
    font-size: 1.08rem;
    letter-spacing: 0.01em;
}
.tab.active {
    color: var(--primary);
    background: var(--container-bg);
    border-bottom: 2.5px solid var(--primary);
    font-weight: 600;
}
.tab-content {
    display: none;
    padding: 32px 32px 0 32px;
    animation: fadeIn 0.3s;
}
.tab-content.active {
    display: block;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px);}
    to { opacity: 1; transform: none;}
}
/* Chat */
.chat-window {
    height: 340px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bubble-assistant);
    padding: 18px;
    margin-bottom: 18px;
    box-shadow: 0 1px 8px #0001;
    transition: background 0.3s;
}
.msg {
    margin-bottom: 16px;
    display: flex;
}
.msg.user {
    justify-content: flex-end;
}
.msg .bubble {
    max-width: 70%;
    padding: 14px 20px;
    border-radius: 18px;
    font-size: 1.04rem;
    line-height: 1.6;
    box-shadow: 0 1px 4px #0001;
    transition: background 0.3s, color 0.3s;
}
.msg.user .bubble {
    background: var(--bubble-user);
    color: var(--bubble-user-text);
    border-bottom-right-radius: 6px;
    border: 1.5px solid #2563eb;
}
.msg.assistant .bubble {
    background: #e9ecf3; /* Daha belirgin açık gri arka plan */
    color: #1a1a1a;      /* Daha koyu yazı rengi */
    border-bottom-left-radius: 6px;
    border: 1.5px solid #d1d5db; /* Hafif kenarlık ile ayrım */
}
body.dark-mode .msg.assistant .bubble {
    background: #23262f;
    color: #f1f3f6;
    border: 1.5px solid #353945;
}
.chat-input-row {
    display: flex;
    gap: 10px;
}
.chat-input {
    flex: 1;
    padding: 13px;
    border-radius: 9px;
    border: 1.5px solid var(--input-border);
    font-size: 1.05rem;
    background: var(--input-bg);
    color: var(--text);
    transition: background 0.3s, color 0.3s, border 0.3s;
}
.send-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 9px;
    padding: 0 26px;
    font-size: 1.05rem;
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 500;
    box-shadow: 0 1px 4px #0001;
}
.send-btn:hover:enabled {
    background: var(--primary-hover);
}
.send-btn:disabled {
    background: #b3d1f7;
    cursor: not-allowed;
}
/* Görsel üretim */
.img-form-row {
    display: flex;
    gap: 14px;
    margin-bottom: 18px;
}
.img-form-row input, .img-form-row select {
    flex: 1;
    padding: 11px;
    border-radius: 9px;
    border: 1.5px solid var(--input-border);
    font-size: 1.05rem;
    background: var(--input-bg);
    color: var(--text);
    transition: background 0.3s, color 0.3s, border 0.3s;
}
.img-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 9px;
    padding: 11px 26px;
    font-size: 1.05rem;
    cursor: pointer;
    transition: background 0.2s;
    font-weight: 500;
    box-shadow: 0 1px 4px #0001;
}
.img-btn:hover:enabled {
    background: var(--primary-hover);
}
.img-btn:disabled {
    background: #b3d1f7;
    cursor: not-allowed;
}
.img-result {
    margin-top: 20px;
    text-align: center;
}
.img-result img {
    max-width: 100%;
    border-radius: 14px;
    box-shadow: var(--shadow-img);
    margin-top: 8px;
}
/* API Kullanım */
.api-section {
    font-size: 1.03rem;
    color: var(--text);
}
.api-section code {
    background: var(--code-bg);
    padding: 2px 7px;
    border-radius: 7px;
    font-size: 0.97em;
}
.api-section pre {
    background: var(--code-bg);
    padding: 14px;
    border-radius: 9px;
    overflow-x: auto;
    font-size: 0.98em;
    margin-bottom: 18px;
}
@media (max-width: 600px) {
    .container { max-width: 100%; margin: 0; border-radius: 0; }
    .tab-content { padding: 18px 8px 0 8px; }
    .chat-window { height: 220px; }
}

/* --- DARK MODE --- */
body.dark-mode {
    --bg: #0f172a;
    --container-bg: #1e293b;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --border: #334155;
    --bubble-user: #3b82f6;
    --bubble-assistant: #1e293b;
    --bubble-user-text: #ffffff;
    --bubble-assistant-text: #f1f5f9;
    --input-bg: #0f172a;
    --input-border: #334155;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
    --code-bg: #0f172a;
    --header-bg: #1e293b;
    --nav-bg: #1e293b;
    --footer-bg: #0f172a;
}

/* Dark mode toggle button position adjustment */
.dark-mode-toggle,
#dark-toggle {
    position: absolute;
    top: 18px;
    right: 32px;
    z-index: 10;
    background: var(--container-bg);
    border: 1.5px solid var(--primary);
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px #0002;
    transition: background 0.3s, border 0.3s;
}
#dark-toggle:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary-hover);
}
#dark-toggle-icon {
    font-size: 1.5rem;
    transition: color 0.3s;
}
/* Tema ekranı için üstte bir bar ekleyelim */
.theme-bar {
    width: 100%;
    height: 48px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-hover) 100%);
    border-radius: 18px 18px 0 0;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    position: relative;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body.dark-mode {
    --bg: #0f172a;
    --container-bg: #1e293b;
    --text: #f1f5f9;
    --text-secondary: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --border: #334155;
    --bubble-user: #3b82f6;
    --bubble-assistant: #1e293b;
    --bubble-user-text: #ffffff;
    --bubble-assistant-text: #f1f5f9;
    --input-bg: #0f172a;
    --input-border: #334155;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
    --code-bg: #0f172a;
    --header-bg: #1e293b;
    --nav-bg: #1e293b;
    --footer-bg: #0f172a;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.app-header {
    background: var(--header-bg);
    border-bottom: 1px solid var(--border);
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
}

.logo i {
    font-size: 1.5rem;
}

/* Navigation */
.app-nav {
    background: var(--nav-bg);
    border-bottom: 1px solid var(--border);
    padding: 0.5rem;
    display: flex;
    gap: 0.5rem;
    position: sticky;
    top: 4rem;
    z-index: 90;
}

.nav-item {
    padding: 0.75rem 1.25rem;
    border: none;
    background: none;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--bubble-assistant);
    color: var(--text);
}

.nav-item.active {
    background: var(--primary);
    color: white;
}

/* Main Content */
.app-main {
    flex: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    width: 100%;
}

.content-area {
    background: var(--container-bg);
    border-radius: 1rem;
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* Chat */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 12rem);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.msg {
    display: flex;
    gap: 0.5rem;
    max-width: 85%;
}

.msg.user {
    margin-left: auto;
}

.msg .bubble {
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    font-size: 1rem;
    line-height: 1.5;
    box-shadow: var(--shadow);
}

.msg.user .bubble {
    background: var(--bubble-user);
    color: var(--bubble-user-text);
    border-bottom-right-radius: 0.25rem;
}

.msg.assistant .bubble {
    background: var(--bubble-assistant);
    color: var(--bubble-assistant-text);
    border-bottom-left-radius: 0.25rem;
}

.chat-input-form {
    padding: 1rem;
    border-top: 1px solid var(--border);
    background: var(--container-bg);
}

.input-wrapper {
    display: flex;
    gap: 0.5rem;
}

#chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    background: var(--input-bg);
    color: var(--text);
    font-size: 1rem;
    resize: none;
    min-height: 2.5rem;
    max-height: 150px;
    transition: all 0.2s;
}

#chat-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.send-button {
    padding: 0.75rem 1.25rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-button:hover:not(:disabled) {
    background: var(--primary-hover);
}

.send-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Image Generator */
.image-generator {
    padding: 1.5rem;
}

.image-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-weight: 500;
    color: var(--text-secondary);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

#img-prompt {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    background: var(--input-bg);
    color: var(--text);
    font-size: 1rem;
    resize: vertical;
    min-height: 100px;
}

.form-row input {
    padding: 0.75rem 1rem;
    border: 1px solid var(--input-border);
    border-radius: 0.5rem;
    background: var(--input-bg);
    color: var(--text);
    font-size: 1rem;
}

.generate-button {
    padding: 1rem 1.5rem;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.generate-button:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.generate-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.image-result {
    margin-top: 1.5rem;
    text-align: center;
}

.image-result img {
    max-width: 100%;
    border-radius: 0.5rem;
    box-shadow: var(--shadow-lg);
}

/* API Documentation */
.api-documentation {
    padding: 1.5rem;
}

.api-documentation h2 {
    margin-bottom: 1.5rem;
    color: var(--text);
}

.api-section {
    margin-bottom: 2rem;
}

.api-section h3 {
    margin-bottom: 1rem;
    color: var(--text);
}

.endpoint {
    background: var(--code-bg);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.endpoint h4 {
    margin-bottom: 0.5rem;
    color: var(--text);
}

.endpoint pre {
    background: var(--container-bg);
    padding: 1rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    font-size: 0.9rem;
}

.endpoint code {
    font-family: 'Consolas', 'Monaco', monospace;
}

.code-examples {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
}

.code-block {
    background: var(--code-bg);
    border-radius: 0.5rem;
    padding: 1rem;
}

.code-block h4 {
    margin-bottom: 0.5rem;
    color: var(--text);
}

/* Footer */
.app-footer {
    background: var(--footer-bg);
    border-top: 1px solid var(--border);
    padding: 1.5rem;
    margin-top: auto;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
}

.footer-links a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--primary);
}

/* Dark Mode Toggle */
#dark-toggle {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

#dark-toggle:hover {
    background: var(--bubble-assistant);
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-main {
        padding: 0.5rem;
    }

    .content-area {
        border-radius: 0.5rem;
    }

    .chat-container {
        height: calc(100vh - 10rem);
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .footer-links {
        flex-direction: column;
        gap: 0.75rem;
    }
}

/* Loading States */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--primary);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
    margin-left: 0.5rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error States */
.error {
    color: #ef4444;
    background: #fee2e2;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin: 0.5rem 0;
}

/* Success States */
.success {
    color: #22c55e;
    background: #dcfce7;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin: 0.5rem 0;
}
