/* =====================================================================
   DÖVME STÜDYOSU CHATBOT PLATFORMU — ADMIN PANEL CSS
   =====================================================================
   Sakin, koyu-nötr palet. Sade, temiz, kullanışlı.
   Emoji yok, gereksiz animasyon yok. Tam responsive.
   ===================================================================== */

/* ---------- DEĞİŞKENLER ---------- */
:root {
    --bg:           #f4f5f7;
    --surface:      #ffffff;
    --surface-2:    #fafbfc;
    --ink:          #1f2329;
    --ink-soft:     #5a6473;
    --ink-faint:    #8d97a6;
    --line:         #e3e7ed;
    --line-strong:  #d0d6df;
    --accent:       #3a4a5f;
    --accent-hover: #2c3a4d;
    --ok:           #2f7d5b;
    --pending:      #b08400;
    --error-bg:     #fbeaea;
    --error-ink:    #9a2b2b;
    --error-line:   #e8c4c4;
    --radius:       6px;
    --radius-lg:    8px;
    --shadow-sm:    0 1px 2px rgba(31, 35, 41, 0.06);
    --shadow:       0 2px 8px rgba(31, 35, 41, 0.08);
    --sidebar-w:    232px;
    --font:         -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ---------- RESET ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* =====================================================================
   GİRİŞ SAYFASI
   ===================================================================== */
.auth-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg);
    padding: 20px;
}
.auth-wrap { width: 100%; max-width: 380px; }
.auth-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 36px 32px;
}
.auth-head { margin-bottom: 24px; text-align: center; }
.auth-title { font-size: 20px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.auth-sub { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-foot {
    text-align: center;
    font-size: 12px;
    color: var(--ink-faint);
    margin-top: 20px;
}

/* =====================================================================
   FORM ELEMANLARI
   ===================================================================== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.field-input {
    width: 100%;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    outline: none;
    transition: border-color 0.12s ease;
}
.field-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(58, 74, 95, 0.1);
}
.field-input::placeholder { color: var(--ink-faint); }

/* ---------- BUTONLAR ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 16px;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color 0.12s ease, border-color 0.12s ease;
    white-space: nowrap;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost {
    background: transparent;
    color: var(--ink-soft);
    border-color: var(--line-strong);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ---------- UYARILAR ---------- */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
}
.alert-error {
    background: var(--error-bg);
    color: var(--error-ink);
    border: 1px solid var(--error-line);
}

/* =====================================================================
   ADMIN SHELL (sidebar + main)
   ===================================================================== */
.admin-shell { display: flex; min-height: 100vh; }

/* ---------- SIDEBAR ---------- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.sidebar-brand {
    padding: 20px 22px;
    border-bottom: 1px solid var(--line);
}
.brand-mark { font-size: 15px; font-weight: 600; color: var(--ink); letter-spacing: -0.01em; }
.sidebar-nav { padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
    display: block;
    padding: 9px 12px;
    font-size: 14px;
    color: var(--ink-soft);
    border-radius: var(--radius);
    transition: background-color 0.12s ease, color 0.12s ease;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.is-active { background: var(--accent); color: #fff; }
.nav-disabled {
    color: var(--ink-faint);
    cursor: not-allowed;
    opacity: 0.6;
}
.nav-disabled:hover { background: transparent; color: var(--ink-faint); }

/* ---------- ANA ALAN ---------- */
.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ---------- ÜST BAR ---------- */
.topbar {
    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;
}
.topbar-title { font-size: 16px; font-weight: 600; color: var(--ink); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.user-badge { font-size: 13px; color: var(--ink-soft); }

/* ---------- İÇERİK ---------- */
.content { padding: 28px 24px; max-width: 1100px; width: 100%; }
.page-intro { margin-bottom: 22px; }
.page-desc { font-size: 14px; color: var(--ink-soft); }

/* =====================================================================
   İSTATİSTİK KARTLARI
   ===================================================================== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 13px; color: var(--ink-soft); }
.stat-value { font-size: 28px; font-weight: 600; color: var(--ink); letter-spacing: -0.02em; }

/* =====================================================================
   PANEL (içerik kutusu)
   ===================================================================== */
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.panel-head {
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}
.panel-title { font-size: 15px; font-weight: 600; color: var(--ink); }
.panel-body { padding: 20px; }
.muted { color: var(--ink-soft); font-size: 14px; margin-bottom: 16px; }

/* ---------- DURUM LİSTESİ ---------- */
.status-list { display: flex; flex-direction: column; gap: 8px; }
.status-list li {
    font-size: 14px;
    padding-left: 22px;
    position: relative;
    color: var(--ink);
}
.status-list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: 7px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.status-ok::before { background: var(--ok); }
.status-ok { color: var(--ink); }
.status-pending::before { background: var(--pending); }
.status-pending { color: var(--ink-soft); }

/* =====================================================================
   RESPONSIVE
   ===================================================================== */
@media (max-width: 768px) {
    .admin-shell { flex-direction: column; }
    .sidebar {
        width: 100%;
        flex-direction: row;
        align-items: center;
        border-right: none;
        border-bottom: 1px solid var(--line);
        overflow-x: auto;
    }
    .sidebar-brand { border-bottom: none; border-right: 1px solid var(--line); white-space: nowrap; }
    .sidebar-nav { flex-direction: row; padding: 10px; }
    .nav-item { white-space: nowrap; }
    .content { padding: 20px 16px; }
    .topbar { padding: 0 16px; }
    .stat-value { font-size: 24px; }
}

@media (max-width: 420px) {
    .topbar-title { font-size: 15px; }
    .user-badge { display: none; }
    .auth-card { padding: 28px 22px; }
}

/* =====================================================================
   FAZ 2 — TENANT / BOT / EĞİTİM STİLLERİ
   ===================================================================== */

/* ---------- SAYFA BAŞLIĞI (başlık + buton) ---------- */
.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 22px;
    gap: 16px;
}
.page-head .page-intro { margin-bottom: 0; }

/* ---------- BAŞARI UYARISI ---------- */
.alert-success {
    background: #eaf6ef;
    color: #1f6b45;
    border: 1px solid #bfe0cd;
}

/* ---------- GERİ LİNKİ ---------- */
.back-link {
    font-size: 13px;
    color: var(--ink-soft);
    transition: color 0.12s ease;
}
.back-link:hover { color: var(--accent); }

/* ---------- TABLO ---------- */
.table-wrap { overflow-x: auto; }
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.data-table thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.data-table tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--surface-2); }
.cell-strong { font-weight: 500; }
.cell-muted { color: var(--ink-soft); font-size: 13px; }
.col-center { text-align: center; }
.col-actions { white-space: nowrap; text-align: right; }

/* ---------- BADGE ---------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}
.badge-active { background: #e7f4ed; color: #1f6b45; }
.badge-passive { background: #f0f0f2; color: #8d97a6; }

/* ---------- İŞLEM LİNKLERİ ---------- */
.link-action {
    font-size: 13px;
    color: var(--accent);
    padding: 4px 8px;
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
    transition: color 0.12s ease;
}
.link-action:hover { color: var(--accent-hover); text-decoration: underline; }
.link-muted { color: var(--ink-soft); }
.link-danger { color: var(--error-ink); }
.inline-form { display: inline; }

/* ---------- BOŞ DURUM ---------- */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-state .muted { margin-bottom: 16px; }

/* ---------- FORM ---------- */
.panel-form { max-width: 640px; }
.form { display: flex; flex-direction: column; gap: 18px; }
.field-hint {
    font-size: 13px;
    color: var(--ink-faint);
    margin-bottom: 8px;
    display: block;
}
.field-textarea {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.5;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    outline: none;
    resize: vertical;
    transition: border-color 0.12s ease;
}
.field-textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(58, 74, 95, 0.1);
}
.field-row { display: flex; gap: 16px; }
.field-row .field { flex: 1; }
.field-narrow { flex: 0 0 100px; }
.field-color {
    width: 100%;
    height: 38px;
    padding: 3px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    cursor: pointer;
    background: var(--surface);
}
.checkbox-label, .radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--ink);
    cursor: pointer;
}
.radio-group { display: flex; gap: 24px; flex-wrap: wrap; }
.form-actions {
    display: flex;
    gap: 10px;
    padding-top: 4px;
}
.form-actions-sticky {
    position: sticky;
    bottom: 0;
    background: var(--bg);
    padding: 16px 0;
    margin-top: 4px;
    border-top: 1px solid var(--line);
    z-index: 5;
}
.form-note {
    font-size: 13px;
    color: var(--ink-faint);
    padding-top: 8px;
    border-top: 1px solid var(--line);
}

/* ---------- BOT BAŞLIK ---------- */
.bot-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
}
.bot-studio-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 4px;
}

/* ---------- EMBED KOD KUTUSU ---------- */
.code-box {
    background: #2b2f36;
    border-radius: var(--radius);
    padding: 14px 16px;
    margin: 12px 0;
    overflow-x: auto;
}
.code-box code {
    color: #e6e9ee;
    font-family: "SF Mono", Monaco, "Cascadia Code", Consolas, monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-all;
}
.copy-msg {
    font-size: 13px;
    color: var(--ok);
    margin-left: 10px;
}
.key-info {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.key-label { font-size: 13px; color: var(--ink-soft); font-weight: 500; }
.key-value {
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-size: 12px;
    background: var(--surface-2);
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--ink);
    border: 1px solid var(--line);
    word-break: break-all;
}
.warn-inline {
    margin-top: 14px;
    font-size: 13px;
    color: var(--pending);
    background: #fdf6e3;
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid #e8d9a0;
}
code {
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-size: 0.9em;
    background: var(--surface-2);
    padding: 1px 5px;
    border-radius: 3px;
}

/* ---------- PANEL İÇİ TEST CHAT ---------- */
.test-chat { margin-top: 8px; }
.test-messages {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface-2);
    min-height: 200px;
    max-height: 380px;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}
.test-empty {
    color: var(--ink-faint);
    font-size: 14px;
    text-align: center;
    margin: auto;
}
.test-msg {
    max-width: 78%;
    padding: 9px 13px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.test-msg-user {
    align-self: flex-end;
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 3px;
}
.test-msg-bot {
    align-self: flex-start;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    border-bottom-left-radius: 3px;
}
.test-msg-error {
    align-self: flex-start;
    background: var(--error-bg);
    color: var(--error-ink);
    border: 1px solid var(--error-line);
    font-size: 13px;
}
.test-typing { color: var(--ink-faint); font-style: italic; }
.test-input-row { display: flex; gap: 8px; }
.test-input-row .field-input { flex: 1; }

/* ---------- PROMPT ÖNİZLEME ---------- */
.preview-panel { margin-top: 20px; }
.preview-panel .panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.prompt-preview {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    font-family: "SF Mono", Monaco, Consolas, monospace;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--ink);
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 500px;
    overflow-y: auto;
    margin: 0;
}

/* ---------- FAZ 2 RESPONSIVE ---------- */
@media (max-width: 768px) {
    .page-head { flex-direction: column; }
    .bot-header { flex-direction: column; }
    .field-row { flex-direction: column; }
    .field-narrow { flex: 1; }
    .col-actions { text-align: left; }
    .data-table tbody td { padding: 10px 12px; }
    .test-msg { max-width: 88%; }
}

/* =====================================================================
   FAZ 4 — LEAD / KONUŞMA STİLLERİ
   ===================================================================== */

/* ---------- LEAD SAYISI LİNKİ ---------- */
.lead-count-link {
    display: inline-block;
    min-width: 28px;
    padding: 2px 8px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 12px;
    color: var(--accent);
    font-size: 13px;
    font-weight: 500;
    transition: background-color 0.12s ease;
}
.lead-count-link:hover { background: #eef1f5; }

/* ---------- TABLO TRUNCATE ---------- */
.cell-truncate {
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------- KONUŞMA LOG ---------- */
.conv-log {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 640px;
}
.conv-msg {
    display: flex;
    flex-direction: column;
    gap: 3px;
    max-width: 80%;
}
.conv-msg-visitor { align-self: flex-start; }
.conv-msg-bot { align-self: flex-end; align-items: flex-end; }
.conv-role {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--ink-faint);
    padding: 0 4px;
}
.conv-content {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.conv-msg-visitor .conv-content {
    background: var(--surface-2);
    border: 1px solid var(--line);
    color: var(--ink);
    border-bottom-left-radius: 3px;
}
.conv-msg-bot .conv-content {
    background: var(--accent);
    color: #fff;
    border-bottom-right-radius: 3px;
}
.conv-img-tag {
    display: inline-block;
    margin-left: 8px;
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 10px;
    background: rgba(255,255,255,0.2);
    color: inherit;
    opacity: 0.85;
}
.conv-msg-visitor .conv-img-tag {
    background: #e3e7ed;
    color: var(--ink-soft);
}
.conv-time {
    font-size: 11px;
    color: var(--ink-faint);
    padding: 0 4px;
}

/* ---------- FAZ 4 RESPONSIVE ---------- */
@media (max-width: 768px) {
    .cell-truncate { max-width: 120px; }
    .conv-msg { max-width: 90%; }
}

/* =====================================================================
   FAZ 5 — DASHBOARD İSTATİSTİK STİLLERİ
   ===================================================================== */

/* ---------- STAT KART ALT BİLGİ ---------- */
.stat-sub {
    font-size: 12px;
    color: var(--ink-faint);
    margin-top: 2px;
}

/* ---------- BÜTÇE ÇUBUĞU ---------- */
.budget-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.budget-used { font-size: 22px; font-weight: 600; color: var(--ink); }
.budget-sep { color: var(--ink-faint); }
.budget-total { font-size: 14px; color: var(--ink-soft); }
.budget-percent {
    margin-left: auto;
    font-size: 14px;
    font-weight: 600;
    color: var(--ok);
    padding: 2px 10px;
    background: #e7f4ed;
    border-radius: 12px;
}
.budget-percent.budget-warn { color: var(--error-ink); background: var(--error-bg); }
.budget-bar {
    height: 8px;
    background: var(--line);
    border-radius: 4px;
    overflow: hidden;
}
.budget-fill {
    height: 100%;
    background: var(--ok);
    border-radius: 4px;
    transition: width 0.3s ease;
}
.budget-fill-warn { background: var(--error-ink); }
.budget-note { margin-top: 12px; font-size: 13px; }

/* ---------- DASHBOARD KOLONLAR ---------- */
.dash-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}
.dash-col { margin-bottom: 0; }
.panel-body-flush { padding: 0; }
.data-table-compact thead th { padding: 10px 14px; }
.data-table-compact tbody td { padding: 10px 14px; }
.dash-studio-link { color: var(--accent); font-weight: 500; }
.dash-studio-link:hover { text-decoration: underline; }

/* ---------- SON LEAD'LER ---------- */
.recent-list { display: flex; flex-direction: column; }
.recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    gap: 12px;
}
.recent-item:last-child { border-bottom: none; }
.recent-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.recent-name { font-size: 14px; font-weight: 500; color: var(--ink); }
.recent-contact { font-size: 13px; color: var(--ink-soft); }
.recent-meta { display: flex; flex-direction: column; gap: 2px; text-align: right; flex-shrink: 0; }
.recent-studio { font-size: 13px; color: var(--ink-soft); }
.recent-date { font-size: 12px; color: var(--ink-faint); }

/* ---------- KELİME BULUTU ---------- */
.topic-cloud { display: flex; flex-wrap: wrap; gap: 8px; }
.topic-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 16px;
    font-size: 13px;
    color: var(--ink);
}
.topic-count {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    background: #eef1f5;
    padding: 1px 7px;
    border-radius: 10px;
}

/* ---------- FAZ 5 RESPONSIVE ---------- */
@media (max-width: 768px) {
    .dash-columns { grid-template-columns: 1fr; }
    .budget-percent { margin-left: 0; }
}
