/* ═══════════════════════════════════════════════════════════════
   tMarketing — CSS Design System
   EN: Industrial dark theme with yellow accent for marketing module.
   VI: Theme công nghiệp tối với điểm nhấn vàng cho module marketing.
   Design source: pencil-design/src/pages/tMarketing/desktop/
   ═══════════════════════════════════════════════════════════════ */

/* ── DESIGN TOKENS ── */
:root {
    --mkt-bg-page: #18181B;
    --mkt-bg-card: #0F0F10;
    --mkt-bg-elevated: #1C1C1F;
    --mkt-yellow-primary: #FACC15;
    --mkt-yellow-light: #FDE047;
    --mkt-yellow-dim: rgba(250, 204, 21, 0.08);
    --mkt-yellow-glow: rgba(250, 204, 21, 0.15);
    --mkt-text-primary: #FAFAFA;
    --mkt-text-secondary: #71717A;
    --mkt-text-tertiary: #52525B;
    --mkt-border: #27272A;
    --mkt-border-light: #3F3F46;
    --mkt-success: #22C55E;
    --mkt-warning: #FACC15;
    --mkt-error: #EF4444;
    --mkt-info: #3B82F6;
    --mkt-purple: #8B5CF6;
    --mkt-pink: #EC4899;
    --mkt-sidebar-w: 240px;
    --mkt-font: 'Roboto', sans-serif;
}

/* ── LAYOUT ── */
.mkt-layout {
    display: flex;
    min-height: 100vh;
    background: var(--mkt-bg-page);
    color: var(--mkt-text-primary);
    font-family: var(--mkt-font);
}

.mkt-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--mkt-bg-page);
}

/* ── SIDEBAR ── */
.mkt-sidebar {
    width: var(--mkt-sidebar-w);
    background: var(--mkt-bg-card);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--mkt-border);
    flex-shrink: 0;
    overflow-y: auto;
}

.mkt-sidebar__logo {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 20px 16px;
}

.mkt-sidebar__logo-icon {
    width: 32px;
    height: 32px;
    background: var(--mkt-yellow-primary);
    color: var(--mkt-bg-card);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
}

.mkt-sidebar__logo-text {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--mkt-text-primary);
}

/* Navigation items */
.mkt-sidebar__nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 12px;
    flex: 1;
}

.mkt-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--mkt-text-secondary);
    text-decoration: none;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
}

.mkt-nav-item:hover {
    color: var(--mkt-text-primary);
    background: var(--mkt-yellow-dim);
}

.mkt-nav-item--active {
    color: var(--mkt-text-primary) !important;
    background: var(--mkt-yellow-glow) !important;
}

.mkt-nav-item--active .mkt-nav-num {
    color: var(--mkt-yellow-primary) !important;
}

.mkt-nav-num {
    font-size: 12px;
    font-weight: 600;
    color: var(--mkt-text-tertiary);
    min-width: 20px;
}

/* Sidebar stats card */
.mkt-sidebar__stats {
    margin: 16px 12px;
    padding: 16px;
    background: rgba(250, 204, 21, 0.06);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mkt-sidebar__stats-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--mkt-yellow-primary);
    letter-spacing: 0.5px;
}

.mkt-sidebar__stats-header i {
    width: 14px;
    height: 14px;
}

.mkt-sidebar__stats-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--mkt-text-primary);
}

/* Sidebar user */
.mkt-sidebar__user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid var(--mkt-border);
}

.mkt-user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: var(--mkt-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 700;
    color: var(--mkt-text-primary);
}

.mkt-user-name {
    flex: 1;
    font-size: 12px;
    font-weight: 500;
    color: var(--mkt-text-primary);
    letter-spacing: 0.5px;
}

.mkt-sidebar__user button {
    background: none;
    border: none;
    color: var(--mkt-text-tertiary);
    cursor: pointer;
    padding: 4px;
}

.mkt-sidebar__user button i {
    width: 14px;
    height: 14px;
}

/* ── TOPBAR ── */
.mkt-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    flex-shrink: 0;
}

.mkt-topbar__left {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mkt-topbar__title {
    font-size: 22px;
    font-weight: 700;
    color: var(--mkt-text-primary);
    margin: 0;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.mkt-topbar__subtitle {
    font-size: 13px;
    color: var(--mkt-text-secondary);
    margin: 0;
}

.mkt-topbar__right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── BUTTONS ── */
.mkt-btn-primary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--mkt-yellow-primary);
    color: var(--mkt-bg-card);
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: background 0.2s;
}

.mkt-btn-primary:hover {
    background: var(--mkt-yellow-light);
}

.mkt-btn-primary i {
    width: 14px;
    height: 14px;
}

.mkt-btn-ghost {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: transparent;
    color: var(--mkt-text-secondary);
    border: 1px solid var(--mkt-border);
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: all 0.2s;
}

.mkt-btn-ghost:hover {
    color: var(--mkt-text-primary);
    border-color: var(--mkt-border-light);
}

.mkt-btn-ghost i {
    width: 14px;
    height: 14px;
}

/* ── CONTENT AREA ── */
.mkt-content {
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 0 28px 28px;
    flex: 1;
}

/* ── KPI CARDS ── */
.mkt-kpi-row {
    display: flex;
    gap: 16px;
}

.mkt-kpi-card {
    flex: 1;
    background: var(--mkt-bg-card);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mkt-kpi-card__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mkt-kpi-card__icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mkt-kpi-card__icon i {
    width: 16px;
    height: 16px;
}

.mkt-kpi-card__badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 2px;
}

.mkt-kpi-card__badge--up {
    color: var(--mkt-success);
    background: rgba(34, 197, 94, 0.1);
}

.mkt-kpi-card__badge--down {
    color: var(--mkt-error);
    background: rgba(239, 68, 68, 0.1);
}

.mkt-kpi-card__badge i {
    width: 10px;
    height: 10px;
}

.mkt-kpi-card__value {
    font-size: 24px;
    font-weight: 700;
    color: var(--mkt-text-primary);
}

.mkt-kpi-card__label {
    font-size: 12px;
    color: var(--mkt-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── PANELS / CARDS ── */
.mkt-panel {
    background: var(--mkt-bg-card);
    border-radius: 10px;
    overflow: hidden;
}

.mkt-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--mkt-border);
}

.mkt-panel__title {
    font-size: 13px;
    font-weight: 700;
    color: var(--mkt-text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin: 0;
}

.mkt-panel__title i {
    width: 16px;
    height: 16px;
    color: var(--mkt-yellow-primary);
}

.mkt-panel__action {
    font-size: 12px;
    color: var(--mkt-yellow-primary);
    text-decoration: none;
    font-weight: 500;
    letter-spacing: 0.3px;
}

.mkt-panel__body {
    padding: 16px 20px;
}

/* ── TABLE ── */
.mkt-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.mkt-table th {
    text-align: left;
    padding: 10px 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--mkt-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--mkt-border);
}

.mkt-table td {
    padding: 12px;
    border-bottom: 1px solid var(--mkt-border);
    color: var(--mkt-text-primary);
}

.mkt-table tr:last-child td {
    border-bottom: none;
}

.mkt-table tr:hover td {
    background: var(--mkt-yellow-dim);
}

/* ── STATUS BADGES ── */
.mkt-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.mkt-badge--active {
    background: rgba(34, 197, 94, 0.12);
    color: var(--mkt-success);
}

.mkt-badge--draft {
    background: rgba(113, 113, 122, 0.12);
    color: var(--mkt-text-secondary);
}

.mkt-badge--training {
    background: rgba(250, 204, 21, 0.12);
    color: var(--mkt-warning);
}

.mkt-badge--error {
    background: rgba(239, 68, 68, 0.12);
    color: var(--mkt-error);
}

.mkt-badge--info {
    background: rgba(59, 130, 246, 0.12);
    color: var(--mkt-info);
}

/* ── SEARCH ── */
.mkt-search {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--mkt-bg-card);
    border: 1px solid var(--mkt-border);
    border-radius: 6px;
    min-width: 200px;
}

.mkt-search i {
    width: 14px;
    height: 14px;
    color: var(--mkt-text-tertiary);
}

.mkt-search input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    color: var(--mkt-text-primary);
    font-size: 12px;
    font-family: var(--mkt-font);
}

.mkt-search input::placeholder {
    color: var(--mkt-text-tertiary);
}

/* ── CHANNEL CARDS (Social Hub) ── */
.mkt-channel-card {
    background: var(--mkt-bg-card);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    border: 1px solid var(--mkt-border);
    transition: border-color 0.2s;
}

.mkt-channel-card:hover {
    border-color: var(--mkt-border-light);
}

/* ── CHAT (Livechat) ── */
.mkt-chat-layout {
    display: flex;
    flex: 1;
    min-height: 0;
}

.mkt-chat-list {
    width: 300px;
    border-right: 1px solid var(--mkt-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.mkt-chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.mkt-chat-info {
    width: 280px;
    border-left: 1px solid var(--mkt-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.mkt-chat-item {
    display: flex;
    gap: 10px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--mkt-border);
    transition: background 0.2s;
}

.mkt-chat-item:hover,
.mkt-chat-item--active {
    background: var(--mkt-yellow-dim);
}

/* ── MOBILE RESPONSIVE ── */
.mkt-sidebar-overlay {
    display: none;
}

/* ── Mobile hamburger button ── */
.mkt-mobile-toggle {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    background: var(--mkt-bg-card);
    border: 1px solid var(--mkt-border);
    color: var(--mkt-text-primary);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

/* ── Mobile bar — hidden on desktop ── */
.mkt-mobile-bar {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--mkt-bg-card);
    border-bottom: 1px solid var(--mkt-border);
}

.mkt-mobile-bar__title {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--mkt-yellow-primary);
    flex: 1;
}

/* ── Mobile search ── */
.mkt-mobile-search {
    display: none;
    position: relative;
    flex: 1;
}

.mkt-mobile-search input {
    width: 100%;
    height: 32px;
    padding: 0 12px 0 32px;
    background: var(--mkt-bg-page);
    border: 1px solid var(--mkt-border);
    border-radius: 6px;
    color: var(--mkt-text-primary);
    font-size: 12px;
    outline: none;
}

.mkt-mobile-search input:focus {
    border-color: var(--mkt-yellow-primary);
}

.mkt-mobile-search i {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    color: var(--mkt-text-secondary);
    pointer-events: none;
}

.mkt-mobile-search-btn {
    display: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: transparent;
    border: 1px solid var(--mkt-border);
    color: var(--mkt-text-secondary);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

/* ── Sidebar close button (mobile) ── */
.mkt-sidebar-close {
    display: none;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--mkt-border);
    color: var(--mkt-text-secondary);
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin-left: auto;
}

@media (max-width: 768px) {

    /* ── Sidebar hide/show ── */
    .mkt-sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        width: 260px;
        z-index: 1001;
        transition: left 0.3s ease;
    }

    .mkt-sidebar--open {
        left: 0;
    }

    .mkt-sidebar-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 1000;
        cursor: pointer;
    }

    .mkt-sidebar-close {
        display: flex;
    }

    .mkt-mobile-toggle {
        display: flex;
    }

    .mkt-mobile-bar {
        display: flex;
    }

    .mkt-mobile-search-btn {
        display: flex;
    }

    /* ── Topbar — compact ── */
    .mkt-topbar {
        padding: 10px 16px;
        gap: 6px;
    }

    .mkt-topbar__left {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
    }

    .mkt-topbar__title {
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mkt-topbar__subtitle {
        display: none;
    }

    .mkt-topbar__right {
        flex-wrap: nowrap;
        gap: 4px;
        flex-shrink: 0;
    }

    .mkt-topbar__right .mkt-search {
        display: none;
    }

    .mkt-topbar__right .mkt-btn-ghost,
    .mkt-topbar__right .mkt-btn-primary {
        padding: 6px 8px;
        font-size: 11px;
        gap: 4px;
    }

    .mkt-topbar__right .mkt-btn-ghost span,
    .mkt-topbar__right .mkt-btn-primary span {
        display: none;
    }

    /* ── Content area ── */
    .mkt-content {
        padding: 0 12px 16px;
        gap: 16px;
    }

    /* ── KPI row → 2x2 grid ── */
    .mkt-kpi-row {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 10px !important;
    }

    .mkt-kpi-card {
        min-width: 0;
    }

    .mkt-kpi-card__value {
        font-size: 20px;
    }

    /* ── Table → horizontal scroll ── */
    .mkt-panel:has(.mkt-table) .mkt-panel__body,
    .mkt-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .mkt-table {
        min-width: 600px;
    }

    /* ── Search → smaller ── */
    .mkt-search {
        min-width: 120px;
    }

    /* ═══ LIVECHAT — single column ═══ */
    .mkt-chat-layout {
        flex-direction: column !important;
    }

    .mkt-chat-list {
        width: 100% !important;
        max-height: 220px;
        border-right: none !important;
        border-bottom: 1px solid var(--mkt-border);
    }

    .mkt-chat-main {
        min-height: 300px;
    }

    .mkt-chat-info {
        display: none !important;
    }

    /* ═══ SOCIAL HUB — stack sections ═══ */
    .mkt-hub-columns {
        flex-direction: column !important;
        gap: 16px !important;
    }

    .mkt-hub-columns>div {
        width: 100% !important;
    }

    .mkt-platform-grid {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .mkt-platform-grid>div {
        width: 100% !important;
    }

    /* ═══ AI CONTENT STUDIO — stack calendar + AI panel ═══ */
    .mkt-content-split {
        flex-direction: column !important;
        padding: 0 12px 16px !important;
    }

    .mkt-content-split>div {
        width: 100% !important;
        padding-right: 0 !important;
    }

    .mkt-calendar-grid {
        font-size: 11px;
    }

    /* ═══ ANALYTICS — stack chart + top content ═══ */
    .mkt-analytics-row {
        flex-direction: column !important;
        gap: 16px !important;
    }

    .mkt-analytics-row>.mkt-panel {
        width: 100% !important;
        flex: none !important;
    }

    .mkt-channel-cards {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .mkt-channel-cards>div {
        width: 100% !important;
    }

    /* ═══ CHATBOT — stack flows + canvas ═══ */
    .mkt-chatbot-layout {
        flex-direction: column !important;
    }

    .mkt-chatbot-layout>.mkt-flow-list {
        width: 100% !important;
        max-height: 200px;
        border-right: none !important;
        border-bottom: 1px solid var(--mkt-border);
        overflow-y: auto;
    }

    .mkt-chatbot-layout>.mkt-flow-canvas {
        min-height: 300px;
    }

    .mkt-node-palette {
        position: static !important;
        width: 100% !important;
        right: auto !important;
        top: auto !important;
        bottom: auto !important;
        display: flex !important;
        flex-direction: row !important;
        overflow-x: auto !important;
        gap: 8px !important;
        padding: 12px !important;
        border-top: 1px solid var(--mkt-border);
    }

    .mkt-node-palette>div {
        min-width: 140px;
        flex-shrink: 0;
    }

    /* ═══ AI CHATBOT — stack scenarios + panels ═══ */
    .mkt-aibot-layout {
        flex-direction: column !important;
    }

    .mkt-aibot-layout>.mkt-scenario-list {
        width: 100% !important;
        max-height: 200px;
        border-right: none !important;
        border-bottom: 1px solid var(--mkt-border);
        overflow-y: auto;
    }

    .mkt-aibot-layout>.mkt-aibot-main {
        width: 100% !important;
    }

    .mkt-aibot-panels {
        flex-direction: column !important;
        gap: 16px !important;
    }

    .mkt-aibot-panels>div {
        width: 100% !important;
    }

    /* ═══ Panel footer actions → wrap ═══ */
    .mkt-panel-footer {
        flex-wrap: wrap;
        gap: 8px;
    }

    .mkt-panel-footer .mkt-btn-ghost,
    .mkt-panel-footer .mkt-btn-primary {
        font-size: 11px;
        padding: 6px 10px;
    }

    /* ═══ CHATBOT CANVAS — stack nodes vertically ═══ */
    .mkt-flow-canvas-nodes {
        flex-direction: column !important;
        align-items: stretch !important;
        justify-content: flex-start !important;
        padding: 20px 16px !important;
        gap: 0 !important;
    }

    .mkt-flow-canvas-nodes>div[style*="width:280px"] {
        width: 100% !important;
    }

    .mkt-flow-connector {
        width: 2px !important;
        height: 24px !important;
        margin: 0 auto;
    }

    /* ═══ CRM — bottom action bar wraps ═══ */
    .mkt-crm-actions {
        flex-direction: column !important;
        gap: 10px !important;
    }

    .mkt-crm-actions>div {
        flex-wrap: wrap;
        gap: 6px;
    }

    .mkt-crm-actions .mkt-btn-ghost,
    .mkt-crm-actions .mkt-btn-primary {
        font-size: 11px;
        padding: 6px 10px;
    }

    /* ═══ AI CHATBOT — hide test chat panel on small mobile ═══ */
    .mkt-aibot-test-chat {
        display: none !important;
    }
}