/* ============================================================
   CSS — Phase 20: Decision Memory
   Semantic search panel, pattern intelligence cards,
   institutional advisor context, admin settings.
   ============================================================ */

/* ── SEARCH PANEL ──────────────────────────────────────────── */

.memory-search-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    height: 100vh;
    background: #1a1a1a;
    border-left: 1px solid #2a2a2a;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    transition: right 0.25s ease;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
}

.memory-search-panel.open {
    right: 0;
}

.memory-search-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #2a2a2a;
}

.memory-search-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: #f0f0f0;
}

.memory-search-title svg {
    stroke: #FF9500;
}

.memory-search-close {
    background: none;
    border: none;
    color: #8e8e93;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
}

.memory-search-close:hover {
    background: #2a2a2a;
    color: #f0f0f0;
}

.memory-search-input-wrap {
    display: flex;
    gap: 8px;
    padding: 16px 20px 8px;
}

.memory-search-input {
    flex: 1;
    background: #111;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 10px 14px;
    color: #f0f0f0;
    font-size: 13px;
    font-family: 'Inter', sans-serif;
    outline: none;
}

.memory-search-input:focus {
    border-color: #FF9500;
}

.memory-search-input::placeholder {
    color: #555;
}

.memory-search-btn {
    background: #FF9500;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
}

.memory-search-btn:hover {
    background: #e68600;
}

.memory-search-options {
    padding: 8px 20px;
    border-bottom: 1px solid #222;
}

.memory-search-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #8e8e93;
    cursor: pointer;
}

.memory-search-toggle input[type="checkbox"] {
    accent-color: #FF9500;
}

.memory-search-results {
    flex: 1;
    overflow-y: auto;
    padding: 12px 20px;
}

.memory-search-empty,
.memory-search-loading,
.memory-search-disabled {
    padding: 24px 20px;
    text-align: center;
    color: #8e8e93;
    font-size: 13px;
    line-height: 1.6;
}

.memory-search-disabled p:first-child {
    color: #aaa;
    font-size: 14px;
}

/* ── SEARCH RESULT CARDS ─────────────────────────────────── */

.memory-result-card {
    background: #222;
    border: 1px solid #333;
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.memory-result-card:hover {
    border-color: #FF9500;
    background: #252525;
}

.memory-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.memory-result-entity {
    font-size: 14px;
    font-weight: 600;
    color: #f0f0f0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 70%;
}

.memory-result-sim {
    font-size: 12px;
    font-weight: 600;
    color: #FF9500;
    background: #FF950015;
    padding: 2px 8px;
    border-radius: 12px;
}

.memory-result-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.memory-result-type {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.memory-result-stage {
    font-size: 11px;
    color: #8e8e93;
}

.memory-result-preview {
    font-size: 12px;
    color: #999;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── SIDEBAR SEARCH BUTTON ──────────────────────────────── */

.sidebar-memory-btn {
    position: relative;
}

.sidebar-memory-btn .memory-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 6px;
    height: 6px;
    background: #FF9500;
    border-radius: 50%;
}

/* ── PATTERN INTELLIGENCE (Analytics) ─────────────────────── */

.memory-pattern-disabled {
    padding: 24px;
    text-align: center;
    color: #8e8e93;
    font-size: 13px;
    background: #1a1a1a;
    border-radius: 10px;
    border: 1px dashed #333;
    margin-top: 12px;
}

.memory-pattern-loading {
    padding: 24px;
    text-align: center;
    color: #8e8e93;
    font-size: 13px;
    margin-top: 12px;
}

.memory-pattern-threshold {
    text-align: center;
    padding: 20px;
}

.memory-pattern-count {
    font-size: 28px;
    font-weight: 700;
    color: #FF9500;
}

.memory-pattern-threshold p {
    margin-top: 8px;
    font-size: 12px;
    color: #666;
}

.memory-pattern-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    margin-top: 12px;
}

.memory-pattern-card {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 10px;
    padding: 16px;
    transition: border-color 0.15s;
}

.memory-pattern-card:hover {
    border-color: #FF9500;
}

.memory-pattern-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.memory-pattern-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #FF950015;
    border-radius: 6px;
}

.memory-pattern-icon svg {
    stroke: #FF9500;
}

.memory-pattern-title {
    font-size: 13px;
    font-weight: 600;
    color: #f0f0f0;
    flex: 1;
}

.memory-pattern-entities {
    font-size: 11px;
    color: #8e8e93;
    background: #252525;
    padding: 2px 8px;
    border-radius: 12px;
    white-space: nowrap;
}

.memory-pattern-desc {
    font-size: 12px;
    color: #999;
    line-height: 1.6;
}

/* ── INSTITUTIONAL ADVISOR BADGE (Chat) ──────────────────── */

.memory-advisor-context {
    background: #1a1a1a;
    border: 1px solid #FF950030;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
    font-size: 12px;
    color: #999;
}

.memory-advisor-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: #FF9500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.memory-advisor-entity {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px solid #222;
}

.memory-advisor-entity:last-child {
    border-bottom: none;
}

.memory-advisor-entity-name {
    font-weight: 500;
    color: #ccc;
}

.memory-advisor-entity-meta {
    font-size: 11px;
    color: #666;
}

/* ── ADMIN SETTINGS ──────────────────────────────────────── */

#memorySettingsCard .status-active {
    background: #34C75920;
    color: #34C759;
}

#memorySettingsCard .status-inactive {
    background: #8e8e9320;
    color: #8e8e93;
}

.input-with-btn {
    display: flex;
    gap: 8px;
    align-items: center;
}

.input-with-btn .form-input {
    flex: 1;
}

.input-with-btn .btn-sm {
    background: #333;
    color: #aaa;
    border: 1px solid #444;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
}

.input-with-btn .btn-sm:hover {
    background: #444;
    color: #f0f0f0;
}

.memory-backfill-progress {
    color: #FF9500;
    font-weight: 500;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #FF9500;
}

/* ── ANA BADGE EXTENSIONS ────────────────────────────────── */

.ana-badge-count {
    font-size: 11px;
    color: #8e8e93;
    background: #252525;
    padding: 2px 10px;
    border-radius: 12px;
    margin-left: 8px;
}

/* ── HEADER MEMORY ICON ──────────────────────────────────── */

.header-memory-btn {
    background: none;
    border: 1px solid #333;
    border-radius: 8px;
    padding: 6px 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #999;
    font-size: 12px;
    font-weight: 500;
    transition: border-color 0.15s, color 0.15s;
}

.header-memory-btn:hover {
    border-color: #FF9500;
    color: #FF9500;
}

.header-memory-btn svg {
    width: 14px;
    height: 14px;
}

/* ── RESPONSIVE ──────────────────────────────────────────── */

@media (max-width: 768px) {
    .memory-search-panel {
        width: 100vw;
        right: -100vw;
    }
    .memory-pattern-grid {
        grid-template-columns: 1fr;
    }
}
