/**
 * MainOffice CRM — Mobile layout (≤1439px)
 * כלל בטיחות: אין כללים כאן שחלים על שולחן (1440px+).
 * שינויי שולחן — רק בקבצים הקיימים, מחוץ לקובץ זה.
 */
:root {
    --crm-mobile-breakpoint: 1440px;
    --crm-mobile-nav-height: 56px;
}

/* ── שולחן עם עכבר — תמיד הסתר מובייל (גם ב-scaling של Windows) ── */
@media (min-width: 768px) and (pointer: fine) {
    .crm-mobile-only {
        display: none !important;
    }
}

/* ── מובייל: מגע, או מסך צר מאוד ── */
@media ((max-width: 1439px) and (pointer: coarse)), (max-width: 767px) {
    .crm-desktop-only {
        display: none !important;
    }

    #sidebar-logo-fixed,
    #sidebar-shell {
        display: none !important;
    }

    #main-layout header {
        margin-right: 0 !important;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    #main-content {
        margin-right: 0 !important;
        padding-bottom: calc(var(--crm-mobile-nav-height) + env(safe-area-inset-bottom, 0px) + 0.5rem) !important;
    }

    body.sidebar-pinned #main-content {
        margin-right: 0 !important;
    }

    /* כותרת מובייל — לוגו + משתמש */
    #main-layout header .crm-mobile-header-brand {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        flex-shrink: 0;
    }

    #main-layout header .crm-mobile-header-brand img {
        height: 28px;
        width: auto;
    }

    #main-layout header .crm-header-agent-filter,
    #main-layout header form[action="/dashboard"],
    #main-layout header form[action*="dashboard"] {
        display: none !important;
    }

    #main-layout header {
        justify-content: space-between;
    }

    /* הודעת «עבור למחשב» */
    .crm-desktop-only-notice {
        display: flex;
        align-items: flex-start;
        gap: 0.75rem;
        margin: 0 0 0.75rem 0;
        padding: 0.875rem 1rem;
        background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
        border: 1px solid #f59e0b;
        border-radius: 0.75rem;
        color: #78350f;
        font-size: 0.875rem;
        line-height: 1.5;
        font-weight: 600;
    }

    .crm-desktop-only-notice[hidden] {
        display: none !important;
    }

    .crm-desktop-only-notice__icon {
        flex-shrink: 0;
        font-size: 1.25rem;
        margin-top: 0.1rem;
    }

    .crm-desktop-only-notice__title {
        font-weight: 800;
        margin-bottom: 0.25rem;
    }

    /* תפריט תחתון */
    .crm-mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 60;
        height: calc(var(--crm-mobile-nav-height) + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: rgba(26, 26, 26, 0.97);
        backdrop-filter: blur(12px);
        border-top: 1px solid #333;
        display: flex;
        align-items: stretch;
        justify-content: space-around;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.25);
    }

    .crm-mobile-bottom-nav a,
    .crm-mobile-bottom-nav button {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.15rem;
        padding: 0.35rem 0.25rem;
        color: #94a3b8;
        font-size: 0.75rem;
        font-weight: 700;
        text-decoration: none;
        border: none;
        background: transparent;
        cursor: pointer;
        min-width: 0;
        transition: color 0.15s, background 0.15s;
    }

    .crm-mobile-bottom-nav a:hover,
    .crm-mobile-bottom-nav button:hover,
    .crm-mobile-bottom-nav a.is-active,
    .crm-mobile-bottom-nav button.is-active {
        color: #fff;
        background: rgba(255, 255, 255, 0.06);
    }

    .crm-mobile-bottom-nav i {
        font-size: 1.25rem;
    }

    .crm-mobile-bottom-nav .nav-badge {
        position: absolute;
        top: 2px;
        margin-right: 1.25rem;
        min-width: 17px;
        height: 17px;
        padding: 0 4px;
        background: #ef4444;
        color: #fff;
        font-size: 10px;
        font-weight: 900;
        border-radius: 999px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .crm-mobile-bottom-nav .nav-item-wrap {
        position: relative;
        flex: 1;
        display: flex;
        min-width: 0;
    }

    .crm-mobile-bottom-nav__agent-group,
    .crm-mobile-bottom-nav__manager-group {
        display: flex;
        align-items: stretch;
        min-width: 0;
    }

    .crm-mobile-bottom-nav__agent-group {
        flex: 4 1 0;
    }

    .crm-mobile-bottom-nav__manager-group {
        flex: 1 1 0;
    }

    .crm-mobile-bottom-nav__more {
        flex: 1 1 0;
    }

    .crm-mobile-bottom-nav__divider {
        width: 1px;
        align-self: stretch;
        margin: 0.4rem 0.1rem;
        background: rgba(255, 255, 255, 0.22);
        flex-shrink: 0;
    }

    /* כיתוב מנהל בלבד — צהוב */
    .crm-nav-label-manager {
        color: #facc15 !important;
    }

    .crm-mobile-bottom-nav a.is-active .crm-nav-label-manager,
    .crm-mobile-bottom-nav a:hover .crm-nav-label-manager {
        color: #fde047 !important;
    }

    .crm-mobile-more-sheet__grid a .crm-nav-label-manager {
        color: #facc15 !important;
    }

    /* גיליון «עוד» */
    .crm-mobile-more-sheet {
        position: fixed;
        inset: 0;
        z-index: 70;
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.2s;
    }

    .crm-mobile-more-sheet.is-open {
        pointer-events: auto;
        opacity: 1;
    }

    .crm-mobile-more-sheet__backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.45);
    }

    .crm-mobile-more-sheet__panel {
        position: absolute;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 70vh;
        background: #1a1a1a;
        border-top-left-radius: 1rem;
        border-top-right-radius: 1rem;
        padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom, 0px));
        overflow-y: auto;
        transform: translateY(100%);
        transition: transform 0.25s ease-out;
    }

    .crm-mobile-more-sheet.is-open .crm-mobile-more-sheet__panel {
        transform: translateY(0);
    }

    .crm-mobile-more-sheet__title {
        color: #fff;
        font-weight: 800;
        font-size: 1.05rem;
        margin-bottom: 0.75rem;
        text-align: center;
    }

    .crm-mobile-more-sheet__grid {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 0.5rem;
    }

    .crm-mobile-more-sheet__grid a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.35rem;
        padding: 0.75rem 0.5rem;
        background: #262626;
        border-radius: 0.75rem;
        color: #e2e8f0;
        font-size: 0.78rem;
        font-weight: 700;
        text-decoration: none;
        text-align: center;
    }

    .crm-mobile-more-sheet__grid a i {
        font-size: 1.1rem;
        color: #93c5fd;
    }

    /* רכיבים משותפים — נכסים / לקוחות / מנהל */
    .crm-mob-stage-chip {
        flex-shrink: 0;
        padding: 0.45rem 0.85rem;
        border-radius: 999px;
        font-size: 0.8rem;
        font-weight: 800;
        background: #f1f5f9;
        color: #64748b;
        border: 1px solid #e2e8f0;
        white-space: nowrap;
    }

    .crm-mob-stage-chip.is-active {
        background: #800020;
        color: #fff;
        border-color: #800020;
    }

    .crm-mob-quick-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.25rem;
        padding: 0.7rem 0.3rem;
        border-radius: 0.75rem;
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        font-size: 0.78rem;
        font-weight: 800;
        color: #334155;
    }

    .crm-mob-quick-btn i { font-size: 1.25rem; }
    .crm-mob-quick-btn[data-action="whatsapp"] i { color: #16a34a; }
    .crm-mob-quick-btn[data-action="call"] i { color: #2563eb; }

    .crm-mob-detail-row {
        display: flex;
        justify-content: space-between;
        gap: 0.5rem;
        padding: 0.4rem 0;
        border-bottom: 1px solid #f1f5f9;
        font-size: 0.9rem;
    }

    .crm-mob-detail-row span:first-child {
        color: #94a3b8;
        font-weight: 700;
        flex-shrink: 0;
    }

    .crm-mob-detail-row span:last-child {
        font-weight: 800;
        color: #1e293b;
        text-align: left;
        word-break: break-word;
    }

    .crm-mob-sheet-edit-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.1rem;
        min-width: 2.25rem;
        padding: 0.15rem 0.35rem;
        border: none;
        background: transparent;
        color: #0f4c81;
        font-size: 0.55rem;
        font-weight: 900;
        cursor: pointer;
    }

    .crm-mob-sheet-edit-btn i {
        font-size: 0.85rem;
    }

    .crm-mob-sheet-edit-btn.is-hidden {
        visibility: hidden;
        pointer-events: none;
    }

    .crm-mob-detail-row--edit {
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
    }

    .crm-mob-detail-row--edit label {
        color: #64748b;
        font-size: 0.65rem;
        font-weight: 800;
    }

    .crm-mob-field-input,
    .crm-mob-field-select {
        width: 100%;
        padding: 0.45rem 0.6rem;
        border: 1px solid #e2e8f0;
        border-radius: 0.5rem;
        font-size: 0.8rem;
        font-weight: 700;
        color: #1e293b;
        background: #fff;
        outline: none;
    }

    .crm-mob-field-input:focus,
    .crm-mob-field-select:focus {
        border-color: #0f4c81;
        box-shadow: 0 0 0 2px rgba(15, 76, 129, 0.12);
    }

    .crm-mob-edit-actions {
        display: flex;
        gap: 0.5rem;
        margin-top: 0.75rem;
        margin-bottom: 0.25rem;
    }

    .crm-mob-edit-save,
    .crm-mob-edit-cancel {
        flex: 1;
        padding: 0.55rem 0.75rem;
        border-radius: 0.65rem;
        font-size: 0.8rem;
        font-weight: 900;
        border: none;
        cursor: pointer;
    }

    .crm-mob-edit-save {
        background: #0f4c81;
        color: #fff;
    }

    .crm-mob-edit-cancel {
        background: #f1f5f9;
        color: #475569;
    }

    .leads-summary-desktop-cta {
        display: none !important;
    }
}

/* באנר קבוע — הגדרת טביעת אצבע (מובייל בלבד — .crm-mobile-only) */
.crm-passkey-top-banner {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
    border: 2px solid #34d399;
    border-radius: 12px;
    color: #065f46;
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    line-height: 1.35;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.15);
}

.crm-passkey-top-banner i.fa-fingerprint {
    font-size: 1.1rem;
    color: #059669;
    flex-shrink: 0;
}

.crm-passkey-top-banner span {
    flex: 1;
    text-align: right;
}

.crm-passkey-top-banner:active {
    transform: scale(0.99);
}
