/* app.css - מערכת העיצוב של 2Break בוט (על בסיס מערכת העיצוב של גליל גולן בוט)
   סגנון: מינימלי, צפוף-נתונים (admin). טיפוגרפיה: Noto Sans Hebrew + Fira Code לנתונים.
   צבעים: צהוב 2Break על שחור (כהה), ענבר כהה על לבן (בהיר - בשביל ניגודיות). כל הצבעים כטוקנים. */

:root,
[data-bs-theme="light"] {
    --gg-primary: #a85b06;          /* ענבר כהה - ניגוד 5:1 על לבן */
    --gg-primary-hover: #8a4a04;
    --gg-primary-soft: #fff4d6;
    --gg-primary-rgb: 168, 91, 6;
    --gg-accent: #e11d2a;           /* אדום 2Break */
    --gg-accent-soft: #fdecee;
    --gg-bg: #f6f5f2;
    --gg-surface: #ffffff;
    --gg-surface-2: #faf9f6;
    --gg-border: #e6e3dc;
    --gg-text: #16161a;
    --gg-text-muted: #5e5a54;       /* 6:1 על לבן */
    --gg-sidebar-bg: #ffffff;
    --gg-shadow: 0 1px 2px rgba(22, 22, 26, .05), 0 1px 3px rgba(22, 22, 26, .06);
    --gg-shadow-lg: 0 8px 24px rgba(22, 22, 26, .08);
    --gg-code-bg: #f2f0eb;
    --gg-code-text: #25231f;
}

[data-bs-theme="dark"] {
    --gg-primary: #ffc400;          /* הצהוב של 2Break */
    --gg-primary-hover: #ffd54d;
    --gg-primary-soft: rgba(255, 196, 0, .12);
    --gg-primary-rgb: 255, 196, 0;
    --gg-accent: #ff5a64;
    --gg-accent-soft: rgba(255, 90, 100, .12);
    --gg-bg: #0f0f12;
    --gg-surface: #17171c;
    --gg-surface-2: #1d1d23;
    --gg-border: #2b2b33;
    --gg-text: #f4f4f6;
    --gg-text-muted: #a6a6b0;
    --gg-sidebar-bg: #131317;
    --gg-shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --gg-shadow-lg: 0 8px 24px rgba(0, 0, 0, .45);
    --gg-code-bg: #0b0b0e;
    --gg-code-text: #e4e4ea;
}

/* מיפוי לטוקנים של Bootstrap */
:root, [data-bs-theme] {
    --bs-body-font-family: 'Noto Sans Hebrew', 'Segoe UI', Arial, sans-serif;
    --bs-body-bg: var(--gg-bg);
    --bs-body-color: var(--gg-text);
    --bs-secondary-color: var(--gg-text-muted);
    --bs-border-color: var(--gg-border);
    --bs-primary: var(--gg-primary);
    --bs-primary-rgb: var(--gg-primary-rgb);
    --bs-link-color: var(--gg-primary);
    --bs-link-color-rgb: var(--gg-primary-rgb);
    --bs-link-hover-color: var(--gg-primary-hover);
    --bs-border-radius: .5rem;
    --bs-border-radius-lg: .75rem;
    --bs-font-monospace: 'Fira Code', Consolas, monospace;
}

body {
    font-size: .95rem;
    line-height: 1.55;
    background: var(--gg-bg);
    -webkit-font-smoothing: antialiased;
}
.text-muted, .text-body-secondary { color: var(--gg-text-muted) !important; }
h1, .h1, h2, .h2, h3, .h3, h4, .h4 { font-weight: 700; letter-spacing: -.01em; }
.h3 { font-size: 1.45rem; }
.h4 { font-size: 1.2rem; }
code { color: var(--gg-accent); font-size: .85em; }
.table td, .table th { font-variant-numeric: tabular-nums; }

/* נגישות */
.skip-link { position: absolute; inset-inline-start: 1rem; top: -3rem; z-index: 2000; background: var(--gg-primary); color: #fff; padding: .5rem 1rem; border-radius: .5rem; }
.skip-link:focus { top: 1rem; }
:focus-visible { outline: 3px solid rgba(var(--gg-primary-rgb), .45); outline-offset: 2px; }
.btn:focus-visible, .form-control:focus, .form-select:focus, .form-check-input:focus {
    box-shadow: 0 0 0 .2rem rgba(var(--gg-primary-rgb), .25);
    border-color: var(--gg-primary);
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ===== מבנה ===== */
.app-shell { display: flex; min-height: 100dvh; }
.sidebar {
    width: 252px; flex-shrink: 0; flex-direction: column;
    background: var(--gg-sidebar-bg); border-inline-end: 1px solid var(--gg-border);
    position: sticky; top: 0; height: 100dvh; padding: 1.1rem .75rem;
}
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content-wrapper { padding: 1.5rem; max-width: 1480px; width: 100%; margin: 0 auto; }
.content-wrapper:focus { outline: none; }
@media (max-width: 575.98px) { .content-wrapper { padding: 1rem; } }

.brand { display: flex; align-items: center; gap: .65rem; padding: .25rem .5rem 1.25rem; color: var(--gg-text); text-decoration: none; }
.brand-mark {
    width: 38px; height: 38px; border-radius: .65rem; display: grid; place-items: center;
    background: linear-gradient(135deg, #ffc400, #e11d2a); color: #16161a; font-size: 1.05rem;
}
[data-bs-theme="dark"] .brand-mark { color: #16161a; }
.brand-name { display: block; font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.brand-sub { display: block; font-size: .75rem; color: var(--gg-text-muted); }

.side-nav { display: flex; flex-direction: column; gap: 2px; }
.nav-group-label { font-size: .72rem; font-weight: 600; color: var(--gg-text-muted); padding: .9rem .75rem .35rem; letter-spacing: .02em; }
.side-link {
    display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; min-height: 40px;
    border-radius: .55rem; color: var(--gg-text); text-decoration: none; font-weight: 500;
    transition: background .15s ease, color .15s ease;
}
.side-link i { width: 18px; text-align: center; color: var(--gg-text-muted); transition: color .15s ease; }
.side-link:hover { background: var(--gg-surface-2); color: var(--gg-text); }
.side-link.active { background: var(--gg-primary-soft); color: var(--gg-primary); font-weight: 600; box-shadow: inset -3px 0 0 var(--gg-primary); }
.side-link.active i { color: var(--gg-primary); }
.side-link.danger:hover, .side-link.danger:hover i { color: #dc2626; }
.side-footer { margin-top: auto; border-top: 1px solid var(--gg-border); padding-top: .75rem; }
.user-chip { display: flex; align-items: center; gap: .6rem; padding: .4rem .75rem .6rem; font-size: .88rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--gg-accent-soft); color: var(--gg-accent); display: grid; place-items: center; font-weight: 700; flex-shrink: 0; }
.sidebar-offcanvas { background: var(--gg-sidebar-bg); max-width: 290px; }

.topbar {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem;
    padding: .65rem 1.5rem; background: color-mix(in srgb, var(--gg-bg) 85%, transparent);
    backdrop-filter: blur(8px); border-bottom: 1px solid var(--gg-border);
}
.topbar-title { font-weight: 600; color: var(--gg-text-muted); font-size: .92rem; }
.topbar-actions { margin-inline-start: auto; display: flex; align-items: center; gap: .5rem; }
.icon-btn {
    width: 40px; height: 40px; border-radius: .6rem; border: 1px solid var(--gg-border);
    background: var(--gg-surface); color: var(--gg-text); display: grid; place-items: center; cursor: pointer;
    transition: background .15s ease, border-color .15s ease;
}
.icon-btn:hover { background: var(--gg-surface-2); border-color: var(--gg-text-muted); }
.live-pill { display: inline-flex; align-items: center; gap: .4rem; font-size: .78rem; color: var(--gg-text-muted); padding: .3rem .65rem; border: 1px solid var(--gg-border); border-radius: 999px; background: var(--gg-surface); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; }
.live-pill.on .live-dot { background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, .2); }
.live-pill.off .live-dot { background: #ef4444; }

/* ===== כרטיסים ===== */
.card {
    --bs-card-bg: var(--gg-surface); --bs-card-border-color: var(--gg-border); --bs-card-cap-bg: transparent;
    border-radius: .85rem; box-shadow: var(--gg-shadow); margin-bottom: 1.25rem;
}
.card-header { border-bottom: 1px solid var(--gg-border); padding: .85rem 1.1rem; }
.card-header h5, .card-header strong { font-size: 1rem; font-weight: 600; }
.card-footer { border-top: 1px solid var(--gg-border); background: var(--gg-surface-2) !important; }
.card-body { padding: 1.1rem; }

.stats-card {
    background: var(--gg-surface); border: 1px solid var(--gg-border); border-radius: .85rem;
    padding: 1rem 1.1rem; box-shadow: var(--gg-shadow); transition: border-color .15s ease, transform .15s ease;
}
a:hover > .stats-card { border-color: rgba(var(--gg-primary-rgb), .5); transform: translateY(-1px); }
.stats-card h3 { font-size: 1.65rem; font-weight: 700; color: var(--gg-text) !important; }
.stats-card .icon {
    width: 44px; height: 44px; border-radius: .7rem; display: grid; place-items: center;
    font-size: 1.15rem; opacity: 1; background: var(--gg-primary-soft);
}

/* עמוד: כותרת + פעולות */
.page-head { display: flex; flex-wrap: wrap; gap: .75rem 1rem; align-items: flex-end; justify-content: space-between; margin-bottom: 1.25rem; }
.page-head h1 { margin: 0; }
.page-head p { margin: .2rem 0 0; color: var(--gg-text-muted); }

/* ===== טבלאות ===== */
.table { --bs-table-bg: transparent; --bs-table-hover-bg: var(--gg-surface-2); --bs-table-border-color: var(--gg-border); margin-bottom: 0; }
.table > thead th {
    font-size: .78rem; font-weight: 600; color: var(--gg-text-muted); background: var(--gg-surface-2);
    border-bottom: 1px solid var(--gg-border); white-space: nowrap; padding-top: .6rem; padding-bottom: .6rem;
}
.table > tbody td { padding-top: .65rem; padding-bottom: .65rem; }
.table-hover > tbody > tr { cursor: default; }
.table-responsive { border-radius: .85rem; }

/* ===== כפתורים וטפסים ===== */
.btn { font-weight: 500; border-radius: .55rem; min-height: 36px; transition: background .15s ease, border-color .15s ease, color .15s ease; }
.btn-sm { min-height: 32px; }
.btn-primary { --bs-btn-bg: var(--gg-primary); --bs-btn-border-color: var(--gg-primary); --bs-btn-hover-bg: var(--gg-primary-hover); --bs-btn-hover-border-color: var(--gg-primary-hover); --bs-btn-active-bg: var(--gg-primary-hover); --bs-btn-disabled-bg: var(--gg-primary); --bs-btn-disabled-border-color: var(--gg-primary); }
[data-bs-theme="dark"] .btn-primary { --bs-btn-color: #1a1400; --bs-btn-hover-color: #1a1400; --bs-btn-active-color: #1a1400; }
.btn-outline-primary { --bs-btn-color: var(--gg-primary); --bs-btn-border-color: var(--gg-primary); --bs-btn-hover-bg: var(--gg-primary); --bs-btn-hover-border-color: var(--gg-primary); --bs-btn-active-bg: var(--gg-primary); }
[data-bs-theme="dark"] .btn-outline-primary { --bs-btn-hover-color: #1a1400; }
.btn-light { --bs-btn-bg: var(--gg-surface); --bs-btn-border-color: var(--gg-border); --bs-btn-color: var(--gg-text); --bs-btn-hover-bg: var(--gg-surface-2); --bs-btn-hover-border-color: var(--gg-border); --bs-btn-hover-color: var(--gg-text); }
.btn:disabled, .btn.disabled { opacity: .45; cursor: not-allowed; }
.btn[aria-busy="true"] { pointer-events: none; opacity: .7; }
.form-control, .form-select { border-color: var(--gg-border); background-color: var(--gg-surface); border-radius: .55rem; min-height: 40px; }
.form-control-sm, .form-select-sm { min-height: 34px; }
.form-label { font-weight: 500; color: var(--gg-text); margin-bottom: .3rem; }
.form-check-input:checked { background-color: var(--gg-primary); border-color: var(--gg-primary); }
.form-switch .form-check-input { width: 2.4em; cursor: pointer; }
.input-group-text { background: var(--gg-surface-2); border-color: var(--gg-border); }

/* פילטרים */
.filter-bar { background: var(--gg-surface); border: 1px solid var(--gg-border); border-radius: .85rem; padding: .85rem; margin-bottom: 1.25rem; box-shadow: var(--gg-shadow); }

/* ===== תגיות סטטוס (צבע + אייקון, לא צבע בלבד) ===== */
.badge { font-weight: 600; padding: .38em .65em; border-radius: 999px; font-size: .74rem; }
.status { display: inline-flex; align-items: center; gap: .35rem; font-size: .76rem; font-weight: 600; padding: .25rem .6rem; border-radius: 999px; white-space: nowrap; border: 1px solid transparent; }
.status i { font-size: .7rem; }
.status-success { background: #e7f5ef; color: #065f46; border-color: #bfe5d3; }
.status-warning { background: #fdf6e3; color: #854d0e; border-color: #f2dfae; }
.status-danger { background: #fdecec; color: #991b1b; border-color: #f6c9c9; }
.status-info { background: #e8f3fb; color: #075985; border-color: #c4e0f3; }
.status-neutral { background: var(--gg-surface-2); color: var(--gg-text-muted); border-color: var(--gg-border); }
[data-bs-theme="dark"] .status-success { background: rgba(52, 211, 153, .12); color: #6ee7b7; border-color: rgba(52, 211, 153, .25); }
[data-bs-theme="dark"] .status-warning { background: rgba(251, 191, 36, .12); color: #fcd34d; border-color: rgba(251, 191, 36, .25); }
[data-bs-theme="dark"] .status-danger { background: rgba(248, 113, 113, .12); color: #fca5a5; border-color: rgba(248, 113, 113, .25); }
[data-bs-theme="dark"] .status-info { background: rgba(56, 189, 248, .12); color: #7dd3fc; border-color: rgba(56, 189, 248, .25); }

.chip { display: inline-flex; align-items: center; gap: .3rem; background: var(--gg-surface-2); border: 1px solid var(--gg-border); border-radius: 999px; padding: .15rem .35rem .15rem .65rem; margin: 0 0 .35rem .35rem; font-size: .82rem; }
.chip.off { opacity: .5; text-decoration: line-through; }

/* ===== תוכן ===== */
.msg-body { white-space: pre-wrap; word-break: break-word; font-size: .92rem; line-height: 1.6; }
pre.json {
    background: var(--gg-code-bg); color: var(--gg-code-text); border: 1px solid var(--gg-border);
    padding: .85rem 1rem; border-radius: .65rem; max-height: 460px; overflow: auto;
    direction: ltr; text-align: left; font-family: var(--bs-font-monospace); font-size: .78rem;
    white-space: pre-wrap; word-break: break-all; margin: 0;
}
.thumb { width: 64px; height: 64px; border-radius: .55rem; object-fit: cover; border: 1px solid var(--gg-border); background: var(--gg-surface-2); }
.poster { max-height: 440px; width: 100%; object-fit: contain; border-radius: .65rem; background: var(--gg-surface-2); }
.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--gg-text-muted); }
.empty-state i { font-size: 2rem; opacity: .4; display: block; margin-bottom: .6rem; }
.kv th { color: var(--gg-text-muted); font-weight: 500; width: 140px; white-space: nowrap; }

/* קישורי טאב */
.nav-tabs { --bs-nav-tabs-border-color: var(--gg-border); --bs-nav-tabs-link-active-bg: var(--gg-surface); --bs-nav-tabs-link-active-border-color: var(--gg-border) var(--gg-border) var(--gg-surface); --bs-nav-link-color: var(--gg-text-muted); --bs-nav-link-hover-color: var(--gg-text); }
.nav-tabs .nav-link.active { color: var(--gg-primary); font-weight: 600; }
.pagination { --bs-pagination-active-bg: var(--gg-primary); --bs-pagination-active-border-color: var(--gg-primary); --bs-pagination-color: var(--gg-text); --bs-pagination-bg: var(--gg-surface); --bs-pagination-border-color: var(--gg-border); }

/* כרטיסי בחירה (ספק AI) */
.choice-card { display: block; border: 1px solid var(--gg-border); border-radius: .75rem; padding: .85rem 1rem; cursor: pointer; transition: border-color .15s ease, background .15s ease; height: 100%; }
.choice-card:hover { border-color: var(--gg-text-muted); }
.choice-card:has(input:checked) { border-color: var(--gg-primary); background: var(--gg-primary-soft); box-shadow: 0 0 0 1px var(--gg-primary); }
.choice-card input { margin-inline-end: .4rem; }

/* מסך התחברות */
.login-page { min-height: 100dvh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(1200px 600px at 80% -10%, var(--gg-primary-soft), transparent), var(--gg-bg); }
.login-card { width: 100%; max-width: 400px; background: var(--gg-surface); border: 1px solid var(--gg-border); border-radius: 1rem; padding: 2rem; box-shadow: var(--gg-shadow-lg); }

.alert { border-radius: .7rem; }
.footer-note { text-align: center; color: var(--gg-text-muted); font-size: .78rem; padding: 1rem 0 1.5rem; }

/* קישורים בטבלאות ורשימות - בלי קו תחתון, רק במעבר עכבר */
.table a, .list-group a, .card-header a, .page-head a { text-decoration: none; }
.table a:hover, .list-group a:hover, .card-header a:hover, .page-head a:hover { text-decoration: underline; }

/* ===== מובייל ===== */
/* טבלה רחבה גוללת בתוך הכרטיס - לא מזיזה את כל הדף הצידה */
.card-body:has(> .table), .card-body:has(> table), .card > .table-responsive, .card-body.p-0 { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.app-main { max-width: 100vw; }
img { max-width: 100%; }

@media (max-width: 767.98px) {
    body { font-size: .92rem; }
    .content-wrapper { padding: 1rem .8rem; }
    .topbar { padding: .5rem .8rem; gap: .5rem; }
    .topbar-title { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .live-pill .live-text { display: none; }
    .live-pill { padding: .45rem; }
    h1.h3, .h3 { font-size: 1.25rem; }
    h1.h4, .h4 { font-size: 1.1rem; }
    .page-head { margin-bottom: 1rem; }
    .page-head > div:last-child { width: 100%; }
    .page-head .d-flex, .page-head > div:last-child { flex-wrap: wrap; gap: .4rem !important; }
    .page-head .btn, .page-head form { flex: 1 1 auto; }
    .page-head form .btn { width: 100%; }
    .stats-card { padding: .75rem .8rem; }
    .stats-card h3 { font-size: 1.3rem; }
    .stats-card .icon { width: 36px; height: 36px; font-size: .95rem; }
    .stats-card .small { font-size: .75rem; }
    .card-body { padding: .85rem; }
    .card-header { padding: .7rem .85rem; }
    .table { font-size: .84rem; }
    .table > :not(caption) > * > * { padding: .5rem .45rem; }
    .hide-sm { display: none !important; }
    .filter-bar { padding: .65rem; }
    .filter-bar .btn { width: 100%; }
    .nav-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
    .nav-tabs .nav-link { white-space: nowrap; padding: .45rem .65rem; }
    .modal-dialog { margin: .5rem; }
    .msg-body { font-size: .88rem; }
    .poster { max-height: 320px; }
    .thumb { width: 48px; height: 48px; }
    .kv th { width: 96px; white-space: normal; }
    .btn, .form-control, .form-select { min-height: 42px; }   /* יעד מגע נוח */
    .btn-sm { min-height: 36px; }
    .card-footer { flex-direction: column; align-items: stretch !important; }
    .card-footer .btn { width: 100%; }
    pre.json { max-height: 300px; font-size: .72rem; }
}

/* ===== 2Break: שיחות ===== */
.chat-list .list-group-item { border-color: var(--gg-border); background: var(--gg-surface); padding: .7rem .9rem; }
.chat-list .list-group-item.active { background: var(--gg-primary-soft); color: var(--gg-text); border-color: var(--gg-border); box-shadow: inset -3px 0 0 var(--gg-primary); }
.chat-list .preview { color: var(--gg-text-muted); font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-window { background: var(--gg-surface-2); border-radius: .85rem; padding: 1rem; height: min(62dvh, 640px); overflow-y: auto; display: flex; flex-direction: column; gap: .45rem; }
.bubble { max-width: min(78%, 560px); padding: .5rem .75rem .35rem; border-radius: .9rem; word-break: break-word; font-size: .92rem; line-height: 1.55; box-shadow: var(--gg-shadow); }
.bubble .txt { white-space: pre-wrap; }
.bubble .meta { display: flex; gap: .5rem; justify-content: flex-end; font-size: .7rem; color: var(--gg-text-muted); margin-top: .2rem; }
.bubble.in { align-self: flex-start; background: var(--gg-surface); border: 1px solid var(--gg-border); border-start-start-radius: .25rem; }
.bubble.out { align-self: flex-end; background: var(--gg-primary-soft); border: 1px solid rgba(var(--gg-primary-rgb), .3); border-start-end-radius: .25rem; }
.bubble.out.human { background: rgba(56, 189, 248, .12); border-color: rgba(56, 189, 248, .35); }
.bubble.out.crm { background: var(--gg-surface); border-style: dashed; }
.src { font-size: .66rem; font-weight: 700; padding: .05rem .4rem; border-radius: 999px; background: var(--gg-surface-2); border: 1px solid var(--gg-border); }
.day-sep { align-self: center; font-size: .72rem; color: var(--gg-text-muted); background: var(--gg-surface); border: 1px solid var(--gg-border); border-radius: 999px; padding: .1rem .7rem; margin: .4rem 0; }
.meter { height: 8px; border-radius: 999px; background: var(--gg-surface-2); border: 1px solid var(--gg-border); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--gg-primary); }
.meter.warn > span { background: #f59e0b; }
.meter.danger > span { background: #ef4444; }
.funnel-step { text-align: center; }
.funnel-step .n { font-size: 1.5rem; font-weight: 700; }
.var-hint code { direction: ltr; unicode-bidi: embed; }
textarea.form-control { min-height: 90px; }
.sim-window { height: min(56dvh, 560px); }

@media (max-width: 767.98px) {
    .chat-window { height: 58dvh; padding: .65rem; }
    .bubble { max-width: 90%; font-size: .9rem; }
    .hide-sm { display: none !important; }
}
