/* Tabler Icons: CSS maskesi; simge rengi çevreleyen metnin rengidir */
.ic {
    display: inline-block;
    width: 1.25em;
    height: 1.25em;
    flex: 0 0 auto;
    vertical-align: -0.25em;
    background: currentColor;
    -webkit-mask: var(--ic) center / contain no-repeat;
    mask: var(--ic) center / contain no-repeat;
}

.btn-icon .ic { width: 1.25rem; height: 1.25rem; vertical-align: middle; }

/* ---- Uygulama kabuğu (giriş sonrası) ---- */

html, body { height: 100%; }
body.app-body { overflow: hidden; }

.app {
    position: relative;
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    background: var(--tblr-bg-surface);
}

.app-rail {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 0;
    padding: 8px 0;
    border-right: 1px solid var(--tblr-border-color);
    /* Şerit rengi temadan gelir (themeBar); tema yoksa yüzey rengi */
    background: var(--theme-bar, var(--tblr-bg-surface));
    color: var(--theme-bar-text, var(--tblr-body-color));
    /* Hesap menüsü şeridin dışına taştığı için kırpılmamalı */
    overflow: visible;
    position: relative;
    z-index: 6;
}

.rail-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 10px 2px;
    color: var(--theme-bar-text, var(--tblr-secondary));
    opacity: .78;
    font-size: 11px;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    border-left: 3px solid transparent;
}

.rail-item .ic { width: 1.5rem; height: 1.5rem; }

.rail-item:hover {
    opacity: 1;
    color: var(--theme-bar-text, var(--tblr-body-color));
    background: color-mix(in srgb, var(--theme-bar-text, #888) 12%, transparent);
}

.rail-item.active {
    opacity: 1;
    color: var(--theme-bar-text, var(--tblr-primary));
    border-left-color: var(--tblr-primary);
    background: color-mix(in srgb, var(--tblr-primary) 32%, transparent);
}

/* Dil seçici: açılır kutu, dil sayısı arttıkça menü uzamaz */
.prefs-lang { min-width: 200px; padding: 2px 16px 10px; }

/* Tema seçici: her tema bir yuvarlak düğme (yarısı çubuk rengi, yarısı vurgu rengi) */
.theme-swatches { display: flex; flex-wrap: wrap; gap: 8px; max-width: 220px; padding: 4px 16px 12px; }

.theme-swatch {
    width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 50%;
    border: 2px solid transparent;
    background: linear-gradient(135deg, var(--sw-bar) 50%, var(--sw-accent) 50%);
    box-shadow: 0 0 0 1px var(--tblr-border-color);
    cursor: pointer;
}

.theme-swatch:hover { transform: scale(1.1); }
.theme-swatch.active { border-color: var(--tblr-bg-surface); box-shadow: 0 0 0 2px var(--tblr-primary); }

.app-workspace { position: relative; min-width: 0; min-height: 0; }

/* Sağdan kayan panel; yığın boşken dışarıda durur */
.app-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    width: min(380px, 100%);
    background: var(--tblr-bg-surface);
    border-left: 1px solid var(--tblr-border-color);
    box-shadow: -8px 0 24px rgba(0, 0, 0, .12);
    transform: translateX(105%);
    transition: transform .2s ease;
}

.app-panel[data-open="1"] { transform: translateX(0); }

.fw-frame { height: 100%; }
.fw-frame[hidden] { display: none; }

[data-loading="1"]::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    z-index: 10;
    background: var(--tblr-primary);
    animation: fw-load 1s ease-in-out infinite;
}

@keyframes fw-load {
    0%   { transform: scaleX(0); transform-origin: left; }
    50%  { transform: scaleX(1); transform-origin: left; }
    51%  { transform: scaleX(1); transform-origin: right; }
    100% { transform: scaleX(0); transform-origin: right; }
}

.fw-error {
    position: fixed;
    left: 50%;
    bottom: 72px;
    transform: translateX(-50%);
    z-index: 2000;
    margin: 0;
    display: none;
}

.fw-error[data-show="1"] { display: block; }

/* ---- Gelen kutusu: klasörler | liste | konuşma ---- */

.inbox {
    display: grid;
    grid-template-columns: 260px 340px minmax(0, 1fr);
    height: 100%;
    min-height: 0;
}

.inbox-folders,
.inbox-list {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    border-right: 1px solid var(--tblr-border-color);
    background: var(--tblr-bg-surface);
}

.inbox-head {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
    height: 56px;
    padding: 0 12px;
    border-bottom: 1px solid var(--tblr-border-color);
}

.inbox-title { margin: 0; font-size: 1.1rem; font-weight: 600; }
.inbox-scroll { flex: 1; min-height: 0; overflow-y: auto; }

/* Klasör listesi */
.folder-list { padding: 8px; }

.folder-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 8px;
    color: var(--tblr-body-color);
    text-decoration: none;
}

.folder-item:hover { background: var(--tblr-bg-surface-secondary); }
.folder-item.active { background: var(--tblr-primary-lt); color: var(--tblr-primary); font-weight: 600; }
.folder-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-count { color: var(--tblr-secondary); font-size: 12px; }

.folder-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px 4px;
    color: var(--tblr-secondary);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
}

.folder-chevron { transition: transform .15s ease; }
.folder-group-title.collapsed .folder-chevron { transform: rotate(-90deg); }

/* Konuşma listesi */
.inbox-tabs .nav-link { padding: 0.5rem 0.75rem; }

.inbox-filter {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
    padding: 8px 12px;
    border-bottom: 1px solid var(--tblr-border-color);
}

.conv {
    position: relative;
    display: flex;
    gap: 12px;
    padding: 12px;
    color: var(--tblr-body-color);
    text-decoration: none;
    border-bottom: 1px solid var(--tblr-border-color);
}

.conv:hover { background: var(--tblr-bg-surface-secondary); }
.conv.active { background: var(--tblr-primary-lt); }
.conv .avatar { position: relative; overflow: visible; }

.channel-badge {
    position: absolute;
    right: -4px;
    bottom: -4px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--tblr-bg-surface);
    background: var(--tblr-secondary);
    color: #fff;
}

.channel-badge .ic { width: 11px; height: 11px; vertical-align: 0; }
.ch-whatsapp  { background: #25d366; }
.ch-telegram  { background: #229ed9; }
.ch-instagram { background: #e1306c; }
.ch-mail      { background: #667382; }
.ch-chat      { background: var(--tblr-primary); }

.conv-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.conv-top { display: flex; align-items: baseline; gap: 8px; }
.conv-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-time { color: var(--tblr-secondary); font-size: 12px; }
.conv-preview { color: var(--tblr-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-preview .ic { width: 1em; height: 1em; vertical-align: -0.1em; }
.conv-meta { display: flex; align-items: center; gap: 6px; }

/* Konuşma bölmesi (alan: thread) */
.inbox-thread { position: relative; min-width: 0; min-height: 0; background: var(--tblr-bg-surface); }
.inbox-thread[data-open="1"] > .inbox-empty { display: none; }
.inbox-empty { height: 100%; }

.thread-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 52px;
    height: 100%;
}

.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }

.thread-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    height: 56px;
    padding: 0 12px;
    border-bottom: 1px solid var(--tblr-border-color);
}

.thread-name { font-weight: 600; }

.thread-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 16px;
    background: var(--tblr-bg-surface-secondary);
}

.thread-rail {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding-top: 8px;
    border-left: 1px solid var(--tblr-border-color);
    background: var(--tblr-bg-surface);
}

/* Mesajlar */
.msg { display: flex; align-items: flex-end; gap: 8px; margin: 6px 0; }
.msg.out { justify-content: flex-end; }

.bubble {
    max-width: min(75%, 560px);
    padding: 8px 12px;
    border-radius: 14px;
    background: var(--tblr-bg-surface);
    border: 1px solid var(--tblr-border-color);
    overflow-wrap: anywhere;
}

/* Kullanıcının yazdığı satır sonları korunur; şablon girintileri etkilenmez */
.bubble-text { white-space: pre-wrap; }

.msg.out .bubble { background: var(--tblr-primary-lt); border-color: transparent; }
.bubble-time { margin-left: 8px; font-size: 11px; color: var(--tblr-secondary); white-space: nowrap; }

.msg-system {
    margin: 12px 0;
    text-align: center;
    color: var(--tblr-secondary);
    font-size: 12px;
}

.msg-call { max-width: min(92%, 640px); margin: 12px auto; }

/* Mesaj yazma alanı */
.composer {
    flex: 0 0 auto;
    padding: 8px 12px 12px;
    border-top: 1px solid var(--tblr-border-color);
    background: var(--tblr-bg-surface);
}

.composer-channel { margin-bottom: 6px; }

.composer-box {
    border: 1px solid var(--tblr-border-color);
    border-radius: 10px;
    padding: 8px;
    background: var(--tblr-bg-surface);
}

.composer-box:focus-within { border-color: var(--tblr-primary); }

.composer-input {
    display: block;
    width: 100%;
    max-height: 140px;
    padding: 4px;
    border: 0;
    outline: 0;
    resize: none;
    background: transparent;
    color: var(--tblr-body-color);
    font: inherit;
}

.composer-tools { display: flex; align-items: center; gap: 2px; margin-top: 4px; }

/* Kişi paneli */
.panel-frame { display: flex; flex-direction: column; height: 100%; }

.panel-head {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
    height: 56px;
    padding: 0 12px 0 16px;
    border-bottom: 1px solid var(--tblr-border-color);
}

.panel-title { margin: 0; font-size: 1rem; font-weight: 600; }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px; }

/* ---- Orta genişlik: klasörler çekmeceye geçer ---- */

@media (max-width: 991.98px) {
    .inbox { grid-template-columns: 340px minmax(0, 1fr); }
    .inbox-folders { width: 280px; }
    .thread-wrap { grid-template-columns: minmax(0, 1fr); }
    .thread-rail { display: none; }
}

/* ---- Mobil: menü altta, tek bölme (liste, konuşma üstüne biner) ---- */

@media (max-width: 767.98px) {
    .app {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) 60px;
    }

    .app-workspace { order: 1; }

    .app-rail {
        order: 2;
        flex-direction: row;
        justify-content: space-between;
        align-items: stretch;
        padding: 0;
        border-right: 0;
        border-top: 1px solid var(--tblr-border-color);
    }

    .app-rail-main, .app-rail-foot { display: flex; align-items: stretch; }
    .app-rail-main { flex: 1; justify-content: space-around; }
    .rail-item { border-left: 0; border-top: 3px solid transparent; padding: 6px 8px; justify-content: center; }
    .rail-item.active { border-left-color: transparent; border-top-color: var(--tblr-primary); }    .rail-item span:not(.avatar) { display: none; }
    .rail-item .ic { width: 1.4rem; height: 1.4rem; }

    .app-panel { width: 100%; bottom: 60px; }

    .inbox { grid-template-columns: minmax(0, 1fr); }
    .inbox-list { border-right: 0; }

    /* Konuşma, listenin üstünü kaplar; geri ile kapanınca liste görünür */
    .inbox-thread { display: none; }

    .inbox-thread[data-open="1"] {
        display: block;
        position: absolute;
        inset: 0;
        z-index: 4;
    }

    .bubble { max-width: 85%; }
}

/* ---- Ayarlar: ayar menüsü | içerik ---- */

.split {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    height: 100%;
    min-height: 0;
}

.split-menu {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    border-right: 1px solid var(--tblr-border-color);
    background: var(--tblr-bg-surface);
}

.split-group { padding-top: 6px; }

.split-group-title {
    padding: 10px 18px 2px;
    color: var(--tblr-secondary);
    font-size: 12px;
    font-weight: 600;
}

.split-group .folder-list { padding-top: 4px; padding-bottom: 4px; }

.split-content {
    position: relative;
    min-width: 0;
    min-height: 0;
    background: var(--tblr-bg-surface);
}

.split-content[data-open="1"] > .inbox-empty { display: none; }

/* Ayar sayfası: üst başlık + kaydırılan gövde (ortak, her modülde kullanılabilir) */
.page-frame { display: flex; flex-direction: column; height: 100%; min-height: 0; }

.page-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 0 auto;
    padding: 14px 20px;
    border-bottom: 1px solid var(--tblr-border-color);
}

.page-head-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--tblr-primary-lt);
    color: var(--tblr-primary);
}

.page-head-icon .ic { width: 1.35rem; height: 1.35rem; vertical-align: 0; }
.page-head-text { min-width: 0; }
.page-head-title { margin: 0; font-size: 1.05rem; font-weight: 600; }
.page-head-sub { font-size: 13px; }
.page-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px 24px; }

/* Kanal kataloğu */
.catalog-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--tblr-border-color);
}

.catalog-tabs { flex: 1; min-width: 0; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; margin-bottom: -1px; }
.catalog-tabs .nav-link { white-space: nowrap; padding: 0.55rem 0.8rem; }

.catalog-search { position: relative; flex: 0 1 280px; min-width: 180px; padding-bottom: 8px; }
.catalog-search .form-control { padding-left: 34px; }

.catalog-search-icon {
    position: absolute;
    left: 10px;
    top: 8px;
    color: var(--tblr-secondary);
    pointer-events: none;
}

.catalog-section[hidden], .channel-card[hidden], .catalog-empty[hidden] { display: none; }
.catalog-section-title { margin: 18px 0 10px; font-size: 13px; font-weight: 600; }

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.channel-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 150px;
    padding: 14px 14px 12px;
    border: 1px solid var(--tblr-border-color);
    border-radius: 10px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--tint) 11%, var(--tblr-bg-surface)), var(--tblr-bg-surface) 70%);
}

.channel-card:hover { border-color: color-mix(in srgb, var(--tint) 45%, var(--tblr-border-color)); }

.channel-icon {
    position: absolute;
    top: 12px;
    right: 12px;
    color: var(--tint);
}

.channel-icon .ic { width: 2.1rem; height: 2.1rem; vertical-align: 0; }

.channel-name { margin: 0; padding-right: 44px; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }

.channel-desc {
    margin: 0;
    color: var(--tblr-secondary);
    font-size: 12.5px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.channel-foot {
    display: flex;
    justify-content: flex-end;
    margin-top: auto;
    padding-top: 8px;
    border-top: 1px solid var(--tblr-border-color);
}

.channel-badge-tag {
    align-self: flex-start;
    padding: 1px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
}

.channel-badge-popular { background: color-mix(in srgb, #2fb344 16%, transparent); color: #2fb344; }
.channel-badge-beta { background: color-mix(in srgb, var(--tblr-primary) 16%, transparent); color: var(--tblr-primary); }

@media (max-width: 767.98px) {
    .split { grid-template-columns: minmax(0, 1fr); }
    .split-menu { border-right: 0; }

    /* İçerik, menünün üstünü kaplar; geri ile kapanınca menü görünür */
    .split-content { display: none; }

    .split-content[data-open="1"] {
        display: block;
        position: absolute;
        inset: 0;
        z-index: 4;
    }

    .page-head { padding: 10px 12px; }
    .page-body { padding: 12px; }
    .catalog-search { flex-basis: 100%; }
}

/* ---- Raporlar: KPI kutuları ve grafik kartları ---- */

.page-head-meta { margin-left: auto; text-align: right; font-size: 12px; color: var(--tblr-secondary); line-height: 1.4; }
.report-desc { margin: 0 0 14px; max-width: 760px; }

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.kpi {
    padding: 14px 16px;
    border: 1px solid var(--tblr-border-color);
    border-radius: 10px;
    background: var(--tblr-bg-surface);
}

.kpi-label { display: flex; align-items: center; gap: 6px; color: var(--tblr-secondary); font-size: 13px; font-weight: 600; }
.kpi-info { width: 1em; height: 1em; opacity: .7; }
.kpi-row { display: flex; align-items: baseline; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.kpi-value { font-size: 1.8rem; font-weight: 500; line-height: 1.1; }
.kpi-delta { font-size: 12px; font-weight: 600; }
.kpi-flat { color: var(--tblr-secondary); }
.kpi-good { color: #2fb344; }
.kpi-bad { color: #d63939; }

.report-card {
    min-width: 0;
    padding: 14px 16px 16px;
    border: 1px solid var(--tblr-border-color);
    border-radius: 10px;
    background: var(--tblr-bg-surface);
}

.report-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.report-card-title { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 14px; font-weight: 600; }
.report-control { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 13px; }
.report-control .form-select { min-width: 150px; }

/* Chart.js, boyutu kabın yüksekliğinden alır: kap sabit yükseklikli olmalı */
.chart-box { position: relative; height: 340px; }

.report-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 14px; }

@media (max-width: 991.98px) {
    .report-row { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 767.98px) {
    .chart-box { height: 280px; }
    .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .kpi { padding: 10px 12px; }
    .kpi-value { font-size: 1.35rem; }
}