/* ==========================================================================
   SIDEBAR
   ========================================================================== */
.sidebar {
    width: 16rem;
    /* background-color: var(--bg-glass); */
    background-color: transparent;
    /* border-inline-end: 1px solid var(--border-color); */
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    /* backdrop-filter: blur(8px); */
    transition: transform 0.3s ease;
    position: fixed;
    top: var(--ctc-wp-adminbar-height);
    inset-inline-start: 0;
    bottom: 0;
    /* .admin-header has z-index: 1000 so we are giving z-index: 1001 to sidebar */
    z-index: 1001;
    transform: translateX(-100%);
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 1rem 1rem;
}

.sidebar-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.close-sidebar {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: var(--transition);
}

.close-sidebar:hover {
    color: var(--text);
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-nav ul {
    list-style: none;
    padding: 0 1rem;
}

.sidebar-nav li {
    margin-bottom: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    text-align: start;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.nav-item:hover {
    background-color: var(--bg-card);
    color: var(--text);
}

.nav-item.active {
    /* background: linear-gradient(90deg, var(--primary-light) 0%, transparent 100%); */
    background: none;
    /* Brand teal accent for the active item; --primary-readable clears WCAG AA (≈5.3:1 on light). */
    color: var(--primary-readable);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 1.5rem;
    width: 3px;
    /* Match the active label + icon colour so the whole active item is one tone. */
    background-color: var(--primary-readable);
    border-radius: 0 4px 4px 0;
}

.nav-item span:not(.dashicons) {
    flex: 1;
    white-space: normal;
    word-break: break-word;
    line-height: 1.4;
}


/* Drill-Down Menus */
.sidebar-menus-container {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.sidebar-menu {
    display: none;
    width: 100%;
    animation: slideIn 0.3s ease forwards;
}

.sidebar-menu.active {
    display: block;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.drill-down-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: start;
}

.drill-down-btn:hover {
    background-color: var(--bg-card);
    color: var(--text);
}

.drill-down-btn span:not(.dashicons) {
    flex: 1;
    white-space: normal;
    word-break: break-word;
    line-height: 1.4;
}

.drill-down-back-btn {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: none;
    border-bottom: 1px solid var(--border-color);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 0.5rem;
    transition: background-color 0.2s ease;
}

.drill-down-back-btn:hover {
    background-color: var(--bg-card);
}

.drill-down-back-btn span:not(.dashicons) {
    flex: 1;
    text-align: start;
    white-space: normal;
    word-break: break-word;
    line-height: 1.4;
}

/* Right Sidebar Structure */
/* hidden by default; shown at >=1024px via responsive.css */
.right-sidebar {
    width: 350px;
    /* Transparent panel, no border: the widget cards define the region —
       a panel surface/divider on top reads as card-inside-card and adds
       extra lines where panel + header + card borders meet. */
    background-color: transparent;
    display: none;
    flex-direction: column;
    flex-shrink: 0;
}

.right-sidebar-header {
    padding: 1.5rem 0.75rem 0;
}

.sidebar-tabs {
    display: flex;
    background-color: var(--input-bg);
    padding: 0.25rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.sidebar-tab-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.5rem 0.25rem;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.sidebar-tab-btn:hover {
    color: var(--text);
}

.sidebar-tab-btn.active {
    background-color: var(--bg-card);
    color: var(--primary-readable);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.sidebar-tab-btn .dashicons {
    font-size: 1.25rem;
    width: 20px;
    height: 20px;
}

.sidebar-tab-label {
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
}

.right-sidebar-content {
    padding: 1.5rem;
    display: none;
    flex-direction: column;
    gap: 1.5rem;
    overflow-y: auto;
    flex: 1;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.right-sidebar-content:has(.active) {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.sidebar-tab-content {
    display: none;
}

.sidebar-tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease-out;
}

/* The tab-content panels are focusable scroll regions (tabindex="0") —
   keyboard users need a visible ring when focus lands on them. */
.sidebar-tab-content:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
    border-radius: var(--radius);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Sidebar Widgets - General */
.sidebar-widget {
    background-color: var(--bg-card);

    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    overflow: hidden;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.sidebar-widget.feature-widget {
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(37, 211, 102, 0.05) 100%);
    border-color: rgba(37, 211, 102, 0.2);
}

.widget-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

/* Preview tab card — compact. The floating live preview shares the viewport's
   right edge with this panel, so the shorter the card, the less an open
   widget/greetings dialog overlaps its controls. Switch sits in the header
   row; description is one small hint line under the controls. */
.preview-widget {
    padding: 1rem;
}

.preview-widget .widget-header {
    margin-bottom: 0.75rem;
}

.preview-widget .widget-header .switch {
    margin-inline-start: auto;
}

.preview-widget .widget-body p {
    margin: 0.5rem 0 0;
    font-size: 0.8rem;
}

/* The dynamic note is usually empty — don't let it reserve space. */
.preview-widget #ctc-preview-note:empty {
    display: none;
}

/* Contextual note as a small info callout, so it reads as feedback about the
   last edit — distinct from the static hint below it. The info glyph is a
   ::before (pseudo-content doesn't affect :empty, so the show/hide rules
   above keep working), and the display:none → flex flip when a note arrives
   restarts the fade-in. */
.preview-widget #ctc-preview-note {
    display: flex;
    align-items: flex-start;
    gap: 0.4rem;
    padding: 0.5rem 0.6rem;
    /* Same WhatsApp-green family as .feature-widget's tint, a touch stronger. */
    background: rgba(37, 211, 102, 0.08);
    border-inline-start: 3px solid var(--primary);
    border-radius: 6px;
    color: var(--text);
    animation: fadeIn 0.3s ease-out;
}

.preview-widget #ctc-preview-note::before {
    content: "\f348";
    font-family: dashicons, sans-serif;
    font-size: 1rem;
    line-height: 1.2;
    color: var(--primary-readable);
    flex-shrink: 0;
}

/* One help line at a time: while the dynamic note has content it takes the
   static hint's place, so the two never stack. When the note clears (JS sets
   textContent to ''), :empty hides it above and the hint returns. */
.preview-widget #ctc-preview-note:not(:empty) ~ .preview-hint {
    display: none;
}

/* Preview switched off → the device segment and help text have nothing to
   act on; dim them as a cue (still clickable — flipping the segment while
   off is harmless and remembered). Progressive enhancement: browsers
   without :has() simply skip the dimming. */
.preview-widget .widget-body {
    transition: opacity 0.2s ease;
}

.preview-widget:has(#ctc-preview-toggle:not(:checked)) .widget-body {
    opacity: 0.45;
}

.widget-header .dashicons {
    color: var(--primary);
    font-size: 1.25rem;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-widget.feature-widget .widget-header .dashicons {
    color: #eab308;
}

.widget-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
}

.widget-body p {
    margin: 0 0 1rem 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.widget-body p strong {
    color: var(--text);
    font-weight: 600;
}

.widget-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-pill);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
}

.widget-btn-outline {
    background-color: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.widget-btn-outline:hover {
    border-color: var(--primary);
    background-color: rgba(255, 255, 255, 0.05);
    /* Slight bright indication on hover */
    color: var(--primary-readable);
}

.widget-btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border: none;
    color: white;
    box-shadow: 0 4px 15px -3px var(--primary-glow);
}

.widget-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -4px var(--primary-glow);
    filter: brightness(1.1);
}

/* PRO Widget Custom Classes */
.ctc-pro-promo {
    /* Gold for text needs theme-aware shades: the brand #eab308 is too light to
       read on a white card (≈2:1 contrast), so light mode uses a darker amber
       (≈5.7:1) and dark mode keeps the bright gold (≈8:1 on dark cards). */
    --ctc-gold-text: #a16207;
    /* Extra breathing room above the promo, beyond the container's flex gap. */
    margin-top: 15px;

    /* Airy treatment: skip the solid card surface other widgets get —
       just a faint gold wash and border so it reads as a highlight,
       not another content card. */
    /* card bg */
    background: linear-gradient(135deg, rgba(234, 179, 8, 0.06), transparent 60%);
    border-color: rgba(234, 179, 8, 0.25);
    /* card bgend */
}

html[data-theme="dark"] .ctc-pro-promo {
    --ctc-gold-text: #eab308;
}

.ctc-pro-icon {
    color: var(--ctc-gold-text) !important;
}

.ctc-pro-title {
    color: var(--ctc-gold-text) !important;
    font-weight: 600 !important;
}

.ctc-pro-feature-list {
    margin: 0 0 15px 0;
    padding-inline-start: 0;
    list-style: none;
}

.ctc-pro-feature-list li {
    margin-bottom: 12px;
}

.ctc-pro-feature-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ctc-pro-icon-small {
    color: var(--ctc-gold-text);
    font-size: 16px;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Extra class in the selector so this wins over `.widget-body p` (it was
   losing on specificity, flattening the indent + spacing). */
.ctc-pro-feature-list .ctc-pro-feature-desc {
    margin: 4px 0 0;
    /* Align under the title text (16px icon + 8px gap). */
    margin-inline-start: 24px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Feedback tab — concrete prompts that lower the blank-page friction so
   people actually share an idea instead of staring at a generic box.
   Kept as a plain emoji list (no borders/cards/hover) so it reads as
   examples, not a set of selectable options. */
.ctc-feedback-prompts {
    margin: 0 0 1rem 0;
    padding-inline-start: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.ctc-feedback-prompts li {
    display: flex;
    align-items: flex-start;
    gap: 0.55rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.ctc-feedback-emoji {
    flex-shrink: 0;
    font-size: 1rem;
    line-height: 1.45;
}

/* Reassurance line under the prompts — quieter than body copy. */
.widget-body .ctc-feedback-note {
    margin-bottom: 0;
    font-size: 0.8rem;
    font-style: italic;
}

.ctc-btn-gold {
    background: #eab308 !important;
    border-color: #eab308 !important;
    /* Dark text on the gold button — white on #eab308 is ≈2:1 contrast. */
    color: #422006 !important;
    box-shadow: 0 4px 15px -3px rgba(234, 179, 8, 0.4) !important;
}

.ctc-btn-gold:hover {
    box-shadow: 0 8px 20px -4px rgba(234, 179, 8, 0.6) !important;
}

/* Quiet text link below the upgrade button — deep-links to the
   PRO Features tab via the SPA's global hash-link interceptor. */
.ctc-pro-see-all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition-fast);
}

.ctc-pro-see-all:hover {
    color: var(--text);
    text-decoration: none;
}

/* wp-admin core puts a box-shadow ring on every a:focus; since the SPA doesn't
   reload, the link stays focused after a click and the ring lingers. Keep the
   ring for keyboard users only (matches reset.css focus-visible pattern). */
.ctc-pro-see-all:focus {
    box-shadow: none;
    outline: none;
}

.ctc-pro-see-all:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.ctc-pro-see-all .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    transition: transform 0.2s var(--ease-prism);
    --scale-x: 1;
    --translate-x: 0;
    transform: scaleX(var(--scale-x)) translateX(var(--translate-x));
}

.ctc-pro-see-all:hover .dashicons {
    --translate-x: 3px;
}

[dir="rtl"] .ctc-pro-see-all .dashicons {
    --scale-x: -1;
}
