* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: Arial, sans-serif;
    background: #f5f5f5;
    color: #222;
    direction: rtl;
}

header {
    background: #1a1a2e;
    color: #fff;
    padding: 16px 24px;
}

header h1 {
    font-size: 1.3rem;
    font-weight: 600;
}

main {
    max-width: 1100px;
    margin: 24px auto;
    padding: 0 16px;
}

.date-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.date-bar span {
    font-weight: 600;
    color: #555;
}

.date-btn {
    padding: 6px 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    font-size: 0.9rem;
}

.date-btn.active {
    background: #1a1a2e;
    color: #fff;
    border-color: #1a1a2e;
}

.date-btn:hover:not(.active) {
    background: #eee;
}

#refresh-btn {
    margin-right: auto;
    padding: 6px 14px;
    background: #2d6a4f;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

#refresh-btn:hover {
    background: #1b4332;
}

.kpi-row {
    display: flex;
    gap: 16px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.kpi-card {
    flex: 1;
    min-width: 140px;
    background: #fff;
    border-radius: 8px;
    padding: 20px 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    text-align: center;
}

.kpi-label {
    font-size: 0.85rem;
    color: #777;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: #1a1a2e;
}

.error-msg {
    background: #fff0f0;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 10px 14px;
    border-radius: 4px;
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.campaigns-section h2 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: #333;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

thead th {
    background: #1a1a2e;
    color: #fff;
    padding: 12px 16px;
    text-align: right;
    font-size: 0.9rem;
    font-weight: 600;
}

tbody td {
    padding: 11px 16px;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr:hover {
    background: #f9f9f9;
}

.badge-active {
    background: #d4edda;
    color: #155724;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-paused {
    background: #e2e3e5;
    color: #383d41;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
}

.btn-pause {
    padding: 4px 12px;
    background: #e74c3c;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
}

.btn-pause:hover {
    background: #c0392b;
}

.btn-activate {
    padding: 4px 12px;
    background: #27ae60;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
}

.btn-activate:hover {
    background: #1e8449;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-box {
    background: #fff;
    border-radius: 8px;
    padding: 28px 32px;
    max-width: 400px;
    width: 90%;
    text-align: center;
    direction: rtl;
}

.modal-box p {
    font-size: 1rem;
    margin-bottom: 20px;
    color: #222;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.modal-actions button {
    padding: 8px 24px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
}

#modal-confirm-btn {
    background: #c0392b;
    color: #fff;
}

#modal-confirm-btn:hover {
    background: #a93226;
}

#modal-cancel-btn {
    background: #e2e3e5;
    color: #333;
}

#modal-cancel-btn:hover {
    background: #ccc;
}

.chat-section {
    margin-top: 32px;
}

.chat-log {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    padding: 12px;
    height: 240px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.chat-message {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-user {
    background: #0d6efd;
    color: #fff;
    align-self: flex-start;
    border-bottom-right-radius: 2px;
}

.chat-bot {
    background: #e9ecef;
    color: #212529;
    align-self: flex-end;
    border-bottom-left-radius: 2px;
}

.chat-input-row {
    display: flex;
    gap: 8px;
}

.chat-input-row input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.95rem;
    direction: rtl;
}

.chat-input-row input:focus {
    outline: none;
    border-color: #0d6efd;
}

#chat-send-btn {
    padding: 8px 20px;
    background: #0d6efd;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
}

#chat-send-btn:hover {
    background: #0b5ed7;
}

.goals-section {
    margin-bottom: 28px;
}

.goals-section h2 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: #333;
}

.goals-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.goal-card {
    flex: 1;
    min-width: 160px;
    background: #fff;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    text-align: center;
    border-top: 3px solid #0d6efd;
}

.goal-label {
    font-size: 0.85rem;
    color: #777;
    margin-bottom: 6px;
}

.goal-value {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1a1a2e;
    margin-bottom: 4px;
}

.goal-sub {
    font-size: 0.8rem;
    color: #555;
}

.goal-ok {
    color: #155724;
    font-weight: 600;
}

.goal-warn {
    color: #721c24;
    font-weight: 600;
}

.chat-upload-btn {
    padding: 8px 16px;
    background: #0d6efd;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    align-self: flex-end;
    margin-top: 4px;
}

.chat-upload-btn:hover {
    background: #0b5ed7;
}


/* =============================================================
   WEB-3.2 — App Shell Layout
   All rules below are additive. Nothing above was changed.
   ============================================================= */

/* Full-height shell */
html, body {
    height: 100%;
    overflow: hidden;
}

/* Top bar */
#top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 48px;
    background: #111827;
    color: #f9fafb;
    display: flex;
    align-items: center;
    padding: 0 16px;
    z-index: 50;
    gap: 12px;
    /* Force left-to-right order regardless of document direction */
    direction: ltr;
}

/* Brand area: product name + toggle chevron grouped together */
#brand-area {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
}

#product-name {
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #f9fafb;
}

#sidebar-toggle {
    background: transparent;
    border: none;
    color: #9ca3af;
    /* ‹ character — slightly larger so it reads clearly */
    font-size: 1.1rem;
    line-height: 1;
    padding: 2px 4px;
    border-radius: 3px;
    cursor: pointer;
    flex-shrink: 0;
    transition: color 0.15s, background 0.15s;
}

#sidebar-toggle:hover {
    color: #f9fafb;
    background: rgba(255,255,255,0.08);
}

#three-dot-menu {
    background: transparent;
    border: none;
    color: #9ca3af;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    letter-spacing: 0.1em;
    flex-shrink: 0;
}

#three-dot-menu:hover {
    color: #f9fafb;
    background: rgba(255,255,255,0.08);
}

/* App shell container: fills space below the top bar */
#app-shell {
    display: flex;
    flex-direction: row;        /* sidebar LEFT, workspace RIGHT */
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    /* CRITICAL: override document dir="rtl" so first child = physical left */
    direction: ltr;
}

/* Left sidebar */
#sidebar {
    width: 220px;
    flex-shrink: 0;
    background: #1f2937;
    color: #d1d5db;
    overflow-y: auto;
    padding: 16px 0 24px;
    border-right: 1px solid #374151;
    /* Always stays on the physical left regardless of RTL */
    direction: ltr;
}

.sidebar-group {
    margin-bottom: 4px;
}

.sidebar-group-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #6b7280;
    padding: 14px 16px 6px;
}

.sidebar-item {
    display: block;
    padding: 7px 16px;
    font-size: 0.875rem;
    color: #d1d5db;
    text-decoration: none;
    border-radius: 0;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.sidebar-item:hover {
    background: rgba(255,255,255,0.06);
    color: #f9fafb;
}

.sidebar-item.active {
    background: rgba(99,102,241,0.18);
    color: #a5b4fc;
    font-weight: 600;
    border-left: 3px solid #6366f1;
}

/* Center workspace */
#workspace {
    flex: 1;
    /* Override the legacy `main { max-width / margin / padding }` rule */
    max-width: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #ffffff;
    /* Content inside workspace reads right-to-left (Hebrew) */
    direction: rtl;
}

#workspace .error-msg {
    margin: 12px 16px 0;
    flex-shrink: 0;
}

/* Chat section fills the workspace — no padding here, handled per zone */
#workspace .chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-top: 0;
    padding: 0;
}

/* Message log — open, borderless, ChatGPT-style conversation surface */
#workspace .chat-section .chat-log {
    flex: 1;
    height: auto;
    min-height: 0;
    /* No card: no border, no background box, no radius */
    background: #fff;
    border: none;
    border-radius: 0;
    /* Comfortable reading width with generous horizontal padding */
    padding: 32px 48px 8px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 0;
}

/* Input bar wrapper — pinned to bottom, full-width background, centered content */
#workspace .chat-section .chat-input-wrapper {
    flex-shrink: 0;
    position: relative;
    /* Match the log's horizontal padding so input aligns with messages */
    padding: 16px 48px 24px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
}

#workspace .chat-section .chat-input-row {
    display: flex;
    gap: 10px;
}

#workspace .chat-section .chat-input-row input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.95rem;
    direction: rtl;
    background: #f9fafb;
    transition: border-color 0.15s, background 0.15s;
}

#workspace .chat-section .chat-input-row input:focus {
    outline: none;
    border-color: #6366f1;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.08);
}

#workspace #chat-send-btn {
    padding: 12px 24px;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    flex-shrink: 0;
    transition: background 0.15s;
}

#workspace #chat-send-btn:hover {
    background: #4338ca;
}

/* Sidebar toggle: hide sidebar when body has .sidebar-collapsed */
body.sidebar-collapsed #sidebar {
    display: none;
}

/* Mobile: sidebar hidden by default, full-width workspace */
@media (max-width: 768px) {
    #sidebar {
        display: none;
        position: fixed;
        top: 48px;
        left: 0;
        bottom: 0;
        z-index: 40;
        width: 240px;
        box-shadow: 2px 0 12px rgba(0,0,0,0.25);
    }

    body.sidebar-open #sidebar {
        display: block;
    }

    #workspace {
        width: 100%;
    }

    #workspace .chat-section {
        padding: 12px 14px 14px;
    }
}

/* =============================================================
   WEB-3.3 — Chat Welcome State
   ============================================================= */

#chat-welcome {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px 16px 32px;
    min-height: 0;
}

.welcome-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 10px;
    letter-spacing: -0.01em;
}

.welcome-subtitle {
    font-size: 1.05rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 12px;
}

.welcome-hint {
    font-size: 0.875rem;
    color: #6b7280;
    max-width: 440px;
    line-height: 1.65;
    margin-bottom: 28px;
}

.starter-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 540px;
    direction: rtl;
}

.starter-prompt {
    padding: 9px 18px;
    background: #f9fafb;
    color: #111827;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    direction: rtl;
    white-space: nowrap;
}

.starter-prompt:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

@media (max-width: 768px) {
    #chat-welcome {
        padding: 20px 12px 24px;
    }

    .welcome-title {
        font-size: 1.4rem;
    }

    .welcome-hint {
        font-size: 0.82rem;
    }

    .starter-prompt {
        padding: 8px 14px;
        font-size: 0.82rem;
    }
}

/* =============================================================
   WEB-3.4 — Input Plus Menu
   ============================================================= */

#chat-plus-btn {
    padding: 12px 14px;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 500;
    line-height: 1;
    flex-shrink: 0;
    transition: background 0.15s, border-color 0.15s;
}

#chat-plus-btn:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

#chat-plus-btn.active {
    background: #ede9fe;
    border-color: #6366f1;
    color: #4f46e5;
}

#chat-plus-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    min-width: 200px;
    padding: 6px 0;
    z-index: 60;
    direction: rtl;
}

.plus-menu-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    text-align: right;
    font-size: 0.9rem;
    font-family: inherit;
    color: #111827;
    cursor: pointer;
    transition: background 0.12s;
    white-space: nowrap;
}

.plus-menu-item:hover {
    background: #f3f4f6;
}

@media (max-width: 768px) {
    #workspace .chat-section .chat-input-wrapper {
        padding: 12px 14px 14px;
    }
}

/* =============================================================
   WEB-3.5 — Left Sidebar Modules
   ============================================================= */

/* More breathing room between sidebar groups */
.sidebar-group {
    margin-bottom: 2px;
}

/* Hairline separator between groups */
.sidebar-group + .sidebar-group {
    border-top: 1px solid #2d3748;
    margin-top: 6px;
    padding-top: 2px;
}

/* Disabled / coming-soon sidebar items */
.sidebar-item.disabled {
    color: #4b5563;
    cursor: default;
    pointer-events: none;
}

/* Facebook / Meta Ads: the one real link inside a mostly-disabled group —
   give it a slight call-to-action feel so it stands out */
#sidebar a.sidebar-item:not(.active):not(.disabled) {
    color: #c4b5fd;
}

#sidebar a.sidebar-item:not(.active):not(.disabled):hover {
    background: rgba(99, 102, 241, 0.12);
    color: #ede9fe;
}

/* =============================================================
   WEB-3.7 — Meta Connect Card
   ============================================================= */

.meta-connect-card {
    align-self: flex-end;
    max-width: 380px;
    background: #f0f4ff;
    border: 1px solid #c7d2fe;
    border-radius: 10px;
    padding: 18px 20px;
    direction: rtl;
}

.meta-connect-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e1b4b;
    margin-bottom: 10px;
}

.meta-connect-card-body {
    font-size: 0.875rem;
    color: #374151;
    line-height: 1.65;
    margin-bottom: 16px;
}

.meta-connect-card-btn {
    display: inline-block;
    padding: 9px 20px;
    background: #4f46e5;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: background 0.15s;
    margin-bottom: 12px;
}

.meta-connect-card-btn:hover {
    background: #4338ca;
    color: #fff;
}

.meta-connect-card-note {
    font-size: 0.78rem;
    color: #6b7280;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .meta-connect-card {
        max-width: 90%;
    }
}

/* =============================================================
   WEB-3.8 — Campaigns Chat Card
   ============================================================= */

.campaigns-chat-card {
    align-self: flex-end;
    max-width: 560px;
    width: 100%;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 18px 20px;
    direction: rtl;
}

.campaigns-chat-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e1b4b;
    margin-bottom: 6px;
}

.campaigns-chat-card-subtitle {
    font-size: 0.82rem;
    color: #6b7280;
    margin-bottom: 14px;
}

.campaigns-chat-card-empty {
    font-size: 0.875rem;
    color: #374151;
    padding: 4px 0;
}

.campaigns-chat-card-table-wrap {
    overflow-x: auto;
}

.campaigns-chat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
}

.campaigns-chat-table thead th {
    background: #f1f5f9;
    color: #374151;
    padding: 8px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: right;
}

.campaigns-chat-table tbody td {
    padding: 8px 12px;
    border-bottom: 1px solid #e5e7eb;
    color: #111827;
    font-size: 0.85rem;
}

.campaigns-chat-table tbody tr:last-child td {
    border-bottom: none;
}

.campaigns-chat-table tbody tr:hover {
    background: #f9fafb;
}

.campaigns-badge-active {
    background: #d1fae5;
    color: #065f46;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 600;
}

.campaigns-badge-paused {
    background: #f3f4f6;
    color: #4b5563;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 600;
}

.campaigns-chat-card-error-msg {
    font-size: 0.875rem;
    color: #374151;
    line-height: 1.6;
    margin-bottom: 14px;
}

.campaigns-chat-card-connect-btn {
    display: inline-block;
    padding: 8px 18px;
    background: #4f46e5;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    transition: background 0.15s;
}

.campaigns-chat-card-connect-btn:hover {
    background: #4338ca;
    color: #fff;
}

@media (max-width: 768px) {
    .campaigns-chat-card {
        max-width: 95%;
    }
}

/* =============================================================
   WEB-3.9A — Safe Action Card
   ============================================================= */

.safe-action-card {
    align-self: flex-end;
    max-width: 480px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
    padding: 18px 20px;
    direction: rtl;
}

.safe-action-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #92400e;
    margin-bottom: 10px;
}

.safe-action-card-recommendation {
    font-size: 0.875rem;
    color: #374151;
    line-height: 1.65;
    margin-bottom: 12px;
}

.safe-action-card-risk {
    display: inline-block;
    font-size: 0.8rem;
    font-weight: 700;
    color: #065f46;
    background: #d1fae5;
    padding: 3px 10px;
    border-radius: 10px;
    margin-bottom: 10px;
}

.safe-action-card-reason {
    font-size: 0.82rem;
    color: #6b7280;
    line-height: 1.6;
    margin-bottom: 16px;
}

.safe-action-card-actions {
    display: flex;
    gap: 10px;
    direction: rtl;
}

.safe-action-btn-confirm {
    padding: 8px 20px;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.safe-action-btn-confirm:hover {
    background: #4338ca;
}

.safe-action-btn-cancel {
    padding: 8px 20px;
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.safe-action-btn-cancel:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.safe-action-card-status {
    font-size: 0.82rem;
    color: #6b7280;
    font-style: italic;
}

@media (max-width: 768px) {
    .safe-action-card {
        max-width: 95%;
    }
}

/* =============================================================
   WEB-3.10 — Business Operations Placeholder Card
   ============================================================= */

.business-placeholder-card {
    align-self: flex-end;
    max-width: 440px;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 16px 20px;
    direction: rtl;
}

.business-placeholder-card-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #374151;
    margin-bottom: 8px;
}

.business-placeholder-card-body {
    font-size: 0.85rem;
    color: #4b5563;
    line-height: 1.65;
    margin-bottom: 10px;
}

.business-placeholder-card-note {
    font-size: 0.78rem;
    color: #9ca3af;
    line-height: 1.5;
}

@media (max-width: 768px) {
    .business-placeholder-card {
        max-width: 95%;
    }
}

/* =============================================================
   WEB-3.11 — Mobile + RTL/LTR Polish
   ============================================================= */

/* 1. Input row: force LTR so + sits on the physical LEFT and שלח on the RIGHT.
      The input element keeps its own direction: rtl so Hebrew typing is unaffected. */
#workspace .chat-section .chat-input-row {
    direction: ltr;
}

/* 2. Plus menu: anchor LEFT to align with the + button now on the left.
      WEB-3.4 used right:0 when + was on the RTL-start (physical right). */
#chat-plus-menu {
    left: 0;
    right: auto;
}

/* 3. Chat log: prevent horizontal overflow from long unbreakable content */
#workspace .chat-section .chat-log {
    overflow-x: hidden;
}

/* 4. Chat cards: wrap long mixed Hebrew/English text cleanly */
.meta-connect-card,
.campaigns-chat-card,
.safe-action-card,
.business-placeholder-card {
    overflow-wrap: break-word;
    word-break: break-word;
}

@media (max-width: 768px) {
    /* 5. Neutralise the section-level padding from WEB-3.2 mobile rule.
          Each inner zone owns its own padding; stacking them gives 62px/side
          on a 390px screen (48px log + 14px section = only 266px content). */
    #workspace .chat-section {
        padding: 0;
    }

    /* 6. Chat log: reduce horizontal padding 48px → 14px on mobile */
    #workspace .chat-section .chat-log {
        padding: 16px 14px 8px;
    }

    /* 7. Cards: cap to viewport width so no card can cause horizontal overflow */
    .meta-connect-card,
    .campaigns-chat-card,
    .safe-action-card,
    .business-placeholder-card {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    /* 8. Starter prompts: let long English product names wrap inside the chip */
    .starter-prompt {
        white-space: normal;
    }

    .starter-prompts {
        max-width: 100%;
    }

    /* 9. Safe action buttons: stack vertically on very narrow screens */
    .safe-action-card-actions {
        flex-wrap: wrap;
    }
}

/* =============================================================
   WEB-3.12R2 — Top Right Menu
   ============================================================= */

#top-menu-area {
    position: relative;
    flex-shrink: 0;
}

#top-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    min-width: 180px;
    padding: 6px 0;
    z-index: 60;
    direction: rtl;
}

.top-menu-item {
    display: block;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    text-align: right;
    font-size: 0.9rem;
    font-family: inherit;
    color: #111827;
    cursor: pointer;
    transition: background 0.12s;
    white-space: nowrap;
    text-decoration: none;
}

.top-menu-item:hover {
    background: #f3f4f6;
}

/* =============================================================
   WEB-3.14 — Campaign Chat Card Action Buttons
   ============================================================= */

.campaigns-action-btn {
    padding: 4px 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    transition: background 0.12s, opacity 0.12s;
    white-space: nowrap;
}

.campaigns-action-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.campaigns-action-pause {
    background: #fee2e2;
    color: #991b1b;
}

.campaigns-action-pause:hover:not(:disabled) {
    background: #fecaca;
}

.campaigns-action-activate {
    background: #d1fae5;
    color: #065f46;
}

.campaigns-action-activate:hover:not(:disabled) {
    background: #a7f3d0;
}

.campaigns-action-unavailable {
    font-size: 0.78rem;
    color: #9ca3af;
}
