/* ── Rabط app shell: purple sidebar + white top bar ───────────────────── */

:root {
    --app-sidebar-width: 192px;
    --app-header-height: 48px;
}

.app-no-scroll { overflow: hidden; }

html.app-shell {
    overflow-y: scroll;
    scrollbar-gutter: stable;
    overflow-x: hidden;
}

html.app-shell.app-no-scroll {
    overflow: hidden;
}

html.app-shell body {
    padding-top: var(--app-header-height);
    padding-left: var(--app-sidebar-width);
}

html.app-shell.guest-mode body {
    padding-left: 0;
}

html.guest-mode .app-header-mark-link,
html.marketing-root .app-header-mark-link {
    display: flex;
}

#app-navbar {
    display: contents;
}

.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--app-sidebar-width);
    height: 100vh;
    height: 100dvh;
    background: var(--sidebar, #5B4FFF);
    border-right: none;
    z-index: 201;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.app-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 10px 8px;
    flex-shrink: 0;
}

.app-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    background: #ffffff;
    border-radius: 0;
    padding: 3px;
    text-decoration: none;
    overflow: hidden;
    line-height: 0;
    box-shadow: none;
}

.app-logo-img {
    width: 22px;
    height: 22px;
    object-fit: contain;
    display: block;
}

.app-sidebar-brand-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.app-logo-text {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: #ffffff;
    white-space: nowrap;
}

.app-sidebar-tagline {
    font-size: 10px;
    font-weight: 500;
    color: var(--sidebar-muted, rgba(255, 255, 255, 0.55));
    margin-top: 1px;
}

.app-sidebar-close {
    display: none;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    border-radius: 0;
    flex-shrink: 0;
}

.app-sidebar-close:hover {
    background: var(--sidebar-hover, rgba(255, 255, 255, 0.12));
}

.app-sidebar-nav {
    display: flex;
    flex-direction: column;
    padding: 2px 8px 8px;
    gap: 1px;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none;
}

.app-sidebar-nav::-webkit-scrollbar { width: 0; height: 0; }

.app-sidebar-label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--sidebar-muted, rgba(255, 255, 255, 0.55));
    padding: 10px 8px 4px;
    margin: 0;
}

.app-sidebar-link[hidden] {
    display: none !important;
}

.app-sidebar-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 0;
    font-size: 12px;
    font-weight: 600;
    color: var(--sidebar-text, rgba(255, 255, 255, 0.82));
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.app-sidebar-link:hover {
    background: var(--sidebar-hover, rgba(255, 255, 255, 0.12));
    color: #ffffff;
}

.app-sidebar-link.active {
    background: var(--sidebar-active-bg, #ffffff);
    color: var(--sidebar-active-text, #5B4FFF);
    font-weight: 700;
    box-shadow: none;
}

.app-nav-badge {
    margin-left: auto;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 0;
    background: #ffffff;
    color: #5B4FFF;
    font-size: 10px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.app-nav-badge[hidden] {
    visibility: hidden;
    display: inline-flex !important;
}

.app-sidebar-link.has-hint {
    align-items: flex-start;
    padding-top: 6px;
    padding-bottom: 6px;
}

.app-sidebar-link-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 2px;
}

.app-sidebar-hint {
    font-size: 10px;
    font-weight: 500;
    line-height: 1.3;
    opacity: 0.72;
}

.app-sidebar-link.active .app-sidebar-hint {
    opacity: 0.7;
}

.app-sidebar-link.active .app-nav-badge {
    background: #5B4FFF;
    color: #ffffff;
}

.app-sidebar-icon {
    width: 22px;
    height: 22px;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: transparent;
    font-size: 12px;
    color: inherit;
}

.app-sidebar-link.active .app-sidebar-icon {
    background: transparent;
    color: inherit;
}

.app-sidebar-footer {
    padding: 8px 10px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    flex-shrink: 0;
}

.app-sidebar-guest-hint {
    font-size: 12px;
    line-height: 1.45;
    color: var(--sidebar-muted, rgba(255, 255, 255, 0.55));
    margin: 0;
}

.app-sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.app-sidebar-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 0;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
    overflow: hidden;
}
.app-sidebar-user-avatar.has-photo {
    padding: 0;
    background: rgba(255, 255, 255, 0.12);
}
.app-sidebar-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.app-sidebar-user-meta { min-width: 0; }

.app-sidebar-user-name {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-sidebar-user-email {
    display: block;
    font-size: 11px;
    color: var(--sidebar-muted, rgba(255, 255, 255, 0.55));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    height: var(--app-header-height);
    background: #ffffff;
    border-bottom: 1px solid var(--border-color, #E6EAF2);
    position: fixed;
    top: 0;
    left: var(--app-sidebar-width);
    right: 0;
    z-index: 100;
    gap: 12px;
    flex-wrap: nowrap;
}

html[data-theme="dark"] .app-header {
    background: var(--bg-card, #1A1D28);
    border-bottom-color: var(--border-color, #2A3040);
}

html.guest-mode .app-header {
    background: #ffffff;
    left: 0;
}

.app-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
}

.app-header-center {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

.app-header-nav {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-header-nav .app-sidebar-link {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.app-header-nav .app-sidebar-link:hover {
    background: var(--bg-tertiary);
    color: var(--accent);
}

.app-header-nav .app-sidebar-link.active {
    background: var(--accent);
    color: white;
}

.app-header-nav .app-sidebar-icon {
    margin-right: 6px;
    font-size: 14px;
}

.app-header-title {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary, #1E2540);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.app-header-mark-link {
    display: none;
    flex-shrink: 0;
    line-height: 0;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

.app-header-mark-link:hover {
    opacity: 0.85;
}

.app-header-mark {
    height: 28px;
    width: 28px;
    object-fit: contain;
    background: #ffffff;
    border-radius: 0;
    padding: 2px;
}

.app-nav-status {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    min-height: 24px;
}

html.app-page-whatsapp .app-nav-status,
html.app-page-telegram .app-nav-status {
    min-width: 124px;
}

.nav-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 0;
    font-size: 11px;
    font-weight: 600;
}

.nav-status-connected {
    background: rgba(34, 197, 94, 0.14);
    color: #16a34a;
}

.nav-status-disconnected {
    background: rgba(239, 68, 68, 0.12);
    color: #EF4444;
}

.app-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-inline-start: auto;
}

.app-auth-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-auth-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    border-radius: 0;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
}

.app-auth-btn-ghost {
    background: #ffffff;
    border-color: var(--border-color, #E6EAF2);
    color: var(--text-primary, #1E2540);
}

html[data-theme="dark"] .app-auth-btn-ghost {
    background: transparent;
    border-color: var(--border-color);
    color: var(--text-primary);
}

.app-auth-btn-primary {
    background: var(--accent, #5B4FFF);
    color: #ffffff;
}

.app-theme-toggle,
.app-hamburger,
.app-back-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #C5CAD6;
    border-radius: 0;
    background: #EEF0F6;
    color: #1E2540;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    flex-shrink: 0;
    -webkit-appearance: none;
    appearance: none;
    overflow: visible;
}

.app-back-btn {
    width: 32px;
    height: 32px;
    border-radius: 0;
    font-size: 13px;
    position: relative;
    z-index: 2;
    pointer-events: auto;
    flex-shrink: 0;
}

.app-back-btn:active {
    transform: scale(0.96);
}

html[data-theme="dark"] .app-theme-toggle,
html[data-theme="dark"] .app-hamburger,
html[data-theme="dark"] .app-back-btn {
    background: #2A3040;
    border-color: #4A5270;
    color: #EEF1FB;
}

.app-theme-toggle:hover,
.app-hamburger:hover,
.app-back-btn:hover {
    background: var(--accent-subtle, rgba(91, 79, 255, 0.1));
    border-color: var(--accent, #5B4FFF);
    color: var(--accent, #5B4FFF);
}

.app-hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    padding: 0;
}

.app-hamburger span {
    display: block;
    width: 18px;
    height: 2px;
    background: #1E2540;
    border-radius: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
    flex-shrink: 0;
}

html[data-theme="dark"] .app-hamburger span {
    background: #EEF1FB;
}

.app-hamburger.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.app-hamburger.open span:nth-child(2) { opacity: 0; }
.app-hamburger.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.app-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30, 37, 64, 0.4);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.app-drawer-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

@media (max-width: 900px) {
    html.app-shell body,
    html[dir="rtl"].app-shell body {
        padding-left: 0;
        padding-right: 0;
    }

    .app-sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: 8px 0 24px rgba(30, 37, 64, 0.18);
    }

    .app-sidebar.open { transform: translateX(0); }
    .app-sidebar-close { display: flex; }
    .app-hamburger { display: flex; }
    .app-header-mark-link { display: flex; }
    .app-hamburger,
    .app-theme-toggle,
    .app-back-btn {
        width: 40px;
        height: 40px;
        background: #EEF0F6 !important;
        border: 1px solid #B8BECB !important;
        color: #1E2540 !important;
    }
    .app-hamburger span {
        background: #1E2540 !important;
    }
    html[data-theme="dark"] .app-hamburger,
    html[data-theme="dark"] .app-theme-toggle,
    html[data-theme="dark"] .app-back-btn {
        background: #2A3040 !important;
        border-color: #4A5270 !important;
        color: #EEF1FB !important;
    }
    html[data-theme="dark"] .app-hamburger span {
        background: #EEF1FB !important;
    }
    .app-header,
    html.guest-mode .app-header,
    html[dir="rtl"].app-shell .app-header {
        left: 0;
        right: 0;
        padding: 0 12px;
        flex-wrap: nowrap;
    }
    .app-header-left { gap: 8px; overflow: visible; }
    .app-header-actions,
    html[dir="rtl"] .app-header-actions {
        margin-left: 0;
        margin-right: 0;
        margin-inline-start: auto;
    }
    .app-auth-btn span { display: none; }
    .app-auth-btn { padding: 7px 9px; }
}

@media (max-width: 560px) {
    .app-nav-status { display: none; }
    .app-header-title { font-size: 14px; }
}

html[dir="rtl"].app-shell body {
    padding-left: 0;
    padding-right: var(--app-sidebar-width);
}
html[dir="rtl"].app-shell.guest-mode body {
    padding-right: 0;
}
html[dir="rtl"].app-shell:not(.guest-mode) .app-header {
    left: 0;
    right: var(--app-sidebar-width);
}
html[dir="rtl"] .app-sidebar {
    left: auto;
    right: 0;
}
html[dir="rtl"] .app-nav-badge { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .fa-arrow-left { transform: scaleX(-1); }
html[dir="rtl"] .legal-page ul,
html[dir="rtl"] .legal-page ol { margin: 0 20px 14px 0; }
@media (max-width: 900px) {
    html[dir="rtl"].app-shell body { padding-right: 0; }
    html[dir="rtl"].app-shell:not(.guest-mode) .app-header {
        left: 0;
        right: 0;
    }
    html[dir="rtl"] .app-sidebar { transform: translateX(100%); }
    html[dir="rtl"] .app-sidebar.open { transform: translateX(0); }
}


/* PLATFORM SHARP CORNERS */
html body,
html body *,
html body *::before,
html body *::after {
    border-radius: 0 !important;
}
