:root {
    --ic-blue: #2e91fc;
    --ic-blue-light: #e8f3ff;
    --ic-blue-mid: #b8d9fd;
    --ic-dark: #272C38;
}

/* ── WRAPPER ── */
.icw {
    display: flex;
    position: relative;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #fff;
    margin: 20px 0;
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
}

/* ── MOBILE OVERLAY ── */
.icw-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.35);
    z-index: 10;
}
.icw-overlay.visible { display: block; }

/* ── SIDEBAR ── */
.icw-sidebar {
    width: 210px;
    flex-shrink: 0;
    border-right: 1px solid #eee;
    display: flex;
    flex-direction: column;
    background: #f9f9f9;
    transition: transform 0.25s ease;
    z-index: 20;
}
.icw-sidebar-close {
    display: none; /* hidden on desktop */
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: #888;
    margin-bottom: 8px;
    align-self: flex-end;
}
.icw-sidebar-close svg { width: 16px; height: 16px; }
.icw-sidebar-top {
    padding: 12px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
}
.icw-new-btn {
    width: 100%;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1px solid var(--ic-blue);
    background: transparent;
    color: var(--ic-blue);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
    font-weight: 500;
}
.icw-new-btn:hover { background: var(--ic-blue-light); }
.icw-new-btn svg { width: 12px; height: 12px; flex-shrink: 0; }

.icw-step-nav {
    padding: 8px 8px 6px;
    border-bottom: 1px solid #eee;
}
.icw-step-nav h4 {
    margin: 0 0 5px;
    font-size: 10px;
    font-weight: 500;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    padding: 0 4px;
}
.icw-step-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 6px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 12px;
    color: #777;
}
.icw-step-item:hover { background: #fff; }
.icw-step-item.active { background: var(--ic-blue-light); color: var(--ic-dark); font-weight: 500; }
.icw-step-dot {
    width: 17px; height: 17px;
    border-radius: 50%;
    border: 1.5px solid #ccc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 600;
    flex-shrink: 0;
    color: #999;
}
.icw-step-item.active .icw-step-dot { background: var(--ic-blue); border-color: var(--ic-blue); color: white; }
.icw-step-item.done .icw-step-dot { background: var(--ic-blue-light); border-color: var(--ic-blue-mid); color: var(--ic-dark); }

/* ── HISTORY LIST ── */
.icw-history-list { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.icw-history-header { padding: 8px 12px 4px; }
.icw-history-header h4 { font-size: 10px; font-weight: 500; color: #999; text-transform: uppercase; letter-spacing: 0.6px; margin: 0; }
.icw-history-items { flex: 1; overflow-y: auto; padding: 0 8px 8px; max-height: 280px; }
.icw-history-items::-webkit-scrollbar { width: 3px; }
.icw-history-items::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }
.icw-history-loading { font-size: 11px; color: #bbb; padding: 8px 4px; }
.icw-history-empty { font-size: 11px; color: #bbb; padding: 8px 4px; }

.icw-hist-item {
    padding: 6px 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    margin-bottom: 1px;
}
.icw-hist-item:hover { background: #fff; }
.icw-hist-item:hover .icw-hist-delete { opacity: 1; }
.icw-hist-item.active { background: #fff; border: 1px solid #e8e8e8; }

/* History row with title + delete button */
.icw-hist-row {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 2px;
}
.icw-hist-title { flex: 1; font-size: 12px; color: #333; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icw-hist-delete {
    flex-shrink: 0;
    width: 20px; height: 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    color: #ccc;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}
.icw-hist-delete:hover { color: #e53e3e; background: #fff5f5; }
.icw-hist-delete svg { width: 12px; height: 12px; }
.icw-hist-meta { font-size: 10px; color: #aaa; display: flex; gap: 5px; align-items: center; }
.icw-step-badge { font-size: 9px; padding: 1px 5px; border-radius: 3px; background: var(--ic-blue-light); color: var(--ic-dark); font-weight: 500; }

/* ── MAIN AREA ── */
.icw-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.icw-topbar {
    padding: 11px 14px;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    gap: 8px;
}
/* Mobile menu button — hidden on desktop */
.icw-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 3px;
    color: #555;
    flex-shrink: 0;
}
.icw-menu-btn svg { width: 18px; height: 18px; display: block; }

.icw-coach-dot { width: 7px; height: 7px; border-radius: 50%; background: #22C55E; flex-shrink: 0; }
.icw-topbar-text { flex: 1; min-width: 0; }
.icw-topbar-text h3 { margin: 0; font-size: 13px; font-weight: 600; color: #222; }
.icw-conv-title { margin: 0; font-size: 11px; color: #999; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icw-step-label { font-size: 11px; padding: 3px 9px; border-radius: 20px; background: var(--ic-blue-light); color: var(--ic-dark); font-weight: 500; white-space: nowrap; flex-shrink: 0; }

/* ── DELETE CONFIRMATION BAR ── */
.icw-delete-bar {
    padding: 8px 14px;
    background: #fff5f5;
    border-bottom: 1px solid #fecaca;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.icw-delete-bar span { font-size: 12px; color: #c53030; font-weight: 500; }
.icw-delete-bar-actions { display: flex; gap: 6px; }
.icw-delete-confirm {
    padding: 4px 12px;
    border-radius: 6px;
    border: none;
    background: #e53e3e;
    color: white;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.15s;
}
.icw-delete-confirm:hover { background: #c53030; }
.icw-delete-cancel {
    padding: 4px 12px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: white;
    color: #555;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}
.icw-delete-cancel:hover { background: #f9f9f9; }

/* ── MESSAGES ── */
.icw-messages { overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 11px; }
.icw-messages::-webkit-scrollbar { width: 3px; }
.icw-messages::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 2px; }

.icw-msg { display: flex; gap: 8px; max-width: 86%; animation: icwFade 0.2s ease; }
@keyframes icwFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.icw-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.icw-av { width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 9px; font-weight: 700; margin-top: 2px; }
.assistant .icw-av { background: #2e91fc; color: #fff; }
.user .icw-av { background: #f0f0f0; color: #666; }
.icw-bubble { padding: 8px 12px; border-radius: 10px; font-size: 13px; line-height: 1.65; color: #333; }
.assistant .icw-bubble { background: #f7f8fa; border: 1px solid #ebebeb; border-top-left-radius: 2px; }
.user .icw-bubble { background: var(--ic-dark); color: #ddeeff; border-top-right-radius: 2px; }

.icw-typing { display: flex; gap: 3px; padding: 8px 12px; background: #f7f8fa; border: 1px solid #ebebeb; border-radius: 10px; border-top-left-radius: 2px; width: fit-content; }
.icw-tdot { width: 5px; height: 5px; border-radius: 50%; background: #aaa; animation: icwB 1.2s ease infinite; }
.icw-tdot:nth-child(2) { animation-delay: 0.2s; }
.icw-tdot:nth-child(3) { animation-delay: 0.4s; }
@keyframes icwB { 0%,60%,100% { transform: translateY(0); opacity: 0.4; } 30% { transform: translateY(-3px); opacity: 1; } }

/* ── QUICK REPLIES ── */
.icw-qr { display: flex; flex-wrap: wrap; gap: 5px; padding: 0 14px 6px; }
.icw-qr-btn { padding: 4px 10px; border-radius: 14px; border: 1px solid var(--ic-blue); background: transparent; color: var(--ic-blue); font-size: 11px; font-family: inherit; cursor: pointer; transition: all 0.15s; }
.icw-qr-btn:hover { background: var(--ic-blue-light); }

/* ── INPUT ── */
.icw-input-row { display: flex; gap: 7px; padding: 9px 12px; border-top: 1px solid #eee; align-items: flex-end; }
.icw-ta { flex: 1; border: 1px solid #ddd; border-radius: 8px; padding: 7px 10px; font-size: 13px; font-family: inherit; resize: none; min-height: 33px; max-height: 120px; background: #f9f9f9; color: #333; outline: none; line-height: 1.5; transition: border-color 0.15s; }
.icw-ta:focus { border-color: var(--ic-blue); background: #fff; }
.icw-send { width: 33px; height: 33px; border-radius: 8px; background: var(--ic-blue); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background 0.15s; color: white; }
.icw-send:hover { background: var(--ic-dark); }
.icw-send svg { width: 13px; height: 13px; }

/* ── FOOTER ── */
.icw-footer { padding: 6px 14px; border-top: 1px solid #eee; display: flex; align-items: center; justify-content: space-between; background: #f9f9f9; }
.icw-footer span { font-size: 10px; color: #aaa; }
.icw-footer a { font-size: 10px; color: var(--ic-blue); text-decoration: none; font-weight: 500; }
.icw-footer a:hover { text-decoration: underline; }

/* ── LOGIN NOTICE ── */
.ic-login-notice { padding: 16px 20px; background: #f7f8fa; border: 1px solid #e0e0e0; border-radius: 8px; font-size: 14px; color: #555; }
.ic-login-notice a { color: var(--ic-blue); }

/* ────────────────────────────────────────────
   MOBILE RESPONSIVE — 600px and below
──────────────────────────────────────────── */
@media (max-width: 600px) {

    .icw {
        flex-direction: column;
        border-radius: 8px;
        margin: 0 0 16px;
    }

    /* Sidebar becomes a slide-in drawer */
    .icw-sidebar {
        position: absolute;
        top: 0; left: 0; bottom: 0;
        width: 260px;
        transform: translateX(-100%);
        box-shadow: 4px 0 16px rgba(0,0,0,0.12);
    }
    .icw-sidebar.open {
        transform: translateX(0);
    }

    /* Show close button inside sidebar on mobile */
    .icw-sidebar-close {
        display: flex;
    }

    /* Show hamburger menu button */
    .icw-menu-btn {
        display: flex;
    }

    /* Main takes full width */
    .icw-main {
        width: 100%;
        min-height: 500px;
    }

    /* Topbar adjustments */
    .icw-topbar {
        padding: 10px 12px;
        gap: 6px;
    }
    .icw-topbar-text h3 { font-size: 13px; }

    /* Hide step label on very small screens to prevent overflow */
    .icw-step-label {
        display: none;
    }

    /* Messages area — fill available space */
    .icw-messages {
        padding: 12px;
        gap: 10px;
    }

    /* Bigger font for bubbles on mobile */
    .icw-bubble {
        font-size: 14px;
        padding: 9px 13px;
    }

    /* Input area — larger touch targets */
    .icw-input-row { padding: 8px 10px; gap: 6px; }
    .icw-ta { font-size: 14px; padding: 8px 11px; }
    .icw-send { width: 38px; height: 38px; }
    .icw-send svg { width: 15px; height: 15px; }

    /* Quick replies wrap better */
    .icw-qr { padding: 0 12px 8px; gap: 6px; }
    .icw-qr-btn { font-size: 12px; padding: 5px 11px; }

    /* Delete bar full width */
    .icw-delete-bar { padding: 8px 12px; }

    /* Footer */
    .icw-footer { padding: 6px 12px; }

    /* History items — show delete button always on mobile (no hover) */
    .icw-hist-delete { opacity: 1; }

    /* Messages max width wider on mobile */
    .icw-msg { max-width: 94%; }

    /* Avatar slightly smaller */
    .icw-av { width: 24px; height: 24px; font-size: 8px; }
}

/* ────────────────────────────────────────────
   TABLET — 601px to 768px
──────────────────────────────────────────── */
@media (min-width: 601px) and (max-width: 768px) {

    .icw-sidebar { width: 180px; }

    .icw-step-label {
        font-size: 10px;
        padding: 2px 7px;
    }

    .icw-bubble { font-size: 13px; }
    .icw-ta { font-size: 13px; }
}

/* ── LEARNDASH MARK COMPLETE ──────────────────────────────────────────────────
   The IC AI Coach is always in progress — never "complete".
   This CSS file only loads on pages with the [ic_ai_coach] shortcode,
   so hiding the Mark Complete button here is safe and intentional.
   Works in browser, BuddyBoss App WebView, and any other context.
────────────────────────────────────────────────────────────────────────────── */
#sfwd-mark-complete,
form#sfwd-mark-complete,
.sfwd-mark-complete,
.learndash_mark_complete_button,
#learndash_mark_complete_button,
form#learndash-mark-complete,
#learndash-mark-complete,
#learndash-course-infobar-mark-complete-button,
.ld-content-action:has(#sfwd-mark-complete) {
    display: none !important;
}

/* ── UPGRADE / ACCESS NOTICE ────────────────────────────────────────────────── */
.ic-upgrade-notice {
    padding: 28px 32px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    border-left: 4px solid #2e91fc;
    box-shadow: 0 2px 12px rgba(0,0,0,0.07);
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.ic-upgrade-notice p {
    margin: 0 0 10px;
    font-size: 14px;
    color: #444;
    line-height: 1.6;
}
.ic-upgrade-notice p:last-child { margin-bottom: 0; }
.ic-upgrade-notice strong { color: #272C38; font-size: 16px; }
.ic-upgrade-btn {
    display: inline-block;
    margin-top: 6px;
    padding: 10px 22px;
    background: #2e91fc;
    color: #fff !important;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.15s;
}
.ic-upgrade-btn:hover { background: #272C38; }
