/* ===========================================================
   Personal Content Filter — modal + toolbar button
   Palette mirrors .sa-* Settings modal + .stufferai-modal.
   =========================================================== */

/* ----------  Toolbar trigger button  ---------- */
.cf-toolbar-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 30px;
    width: 30px;
    padding: 0;
    background: transparent;
    border: none;
    color: #e5e7eb;
    cursor: pointer;
    border-radius: 4px;
    transition: color 0.18s ease, background-color 0.18s ease, transform 0.12s ease;
}
.cf-toolbar-btn:hover { color: #fff; background: rgba(255,255,255,0.04); }
.cf-toolbar-btn:active { transform: scale(0.96); }
.cf-toolbar-btn i { font-size: 13px; line-height: 1; }
.cf-toolbar-btn.cf-active {
    color: #dbeafe;
    background: rgba(59,130,246,0.14);
}

.cf-badge {
    position: absolute;
    top: -2px;
    right: -4px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: #3b82f6;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    box-shadow: 0 0 0 2px #444; /* matches .toolbar-item bg */
    pointer-events: none;
}

/* ----------  Modal shell (reuses .stufferai-modal base)  ---------- */
#contentFilterModal.stufferai-modal.active { display: block; }

#contentFilterModal .stufferai-modal-content {
    max-width: 640px;
    width: 94%;
    max-height: 86vh;
    padding: 0;
    overflow: hidden;
    background: #1a1a1a;
    border: 1px solid #2a2c33;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5), 0 2px 0 rgba(255,255,255,0.02) inset;
}

.cf-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px 14px;
    border-bottom: 1px solid #25272d;
}
.cf-modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.1px;
}
.cf-modal-title i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, #3b82f6 0%, #1e40af 100%);
    color: #fff;
    font-size: 13px;
    box-shadow: 0 4px 12px rgba(59,130,246,0.22);
}
.cf-modal-subtitle {
    margin: 2px 0 0 38px;
    font-size: 12px;
    color: #9ca3af;
    font-weight: 400;
}
.cf-close-btn {
    background: transparent;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    color: #9ca3af;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transition: background 0.18s ease, color 0.18s ease;
}
.cf-close-btn:hover { background: #2a2c33; color: #fff; }

/* ----------  Guest banner (mimics .sa-alert)  ---------- */
.cf-guest-banner {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin: 12px 20px 0;
    padding: 10px 12px;
    background: linear-gradient(180deg, rgba(122,92,42,0.35), rgba(58,47,25,1));
    border: 1px solid #7a5c2a;
    border-radius: 10px;
    color: #ffe0a3;
    font-size: 12.5px;
    line-height: 1.45;
}
.cf-guest-banner i { margin-top: 1px; color: #f4b740; }
.cf-guest-banner strong { color: #ffeec5; }
.cf-guest-banner a {
    color: #ffeec5;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}
.cf-guest-banner a:hover { color: #fff; }

/* ----------  Tab switcher  ---------- */
.cf-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 20px 0;
}
.cf-tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 10px;
    background: #22252b;
    color: #cbd5e1;
    border: 1px solid #2e3138;
    border-radius: 9px;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0.15px;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.12s ease;
}
.cf-tab i { font-size: 11px; opacity: 0.85; }
.cf-tab:hover { background: #2c2f36; color: #fff; border-color: #3a3f48; }
.cf-tab:active { transform: scale(0.99); }
.cf-tab.cf-tab-active {
    background: linear-gradient(180deg, #3b3f4a 0%, #2c303a 100%);
    color: #fff;
    border-color: #4b5160;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25), 0 0 0 1px rgba(59,130,246,0.15) inset;
}
.cf-tab.cf-tab-active i { color: #93c5fd; opacity: 1; }

/* ----------  Body  ---------- */
.cf-body {
    padding: 14px 20px 12px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}
.cf-pane { display: none; }
.cf-pane.cf-pane-active {
    display: block;
    animation: cfFadeIn 220ms ease-out;
}
@keyframes cfFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.cf-description {
    margin: 2px 0 12px;
    font-size: 12.5px;
    color: #a3a9b5;
    line-height: 1.5;
}
.cf-description strong { color: #e5e7eb; font-weight: 600; }

/* ----------  Add-word row  ---------- */
.cf-add-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
    margin-bottom: 12px;
}
/* Specific selector + !important to defeat the global input[type=text] { float:right; width:122px; height:35px } rule in home.css */
input.cf-input,
.cf-add-row input.cf-input,
.cf-search-row input.cf-input {
    display: block;
    float: none !important;
    width: 100% !important;
    box-sizing: border-box;
    height: auto !important;
    flex: 1 1 auto;
    min-width: 0;
    background: #121318;
    color: #e5e7eb;
    border: 1px solid #3a3b40;
    border-radius: 9px;
    padding: 9px 12px;
    font-size: 13px !important;
    font-family: inherit;
    box-shadow: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.cf-add-row { display: flex; }
.cf-search-row { display: block; }
.cf-search-row input.cf-input { padding-left: 34px !important; }
.cf-input::placeholder { color: #6b7280; }
.cf-input:focus {
    outline: none;
    border-color: #3b82f6;
    background: #0f1014;
    box-shadow: 0 0 0 3px rgba(59,130,246,0.18);
}
.cf-add-btn {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #3b82f6;
    color: #fff;
    border: 1px solid #3b82f6;
    border-radius: 9px;
    padding: 8px 14px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.12s ease, box-shadow 0.18s ease;
}
.cf-add-btn:hover { background: #2563eb; box-shadow: 0 6px 16px rgba(59,130,246,0.28); }
.cf-add-btn:active { transform: scale(0.98); }
.cf-add-btn:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

/* ----------  Chip grid  ---------- */
.cf-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 0 2px;
    min-height: 24px;
}
.cf-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 5px 5px 11px;
    background: #2a2c33;
    color: #e5e7eb;
    border: 1px solid #3a3b40;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    animation: cfChipIn 140ms cubic-bezier(0.2, 0.8, 0.2, 1);
    transition: background 0.18s ease, border-color 0.18s ease;
}
.cf-chip:hover { background: #2f313a; border-color: #454952; }
.cf-chip-label { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cf-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    font-size: 10px;
    line-height: 1;
    transition: background 0.15s ease, color 0.15s ease;
}
.cf-chip-remove:hover { background: #7a3a3a; color: #fecaca; }
@keyframes cfChipIn {
    from { opacity: 0; transform: scale(0.88); }
    to   { opacity: 1; transform: scale(1); }
}
.cf-chips-empty {
    font-size: 12px;
    color: #6b7280;
    padding: 4px 2px;
    font-style: italic;
}

/* ----------  Search (Tab 2)  ---------- */
.cf-search-row {
    position: relative;
    margin-bottom: 10px;
}
.cf-search-row .cf-input { padding-left: 34px; }
.cf-search-row i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #6b7280;
    font-size: 12px;
    pointer-events: none;
}

/* ----------  Global list with toggles  ---------- */
.cf-global-list {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid #2a2c33;
    border-radius: 10px;
    background: #141519;
    padding: 4px;
}
.cf-global-list::-webkit-scrollbar { width: 10px; }
.cf-global-list::-webkit-scrollbar-track { background: transparent; }
.cf-global-list::-webkit-scrollbar-thumb { background: #2a2c33; border-radius: 999px; border: 2px solid #141519; }
.cf-global-list::-webkit-scrollbar-thumb:hover { background: #3a3b40; }

.cf-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 0.15s ease;
}
.cf-row:hover { background: #1b1d22; }
.cf-row-label {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    flex: 1;
}
.cf-row-word {
    color: #e5e7eb;
    font-size: 13px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cf-row-hint {
    color: #6b7280;
    font-size: 11px;
    font-style: italic;
}
.cf-row.cf-row-whitelisted .cf-row-word { color: #93c5fd; }
.cf-row.cf-row-whitelisted .cf-row-hint::after { content: " · visible to you"; color: #60a5fa; }
.cf-empty-search {
    color: #6b7280;
    font-size: 12px;
    font-style: italic;
    padding: 18px;
    text-align: center;
}

/* ----------  iOS-style toggle  ---------- */
.cf-toggle {
    position: relative;
    width: 40px;
    height: 22px;
    flex: 0 0 auto;
}
.cf-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.cf-toggle-track {
    position: absolute;
    inset: 0;
    background: #2a2c33;
    border: 1px solid #3a3b40;
    border-radius: 999px;
    transition: background 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.22s ease;
    cursor: pointer;
}
.cf-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: #cbd5e1;
    border-radius: 999px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.4);
    transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.22s ease;
}
/* ON = hidden (default for global words) */
.cf-toggle input:checked + .cf-toggle-track {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    border-color: #1d4ed8;
}
.cf-toggle input:checked + .cf-toggle-track .cf-toggle-thumb {
    transform: translateX(18px);
    background: #fff;
}
.cf-toggle input:focus-visible + .cf-toggle-track {
    box-shadow: 0 0 0 3px rgba(59,130,246,0.25);
}

/* ----------  Footer  ---------- */
.cf-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 20px 16px;
    border-top: 1px solid #25272d;
    background: linear-gradient(180deg, transparent, rgba(0,0,0,0.25));
}
.cf-stats {
    font-size: 12px;
    color: #9ca3af;
}
.cf-stats strong { color: #e5e7eb; font-weight: 600; }
.cf-stats .cf-count-hidden { color: #fca5a5; }
.cf-stats .cf-count-shown  { color: #93c5fd; }
.cf-footer-actions { display: flex; gap: 8px; }
.cf-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #2a2c33;
    color: #e5e7eb;
    border: 1px solid #3a3b40;
    border-radius: 9px;
    padding: 8px 14px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, transform 0.12s ease;
}
.cf-btn:hover { background: #343744; border-color: #4b5160; }
.cf-btn:active { transform: scale(0.98); }
.cf-btn-primary {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    border-color: #1d4ed8;
}
.cf-btn-primary:hover {
    background: linear-gradient(180deg, #4f8ef7 0%, #1d4ed8 100%);
    box-shadow: 0 6px 16px rgba(59,130,246,0.26);
}
.cf-btn-ghost { background: transparent; color: #9ca3af; border-color: transparent; }
.cf-btn-ghost:hover { background: #22252b; color: #e5e7eb; }

/* ----------  Toast  ---------- */
.cf-toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translate(-50%, 24px);
    background: #1a1a1a;
    color: #e5e7eb;
    border: 1px solid #3a3b40;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 12.5px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.28s ease;
    z-index: 10000;
    box-shadow: 0 12px 32px rgba(0,0,0,0.6);
}
.cf-toast.cf-toast-visible {
    opacity: 1;
    transform: translate(-50%, 0);
    pointer-events: auto;
}
.cf-toast i { color: #10b981; font-size: 12px; }

/* ----------  Mobile  ---------- */
@media (max-width: 640px) {
    #contentFilterModal .stufferai-modal-content {
        width: 100vw;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        border-left: none;
        border-right: none;
        transform: none !important;
        top: 0 !important;
        left: 0 !important;
    }
    #contentFilterModal.active .stufferai-modal-content {
        transform: none !important;
    }
    .cf-modal-header { padding: 14px 16px 10px; }
    .cf-tabs { padding: 10px 16px 0; }
    .cf-body { padding: 12px 16px 10px; }
    .cf-footer { padding: 10px 16px 14px; flex-direction: column; align-items: stretch; }
    .cf-footer-actions { justify-content: flex-end; }
    .cf-stats { text-align: center; }
    .cf-global-list { max-height: 48vh; }
    .cf-tab { font-size: 12px; padding: 10px 6px; }
}
