/* sidenav.css — sidebar + VS-style tab стилүүд
 * ---------------------------------------------
 */

/* ── Workspace layout ───────────────────────────────────────────── */
.workspace {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

/* ── Tab bar ────────────────────────────────────────────────────── */
.tab-bar {
    display: flex;
    align-items: flex-start;   /* tab-item-уудыг дээр байлгаж, scrollbar-д зай үлдэнэ */
    background: #eef2f7;
    border-bottom: 1px solid #e5e7eb;
    height: 44px;
    min-height: 44px;
    flex-shrink: 0;
    padding-right: .3rem;
    min-width: 0;
    position: sticky;
    top: 0;
    z-index: 20;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.tab-list {
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    height: 44px;
    padding-bottom: 6px;       /* scrollbar-т зориулсан зай — tab текст халхлагдахгүй */
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}
.tab-list::-webkit-scrollbar { height: 6px; }
.tab-list::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.tab-list::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.tab-list::-webkit-scrollbar-track { background: transparent; }

.tab-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 6px 0 10px;
    height: 38px;
    min-width: 96px;
    max-width: 220px;
    background: #eef2f7;
    border: none;
    border-right: 1px solid #e0e6ee;
    cursor: pointer;
    font-size: 12.5px;
    color: #475569;
    white-space: nowrap;
    flex-shrink: 0;
    font-family: inherit;
    position: relative;
    transition: background .12s, color .12s;
}
.tab-item:hover { background: #dee5ef; color: #1e293b; }
.tab-item.active {
    background: white;
    color: #1d5ede;
    font-weight: 500;
}
.tab-item.active::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -1px; height: 2px;
    background: #1d5ede;
}
.tab-item.pinned {
    min-width: 44px;
    padding-left: 8px;
    padding-right: 6px;
}
.tab-item.pinned .tab-title { display: none; }

.tab-icon { font-size: 14px; line-height: 1; flex-shrink: 0; }

.tab-pin {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px; height: 18px;
    font-size: 11px;
    color: #9ca3af;
    border-radius: 3px;
    opacity: 0;
    transition: opacity .12s, color .12s, background .12s, transform .12s;
    flex-shrink: 0;
    transform: rotate(45deg);   /* pin unpinned icon */
}
.tab-item:hover .tab-pin,
.tab-item.active .tab-pin,
.tab-item.pinned .tab-pin { opacity: 1; }
.tab-pin:hover { background: #dbeafe; color: #1d5ede; }
.tab-item.pinned .tab-pin {
    color: #1d5ede;
    transform: rotate(0deg);
}

.tab-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.tab-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px; height: 18px;
    font-size: 15px;
    line-height: 1;
    color: #9ca3af;
    border-radius: 3px;
    opacity: 0;
    transition: opacity .1s, background .12s, color .12s;
    flex-shrink: 0;
}
.tab-item:hover .tab-close,
.tab-item.active .tab-close { opacity: 1; }
.tab-close:hover { background: #fee2e2; color: #dc2626; }
/* Pinned tab-нд × нууна */
.tab-item.pinned .tab-close { display: none; }

/* ── Tab actions (close all / close unpinned) ──────────────────── */
.tab-actions {
    display: none;
    align-items: stretch;
    border-left: 1px solid #e0e6ee;
    flex-shrink: 0;
}
body.has-tabs .tab-actions { display: inline-flex; }

.tab-action-btn {
    padding: 0 .8rem;
    height: 38px;
    background: transparent;
    border: none;
    color: #64748b;
    font-size: 12.5px;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}
.tab-action-btn:hover { background: #e2e8f0; color: #1e293b; }
.tab-action-btn.danger:hover { background: #fee2e2; color: #dc2626; }

/* Tab байхгүй үед tab-bar бүрмөсөн нуугдана */
body:not(.has-tabs) .tab-bar { display: none; }

/* ── Tab context menu (right-click) ────────────────────────────── */
.tab-ctx-menu {
    position: fixed;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 7px;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    padding: .35rem 0;
    min-width: 180px;
    z-index: 1000;
    font-size: 13px;
}
.tab-ctx-item {
    padding: .45rem .85rem;
    cursor: pointer;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: .5rem;
    white-space: nowrap;
}
.tab-ctx-item:hover { background: #eff6ff; color: #1d5ede; }
.tab-ctx-item.danger:hover { background: #fee2e2; color: #dc2626; }
.tab-ctx-sep { height: 1px; background: #f1f5f9; margin: .3rem 0; }

/* ── Tab viewport + home + iframes ─────────────────────────────── */
.tab-viewport {
    flex: 1;
    position: relative;
    background: #f0f2f5;
    overflow: hidden;
    min-height: 0;
}

.tab-home {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    overflow-x: auto;
    background: #f0f2f5;
}
.tab-home.hidden { display: none; }

.tab-frame {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    background: white;
    display: none;
}
.tab-frame.active { display: block; }

/* ── Iframe дотор: зөвхөн контентыг харуулах ──────────────────── */
body.in-iframe header,
body.in-iframe .sidebar,
body.in-iframe .workspace > .tab-bar,
body.in-iframe footer { display: none !important; }

body.in-iframe #page-wrap { display: block !important; min-height: 0 !important; }
body.in-iframe .workspace {
    flex: initial;
    display: block;
    overflow: visible;
    min-width: 0;
    min-height: 0;
}
body.in-iframe .tab-viewport {
    position: static;
    overflow: visible;
}
body.in-iframe .tab-home {
    position: static;
    inset: auto;
    overflow: visible;
}
body.in-iframe main.container {
    padding: 1.2rem 1.4rem;
}
