/* ==========================================================================
   AHD Sohbet (chat_ahdcode) - Modern Glassmorphism & Responsive Stylesheet
   ========================================================================== */

:root {
    --primary: #27548a;
    --primary-light: #3b6ea8;
    --primary-dark: #1a3c63;
    --primary-glow: rgba(39, 84, 138, 0.25);
    --accent: #d98b30;
    --accent-glow: rgba(217, 139, 48, 0.25);
    --ink: #0f172a;
    --ink-light: #334155;
    --muted: #64748b;
    --line: #e2e8f0;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --surface-hover: #f1f5f9;
    --ai-theme: #6366f1;
    --ai-theme-glow: rgba(99, 102, 241, 0.18);
    --success: #10b981;
    --danger: #ef4444;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 12px 28px -4px rgba(15, 23, 42, 0.12);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ink);
    background: #eef3f7;
    height: 100vh;
    overflow: hidden;
    line-height: 1.5;
}

/* --------------------------------------------------------------------------
   Auth Ekranı
   -------------------------------------------------------------------------- */
.auth-body {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    overflow: auto;
    padding: 24px;
}

.auth-container {
    display: flex;
    max-width: 960px;
    width: 100%;
    min-height: 560px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    overflow: hidden;
}

.auth-side {
    padding: 44px;
}

.brand-side {
    flex: 1.1;
    background: linear-gradient(160deg, var(--primary) 0%, #132438 100%);
    color: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.brand-badge {
    display: flex;
    align-items: center;
    gap: 14px;
}

.auth-logo {
    width: 44px;
    height: 44px;
    background: #ffffff;
    border-radius: var(--radius-md);
    padding: 4px;
}

.brand-badge h2 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-text h3 {
    font-size: 24px;
    margin-bottom: 12px;
    font-weight: 700;
}

.brand-text p {
    color: rgba(255, 255, 255, 0.85);
    font-size: 14px;
    margin-bottom: 24px;
}

.feature-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.feature-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13.5px;
    color: rgba(255, 255, 255, 0.9);
}

.feature-list i {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}

.brand-foot {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.form-side {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
}

.auth-card {
    width: 100%;
    max-width: 360px;
}

.auth-card h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 6px;
}

.sub-desc {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 24px;
}

.auth-form .form-group {
    margin-bottom: 18px;
}

.auth-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--ink-light);
}

.auth-form input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: all 0.2s;
    min-height: 48px;
}

.auth-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;

    min-height: 48px;}

.btn-primary:hover {
    background: var(--primary-light);
}

.btn-block {
    width: 100%;
}

.auth-links {
    margin-top: 20px;
    text-align: center;
    font-size: 13.5px;
    color: var(--muted);
}

.auth-links a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    margin-left: 6px;
}

.auth-links a:hover {
    text-decoration: underline;
}

.demo-hint {
    margin-top: 24px;
    padding: 10px 12px;
    background: var(--surface-soft);
    border-radius: var(--radius-sm);
    text-align: center;
    font-size: 12px;
    color: var(--muted);
}

.flash-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #991b1b;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 18px;
}

.flash-success {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    line-height: 1.55;
    margin-bottom: 18px;
}


@media (max-width: 768px) {
    .auth-body {
        align-items: flex-start;
        min-height: 100dvh;
        padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
    }
    .auth-container { display: block; min-height: 0; max-width: 520px; margin: auto; border-radius: 20px; }
    .auth-side { padding: 28px 24px; }
    .brand-side { min-height: 0; gap: 0; border-radius: 20px 20px 0 0; }
    .brand-text, .brand-foot { display: none; }
    .brand-badge { justify-content: center; }
    .auth-logo { width: 42px; height: 42px; }
    .form-side { display: block; }
    .auth-card { max-width: none; }
    .auth-card h2, .sub-desc { text-align: center; }
    .auth-card h2 { font-size: 26px; }
    .sub-desc { margin-bottom: 22px; }
    .auth-form input { font-size: 16px; }
    .auth-links { line-height: 1.8; }
}
@media (max-width: 420px) {
    .auth-body { padding-left: 0; padding-right: 0; background: var(--surface); }
    .auth-container { width: 100%; min-height: 100dvh; border-radius: 0; box-shadow: none; }
    .brand-side { border-radius: 0; padding: max(18px, env(safe-area-inset-top)) 20px 18px; }
    .form-side { padding: 30px 20px max(28px, env(safe-area-inset-bottom)); }
}

/* --------------------------------------------------------------------------
   Ana Sohbet Uygulaması Düzeni
   -------------------------------------------------------------------------- */
.app-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Üst Çubuk */
.top-bar {
    height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
    z-index: 10;
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.app-logo {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.brand-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--primary-dark);
}

.version-badge {
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    border: 1px solid var(--line);
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 8px;
}

.avatar-icon {
    font-size: 24px;
    color: var(--primary);
}

.user-meta {
    display: flex;
    flex-direction: column;
    font-size: 13px;
    line-height: 1.2;
}

.user-role {
    font-size: 11px;
    color: var(--muted);
    text-transform: capitalize;
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    color: var(--ink-light);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    color: #b91c1c;
}

/* Çalışma Alanı */
.workspace {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sol Kenar Çubuğu */
.sidebar {
    width: 340px;
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--line);
    background: var(--surface-soft);
}

.sidebar-tab {
    flex: 1;
    padding: 12px 6px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
}

.sidebar-tab i {
    font-size: 15px;
}

.sidebar-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background: var(--surface);
}

.tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
}

.tab-content.active {
    display: flex;
}

.sidebar-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}

.sidebar-header h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink-light);
}

.btn-icon-refresh {
    background: transparent;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: color 0.2s;
}

.btn-icon-refresh:hover {
    color: var(--primary);
}

.list-container {
    flex: 1;
    overflow-y: auto;
}

.list-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.15s;
}

.list-item:hover {
    background: var(--surface-hover);
}

.list-item.active {
    background: #eef6ff;
    border-left: 3px solid var(--primary);
}

.item-avatar {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full);
    background: var(--primary-glow);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.item-info {
    flex: 1;
    min-width: 0;
}

.item-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13.5px;
    font-weight: 600;
    margin-bottom: 2px;
}

.item-time {
    font-size: 11px;
    color: var(--muted);
    font-weight: normal;
}

.item-snippet {
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.empty-state {
    padding: 40px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

/* AI Sekmesi Özelleri */
.ai-config-box {
    padding: 16px;
    border-bottom: 1px solid var(--line);
    background: #fafafa;
}

.ai-config-box .form-group {
    margin-bottom: 10px;
}

.ai-config-box label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--ink-light);
}

.form-select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
}

.form-select:focus {
    outline: none;
    border-color: var(--ai-theme);
}

.provider-pill-box {
    display: flex;
    gap: 8px;
}

.pill {
    font-size: 11.5px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.active-provider-badge {
    background: #e0e7ff;
    color: #4338ca;
}

.ai-quick-prompts {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quick-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
}

.quick-btn {
    text-align: left;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    color: var(--ink-light);
    cursor: pointer;
    transition: all 0.2s;
}

.quick-btn:hover {
    background: var(--surface);
    border-color: var(--ai-theme);
    color: var(--ai-theme);
}

/* Yönetici Paneli */
.admin-panel-scroll {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.admin-form h4, .admin-test-actions h4, .admin-user-create h4 {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--ink);
}

.admin-form .form-group, .admin-user-create .form-group {
    margin-bottom: 12px;
}

.admin-form label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
}

.admin-form input, .admin-user-create input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
}

.admin-form small {
    display: block;
    color: var(--muted);
    font-size: 11px;
    margin-top: 3px;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 12.5px;
}

.btn-subtle {
    background: var(--surface-soft);
    border: 1px solid var(--line);
    color: var(--ink);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-subtle:hover {
    background: var(--surface-hover);
    border-color: var(--primary);
}

.status-box {
    margin-top: 8px;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    display: none;
}

/* --------------------------------------------------------------------------
   Sağ Sohbet Görünümü
   -------------------------------------------------------------------------- */
.chat-viewport {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f1f5f9;
    position: relative;
}

.chat-header {
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
}

.chat-meta {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-avatar-icon {
    font-size: 26px;
    color: var(--primary);
}

.chat-header h2 {
    font-size: 15px;
    font-weight: 700;
}

.chat-subtitle {
    font-size: 12px;
    color: var(--muted);
}

.encryption-indicator {
    font-size: 11.5px;
    color: var(--success);
    background: #ecfdf5;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    border: 1px solid #a7f3d0;
    display: none;
    align-items: center;
    gap: 6px;
}

/* Mesajlar */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message-row {
    display: flex;
    flex-direction: column;
    max-width: 72%;
}

.message-row.outgoing {
    align-self: flex-end;
    align-items: flex-end;
}

.message-row.incoming {
    align-self: flex-start;
    align-items: flex-start;
}

.message-row.ai {
    align-self: flex-start;
    align-items: flex-start;
    max-width: 82%;
}

.bubble {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.outgoing .bubble {
    background: var(--primary);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.incoming .bubble {
    background: var(--surface);
    color: var(--ink);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--line);
}

.ai .bubble {
    background: #ffffff;
    border: 1px solid rgba(99, 102, 241, 0.2);
    box-shadow: 0 4px 14px -2px var(--ai-theme-glow);
    color: var(--ink);
    border-bottom-left-radius: 4px;
}

.ai-badge-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    font-weight: 700;
    color: var(--ai-theme);
    margin-bottom: 6px;
}

.message-time {
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
}

.outgoing .message-time {
    color: var(--muted);
}

/* Kod ve Markdown */
.bubble pre {
    background: #1e293b;
    color: #f8fafc;
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
    margin: 8px 0;
}

.bubble code {
    background: rgba(0, 0, 0, 0.08);
    padding: 2px 5px;
    border-radius: 4px;
    font-size: 12.5px;
}

.outgoing .bubble code {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Mesaj Yazma Çubuğu */
.composer-area {
    padding: 16px 24px;
    background: var(--surface);
    border-top: 1px solid var(--line);
}

.composer-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.composer-form textarea {
    flex: 1;
    resize: none;
    min-height: 44px;
    max-height: 140px;
    padding: 12px 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
}

.composer-form textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.btn-send {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--primary);
    color: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-send:hover {
    background: var(--primary-light);
    transform: translateY(-1px);
}

/* Karşılama Ekranı */
.welcome-screen {
    margin: auto;
    text-align: center;
    max-width: 480px;
}

.welcome-logo {
    width: 68px;
    height: 68px;
    margin-bottom: 16px;
}

.welcome-screen h3 {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 6px;
}

.welcome-screen p {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 24px;
}

.welcome-cards {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.welcome-card {
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 18px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
}

.welcome-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.welcome-card i {
    font-size: 24px;
    color: var(--primary);
    margin-bottom: 4px;
}

.welcome-card strong {
    font-size: 13.5px;
}

.welcome-card span {
    font-size: 11.5px;
    color: var(--muted);
}

/* Yazıyor Animasyonu */
.typing-indicator {
    display: inline-flex;
    gap: 4px;
    align-items: center;
    padding: 8px 12px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--muted);
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Geri düğmesi yalnızca dar ekranda görünür; geniş ekranda liste ve içerik
   zaten yan yana durduğu için dönülecek bir yer yoktur. */
.chat-back-btn {
    display: none;
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink-light);
    font-size: 14px;
    cursor: pointer;
}

.chat-back-btn:hover { color: var(--primary); border-color: var(--primary); }

/* Mobil / Küçük Ekranlar
   Kenar çubuğu ve içerik alanı yan yana sığmaz; ekranda aynı anda yalnızca
   biri durur. Hangisi olduğunu .chat-open belirler (bkz. showContentPane). */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: 100%;
    }
    .chat-viewport {
        display: none;
    }
    .app-layout.chat-open .sidebar {
        display: none;
    }
    .app-layout.chat-open .chat-viewport {
        display: flex;
    }
    .chat-back-btn {
        display: inline-flex;
    }
    /* Flex öğesinin min-width varsayılanı "auto"dur: içerik kendi doğal
       genişliğinden dar olamaz, bu yüzden içerik alanı 375px ekranda 828px
       kalıp sayfayı yatay kaydırıyordu. min-width:0 küçülmeye izin verir. */
    .app-layout.chat-open .chat-viewport {
        display: flex;
        width: 100%;
        min-width: 0;
        max-width: 100vw;
    }
    .messages-container {
        min-width: 0;
    }
    .lesson-view {
        max-width: 100%;
        width: 100%;
    }
    /* Dar ekranda başlıklar sarmalanıp satır kaydırmasın; taşan metin
       kırpılır, böylece geri düğmesi ve durum rozeti yerinde kalır. */
    .top-bar { padding: 8px 12px; gap: 8px; }
    .brand-title {
        font-size: 15px;
        white-space: nowrap;
    }
    /* Sürüm rozeti ve rol yazısı dar ekranda yer kaplamasın */
    .version-badge { display: none; }
    .user-meta { display: none; }
    .chat-header { padding: 10px 12px; }
    .chat-meta { min-width: 0; }
    .chat-meta > div { min-width: 0; }
    .chat-header h2 {
        font-size: 15px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .chat-subtitle {
        display: block;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    .chat-tools { flex-shrink: 0; }
    .lesson-view {
        padding: 18px 16px 48px;
    }
    .bubble-meta {
        max-width: 100%;
    }
}

/* Kişi arama kutusu: rehber listelenmez, yalnızca arananlar gösterilir. */
.user-search { padding: 10px 12px 4px; }
.user-search-input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border, #dedfdc);
    border-radius: 8px;
    font-size: 13px;
    background: #fff;
    outline: none;
}
.user-search-input:focus { border-color: var(--accent, #2f6feb); }

/* ---------------------------------------------------------------------------
   Şifreli sohbet: oda anahtarı paneli
   --------------------------------------------------------------------------- */

.encryption-indicator.pending {
    color: var(--accent);
    background: #fffbeb;
    border-color: #fde68a;
}

.encryption-indicator.active {
    color: var(--success);
    background: #ecfdf5;
    border-color: #a7f3d0;
}

.encryption-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 14px;
    padding: 12px 18px;
    background: var(--surface-soft);
    border-bottom: 1px solid var(--line);
}

.encryption-panel[hidden] {
    display: none;
}

.encryption-panel-main {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1 1 260px;
    min-width: 0;
}

.encryption-panel-icon {
    color: var(--accent);
    margin-top: 2px;
    flex-shrink: 0;
}

.encryption-panel-text {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--ink-light);
}

.encryption-panel-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.enc-btn {
    font: inherit;
    font-size: 12.5px;
    padding: 7px 14px;
    border-radius: var(--radius-full);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink-light);
    cursor: pointer;
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.enc-btn:hover {
    background: var(--surface-hover);
    border-color: var(--muted);
}

.enc-btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.enc-btn.primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.enc-btn[hidden] {
    display: none;
}

.encryption-unlock {
    display: flex;
    gap: 8px;
    flex: 1 1 100%;
}

.encryption-unlock[hidden] {
    display: none;
}

.encryption-key-input {
    flex: 1 1 auto;
    min-width: 0;
    font: inherit;
    font-size: 13px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
}

.encryption-key-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Kilitli mesaj balonu: gövde sunucudan hiç gelmez */
.bubble.locked {
    background: var(--surface-soft);
    color: var(--muted);
    border: 1px dashed var(--line);
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bubble.encrypted {
    border-left: 3px solid var(--success);
}

/* Sistem bildirimi (kota düşümü, anahtar akışı sonuçları) */
.system-notice {
    align-self: center;
    max-width: 82%;
    margin: 8px auto;
    padding: 8px 14px;
    font-size: 12.5px;
    line-height: 1.5;
    text-align: center;
    color: var(--ink-light);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

.system-notice.error {
    color: #92400e;
    background: #fffbeb;
    border-color: #fde68a;
}

/* ---------------------------------------------------------------------------
   AHD dili öğrenme bölümü
   --------------------------------------------------------------------------- */

.lesson-search {
    padding: 10px 14px 6px;
}

.lesson-search-input {
    width: 100%;
    font: inherit;
    font-size: 13px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--ink);
}

.lesson-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.lesson-group {
    padding: 12px 16px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--muted);
}

.lesson-item .list-item-body strong {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.4;
}

/* Ders içeriği: sohbet balonu değil, okunabilir bir belge */
.lesson-view {
    max-width: 780px;
    margin: 0 auto;
    padding: 26px 30px 60px;
    color: var(--ink);
    font-size: 15px;
    line-height: 1.72;
}

.lesson-view h2,
.lesson-view h3,
.lesson-view h4,
.lesson-view h5 {
    line-height: 1.3;
    color: var(--ink);
    margin: 1.8em 0 .6em;
}

.lesson-view h2 { font-size: 25px; margin-top: .2em; }
.lesson-view h3 { font-size: 20px; }
.lesson-view h4 { font-size: 17px; }
.lesson-view h5 { font-size: 15px; color: var(--ink-light); }

.lesson-view p { margin: 0 0 1em; }

.lesson-view ul,
.lesson-view ol {
    margin: 0 0 1.1em;
    padding-left: 1.5em;
}

.lesson-view li { margin-bottom: .35em; }

.lesson-view blockquote {
    margin: 1.2em 0;
    padding: 12px 18px;
    border-left: 3px solid var(--accent);
    background: var(--surface-soft);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--ink-light);
}

.lesson-view hr {
    border: none;
    border-top: 1px solid var(--line);
    margin: 2em 0;
}

.lesson-view code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: .9em;
    padding: 2px 6px;
    border-radius: 5px;
    background: var(--surface-hover);
    color: var(--primary-dark);
}

.lesson-view pre {
    margin: 0 0 1.2em;
    padding: 14px 16px;
    overflow-x: auto;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

.lesson-view pre code {
    padding: 0;
    background: none;
    color: var(--ink);
}

/* Geniş tablolar sayfayı yatay kaydırmaya zorlamaz, kendi içinde kayar */
.lesson-table-wrap {
    overflow-x: auto;
    margin: 0 0 1.4em;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
}

.lesson-view table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.lesson-view th,
.lesson-view td {
    padding: 9px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.lesson-view thead th {
    background: var(--surface-soft);
    font-weight: 600;
    white-space: nowrap;
}

.lesson-view tbody tr:last-child td { border-bottom: none; }

.composer-area[hidden] { display: none; }

/* ---------------------------------------------------------------------------
   Panel sekmesi ve sohbet araçları
   --------------------------------------------------------------------------- */

.btn-icon-tool {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
    transition: color .15s ease, border-color .15s ease;
}

.btn-icon-tool:hover { color: var(--danger); border-color: var(--danger); }
.btn-icon-tool[hidden] { display: none; }

.panel-box { padding: 6px 14px 20px; overflow-y: auto; }

.panel-user {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    margin-bottom: 14px;
}

.panel-user strong { font-size: 14px; }
.panel-user span { font-size: 12px; color: var(--muted); }

.panel-role {
    align-self: flex-start;
    margin-top: 4px;
    padding: 2px 9px;
    border-radius: var(--radius-full);
    background: var(--primary);
    color: #fff !important;
    font-size: 11px !important;
    font-weight: 600;
}

.panel-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.panel-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 12px 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
}

.panel-stat i { color: var(--primary); font-size: 15px; margin-bottom: 2px; }
.panel-stat strong { font-size: 18px; line-height: 1.1; }
.panel-stat span { font-size: 11px; color: var(--muted); text-align: center; }

.panel-section {
    padding-top: 14px;
    margin-top: 14px;
    border-top: 1px solid var(--line);
}

.panel-section h4 {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted);
}

.panel-hint { margin: 0 0 8px; font-size: 12px; line-height: 1.5; color: var(--ink-light); }
.panel-empty { margin: 0; font-size: 12px; color: var(--muted); }

.panel-quota {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 6px 0;
    font-size: 13px;
    color: var(--ink-light);
}

.panel-quota strong { color: var(--ink); }

.panel-blocked-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 7px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--line);
}

.panel-blocked-row:last-child { border-bottom: none; }


.profile-panel { padding: 10px 14px 24px; overflow-y: auto; }
.profile-form {
    padding: 16px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
}
.profile-form h4 { margin-bottom: 4px; font-size: 14px; }
.profile-form > p { margin-bottom: 14px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.profile-form .form-group { margin-bottom: 13px; }
.profile-form label { display: block; margin-bottom: 5px; color: var(--ink-light); font-size: 12px; font-weight: 600; }
.profile-form input {
    width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line);
    border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-size: 16px;
}
.profile-form input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }
.profile-status { margin-bottom: 12px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 12px; }
.profile-status.success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.profile-status.error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.profile-status[hidden] { display: none; }

/* ---------------------------------------------------------------------------
   Şifreli mesajın çözümlemesi
   Model AHD cümlesinin yanında akıcı karşılık, niyet, gloss ve çözümleme
   üretir. Bunlar mesajın kendisi değil, ona ait bir ektir; bu yüzden balondan
   ayrı ama onunla aynı hizada, kapalı başlayan bir bloka konur.
   --------------------------------------------------------------------------- */

.bubble-meta-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 5px;
    padding: 5px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-full);
    background: var(--surface);
    color: var(--muted);
    font: inherit;
    font-size: 11.5px;
    font-weight: 600;
    cursor: pointer;
    transition: color .15s ease, border-color .15s ease, background .15s ease;
}

.bubble-meta-toggle:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--surface-hover);
}

.bubble-meta-toggle .chev {
    font-size: 9px;
    transition: transform .18s ease;
}

.bubble-meta-toggle.open {
    color: var(--primary);
    border-color: var(--primary);
}

.bubble-meta-toggle.open .chev { transform: rotate(180deg); }

.bubble-meta {
    max-width: min(560px, 88%);
    margin-top: 8px;
    border: 1px solid var(--line);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.bubble-meta[hidden] { display: none; }

.bubble-meta-row {
    padding: 11px 15px;
}

.bubble-meta-row + .bubble-meta-row {
    border-top: 1px solid var(--line);
}

.bubble-meta-label {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--primary);
}

.bubble-meta-label i { font-size: 10px; opacity: .75; }

.bubble-meta-row p {
    margin: 0;
    font-size: 13px;
    line-height: 1.65;
    color: var(--ink-light);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

/* Gloss morfem dizisidir: tireli yapısı ancak eşaralıklı yazıyla okunur */
.bubble-meta-row p.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--ink);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
}

.admin-models {
    padding-top: 16px;
    margin-top: 16px;
    border-top: 1px solid var(--line);
}
.admin-models h4 { margin-bottom: 6px; }
.admin-model-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-model-actions .btn-subtle { flex: 1 1 110px; }
.admin-models .form-select { width: 100%; min-height: 44px; font-size: 13px; }


/* Yönetici kullanıcı listesi */
.admin-users-count { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.admin-users-search-box { margin: 14px 16px 8px; }
.admin-users-list { padding: 8px 16px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.admin-user-card { display: flex; gap: 11px; padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.admin-user-avatar { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 50%; color: var(--primary); background: var(--primary-glow); }
.admin-user-info { min-width: 0; flex: 1; }
.admin-user-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.admin-user-title strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.admin-role-badge { flex: 0 0 auto; padding: 3px 7px; border-radius: 999px; font-size: 10px; font-weight: 700; color: #475569; background: #e2e8f0; }
.admin-role-badge.is-admin { color: #6d28d9; background: #ede9fe; }
.admin-user-email { display: block; margin-top: 3px; color: var(--primary); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.admin-user-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 7px; color: var(--muted); font-size: 10.5px; }
