/* =====================================================
   BRDb Command Palette — CSS condiviso
   Usato da index.html, profile.html, altre pagine
   ===================================================== */

/* --- Trigger (fake input) --- */
/* Fake input che apre il modal */
.search { max-width: 480px; margin: 15px auto; position: relative; cursor: pointer; }
.search-fake-input { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: 25px; border: 1px solid var(--border); background: var(--card); color: var(--muted); font-size: 13px; font-family: 'Inter', sans-serif; transition: all 0.2s; user-select: none; }
.search-fake-input:hover { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 3px rgba(251,191,36,0.08); }
.search-fake-icon { flex-shrink: 0; color: var(--muted); }
.search-fake-placeholder { flex: 1; color: var(--muted); }
.search-fake-kbd { padding: 3px 7px; border-radius: 5px; border: 1px solid var(--border); background: rgba(255,255,255,0.03); font-size: 10px; font-family: 'Inter', sans-serif; color: var(--muted); font-weight: 600; }

/* ===== MODAL OVERLAY ===== */
.search-modal { position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.75); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); display: none; align-items: flex-start; justify-content: center; padding-top: 10vh; opacity: 0; transition: opacity 0.15s ease; }
.search-modal.active { display: flex; opacity: 1; }
.search-modal-panel { width: 100%; max-width: 640px; background: var(--card); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(251,191,36,0.1); overflow: hidden; transform: scale(0.96) translateY(-10px); transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1); }
.search-modal.active .search-modal-panel { transform: scale(1) translateY(0); }

/* Header con input */
.search-modal-header { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, rgba(251,191,36,0.04) 0%, transparent 100%); }
.search-modal-icon { color: var(--accent); flex-shrink: 0; }
.search-modal-header input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: 16px; font-family: 'Inter', sans-serif; font-weight: 500; }
.search-modal-header input::placeholder { color: var(--muted); }
.search-modal-close { background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; display: flex; align-items: center; justify-content: center; transition: all 0.15s; }
.search-modal-close:hover { background: rgba(255,255,255,0.05); color: var(--text); }

/* Risultati */
.search-modal-results { max-height: 50vh; overflow-y: auto; padding: 6px; }
.search-modal-results::-webkit-scrollbar { width: 8px; }
.search-modal-results::-webkit-scrollbar-track { background: transparent; }
.search-modal-results::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.search-modal-results::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* Empty state */
.search-modal-empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.search-modal-empty-icon { font-size: 40px; opacity: 0.5; margin-bottom: 12px; }
.search-modal-empty-text { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.search-modal-empty-hint { font-size: 11px; opacity: 0.7; }

/* Result item */
.search-modal-item { display: flex; align-items: center; gap: 14px; padding: 10px 14px; border-radius: 10px; cursor: pointer; text-decoration: none; color: var(--text); transition: all 0.1s; position: relative; }
.search-modal-item:hover, .search-modal-item.selected { background: linear-gradient(90deg, rgba(251,191,36,0.1) 0%, rgba(251,191,36,0.03) 100%); }
.search-modal-item.selected { box-shadow: inset 3px 0 0 var(--accent); }
.search-avatar { flex-shrink: 0; width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px; color: #000; }
.search-info { flex: 1; min-width: 0; }
.search-username { font-size: 14px; font-weight: 600; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-meta { font-size: 11px; color: var(--muted); display: flex; gap: 10px; align-items: center; }
.search-meta-badge { display: inline-flex; align-items: center; gap: 3px; }
.search-arrow { color: var(--muted); opacity: 0; transition: opacity 0.15s; flex-shrink: 0; }
.search-modal-item:hover .search-arrow, .search-modal-item.selected .search-arrow { opacity: 1; color: var(--accent); }

/* Highlight match */
.search-username mark { background: rgba(251,191,36,0.3); color: var(--accent); padding: 0 2px; border-radius: 3px; font-weight: 700; }

/* Footer */
.search-modal-footer { display: flex; gap: 20px; padding: 10px 18px; border-top: 1px solid var(--border); background: rgba(0,0,0,0.15); font-size: 11px; color: var(--muted); }
.search-modal-footer kbd { display: inline-block; padding: 2px 6px; border-radius: 4px; border: 1px solid var(--border); background: rgba(255,255,255,0.03); font-family: 'Inter', sans-serif; font-size: 10px; font-weight: 600; margin-right: 3px; }

/* ===== V2: layout split + chip + preview ===== */
.search-modal-panel-v2 { max-width: 920px; }

/* Chip filtri */
.search-filters { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 14px; border-bottom: 1px solid var(--border); background: rgba(0,0,0,0.1); }
.search-chip { padding: 5px 11px; border-radius: 16px; border: 1px solid var(--border); background: transparent; color: var(--muted); font-size: 11px; font-family: 'Inter', sans-serif; font-weight: 600; cursor: pointer; transition: all 0.15s; user-select: none; }
.search-chip:hover { border-color: var(--accent); color: var(--text); }
.search-chip.active { background: rgba(251,191,36,0.15); border-color: var(--accent); color: var(--accent); }
.search-chip-danger.active { background: rgba(239,68,68,0.15); border-color: #ef4444; color: #ef4444; }
.search-filter-status { margin-left: auto; color: var(--accent); font-weight: 600; }

/* Layout split */
.search-modal-body { display: grid; grid-template-columns: 1fr 380px; min-height: 320px; max-height: 60vh; }
.search-modal-body.no-preview { grid-template-columns: 1fr; }
.search-modal-results { max-height: 60vh; overflow-y: auto; padding: 6px; }

/* Preview panel */
.search-modal-preview { border-left: 1px solid var(--border); padding: 16px; overflow-y: auto; max-height: 60vh; background: rgba(0,0,0,0.1); }
.search-modal-preview::-webkit-scrollbar { width: 6px; }
.search-modal-preview::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.search-preview-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; min-height: 280px; color: var(--muted); text-align: center; padding: 20px; }
.search-preview-empty-icon { font-size: 42px; opacity: 0.4; margin-bottom: 12px; }
.search-preview-empty-text { font-size: 12px; }

.search-preview-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.search-preview-avatar { width: 56px; height: 56px; border-radius: 14px; display: flex; align-items: center; justify-content: center; font-size: 22px; font-weight: 700; color: #000; flex-shrink: 0; box-shadow: 0 4px 12px rgba(0,0,0,0.3); }
.search-preview-name { font-size: 17px; font-weight: 700; margin-bottom: 2px; }
.search-preview-uid { font-size: 11px; color: var(--muted); font-family: monospace; }

.search-preview-score { display: flex; align-items: baseline; gap: 8px; margin-bottom: 14px; }
.search-preview-score-val { font-size: 32px; font-weight: 900; font-family: 'Orbitron', sans-serif; color: var(--accent); line-height: 1; }
.search-preview-score-lbl { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

.search-preview-sparkline { margin-bottom: 14px; background: rgba(0,0,0,0.15); border-radius: 8px; padding: 8px; }
.search-preview-sparkline svg { display: block; width: 100%; height: 50px; }

.search-preview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 14px; }
.search-preview-stat { padding: 8px 10px; border-radius: 8px; background: rgba(0,0,0,0.15); }
.search-preview-stat-lbl { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 3px; }
.search-preview-stat-val { font-size: 13px; font-weight: 700; }
.search-preview-stat-val.green { color: #22c55e; }
.search-preview-stat-val.red { color: #ef4444; }
.search-preview-stat-val.gold { color: var(--accent); }

.search-preview-section-title { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; font-weight: 700; margin-bottom: 8px; margin-top: 14px; }

.search-preview-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 8px; }
.search-preview-badge { padding: 4px 9px; border-radius: 12px; font-size: 10px; font-weight: 700; background: rgba(251,191,36,0.15); color: var(--accent); border: 1px solid rgba(251,191,36,0.3); }
.search-preview-badge.pizza { background: rgba(245,158,11,0.15); color: #f59e0b; border-color: rgba(245,158,11,0.3); }

.search-preview-posts { display: flex; flex-direction: column; gap: 4px; }
.search-preview-post { font-size: 11px; color: var(--text); text-decoration: none; padding: 6px 8px; border-radius: 6px; background: rgba(0,0,0,0.15); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; transition: background 0.15s; }
.search-preview-post:hover { background: rgba(251,191,36,0.1); color: var(--accent); }

.search-preview-cta { display: block; margin-top: 14px; padding: 10px; text-align: center; border-radius: 10px; background: var(--accent); color: #000; font-weight: 700; font-size: 12px; text-decoration: none; transition: all 0.15s; }
.search-preview-cta:hover { filter: brightness(1.1); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(251,191,36,0.3); }

/* Mobile: nasconde preview */
@media (max-width: 700px) {
    .search-modal { padding-top: 0; }
    .search-modal-panel { max-width: 100%; height: 100vh; border-radius: 0; border: none; }
    .search-modal-body { grid-template-columns: 1fr; max-height: none; }
    .search-modal-preview { display: none; }
    .search-modal-results { max-height: calc(100vh - 180px); }
    .search-fake-kbd { display: none; }
    .search-filters { overflow-x: auto; flex-wrap: nowrap; }
    .search-chip { flex-shrink: 0; }
}

.stats-bar { display: flex; justify-content: center; gap: 30px; padding: 15px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin: 15px 0; flex-wrap: wrap; }
.stat { text-align: center; }
.stat-val { font-family: 'Orbitron', sans-serif; font-size: 22px; font-weight: 900; color: var(--accent); }
.stat-lbl { font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

.section-title { font-size: 16px; font-weight: 800; color: var(--accent); text-align: center; margin: 25px 0 15px; text-transform: uppercase; letter-spacing: 2px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.section-title svg { width: 12px; height: 12px; fill: #94a3b8; }

.brdb-table { width: 100%; border-collapse: collapse; }
.brdb-table th { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); font-weight: 700; }
.brdb-table td { padding: 10px 12px; border-bottom: 1px solid rgba(255,255,255,0.03); font-size: 13px; }
.brdb-table tr:hover td { background: rgba(255,255,255,0.03); }
.brdb-table a { color: var(--text); text-decoration: none; }
.brdb-table a:hover { color: var(--accent); }
.brdb-rank { font-family: 'Orbitron', sans-serif; font-weight: 900; color: var(--muted); width: 40px; }
.brdb-rank-1 { color: var(--accent); font-size: 16px; }
.brdb-rank-2 { color: #c0c0c0; font-size: 15px; }
.brdb-rank-3 { color: #cd7f32; font-size: 14px; }
.brdb-score { font-family: 'Orbitron', sans-serif; font-weight: 900; color: var(--accent); font-size: 18px; }
.brdb-user { font-weight: 700; }
.brdb-uid { font-size: 10px; color: var(--muted); }
.brdb-posts, .brdb-merits { font-size: 12px; color: var(--muted); text-align: right; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-top: 20px; }

/* Responsive per Top Merit + Top Activity */
@media (max-width: 700px) {
    #topMeritContent { grid-template-columns: 1fr !important; gap: 15px !important; }
    #topActivityContent { grid-template-columns: 1fr !important; gap: 15px !important; }
    #topReceiversList, #topSendersList, #topBoardsList, #topTopicsList {
        max-height: 250px;
        overflow-y: auto;
    }
    #topTopicsList div a {
        max-width: 200px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        display: block;
    }
}
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }
.card { background: var(--card); border-radius: 14px; padding: 18px; border: 1px solid var(--border); }
.card-title { font-size: 12px; font-weight: 800; color: var(--accent); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 1px; display: flex; align-items: center; gap: 6px; }
.card-title svg { width: 10px; height: 10px; fill: #94a3b8; flex-shrink: 0; }
.mini-list { display: flex; flex-direction: column; gap: 4px; }
.mini-item { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; font-size: 11px; }
.mini-item:hover { background: rgba(255,255,255,0.03); }
.mini-item a { color: var(--text); text-decoration: none; flex: 1; font-weight: 600; }
.mini-item a:hover { color: var(--accent); }
.mini-val { font-weight: 800; color: var(--accent); font-size: 12px; }
.mini-rank { font-family: 'Orbitron', sans-serif; font-weight: 900; color: var(--muted); min-width: 25px; text-align: center; font-size: 11px; }

.loading { text-align: center; padding: 30px; color: var(--muted); font-size: 13px; }
.spinner { display: inline-block; width: 30px; height: 30px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite; margin-bottom: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
.search-result-item { display: flex; align-items: center; gap: 15px; padding: 10px 14px; border-radius: 10px; background: var(--card); border: 1px solid var(--border); margin-bottom: 3px; text-decoration: none; color: var(--text); }
    

/* ═══════════════════════════════════════════════════════
   MOBILE RESPONSIVE FIX
   ═══════════════════════════════════════════════════════ */
@media (max-width: 768px) {
    /* Container fullscreen su mobile */
    .container { max-width: 100% !important; padding: 10px !important; }
    
    /* Stats bar: gap ridotto, font ridotto */
    .stats-bar { 
        gap: 15px !important; 
        padding: 10px 0 !important;
        flex-wrap: wrap !important;
    }
    .stat { 
        flex: 1 1 30% !important;
        min-width: 0 !important;
    }
    .stat-val { 
        font-size: 16px !important; 
        line-height: 1.2 !important;
    }
    .stat-lbl { 
        font-size: 8px !important; 
        letter-spacing: 0.5px !important;
    }
    
    /* Tabelle: scroll orizzontale se serve */
    .brdb-table { font-size: 11px !important; }
    .brdb-table th { 
        font-size: 9px !important; 
        padding: 6px 4px !important;
        letter-spacing: 0.5px !important;
    }
    .brdb-table td { 
        padding: 8px 4px !important; 
        font-size: 12px !important;
    }
    .brdb-rank { width: 25px !important; font-size: 11px !important; }
    .brdb-rank-1 { font-size: 13px !important; }
    .brdb-rank-2 { font-size: 12px !important; }
    .brdb-rank-3 { font-size: 12px !important; }
    .brdb-score { font-size: 14px !important; }
    .brdb-user { font-size: 13px !important; }
    .brdb-uid { font-size: 9px !important; }
    .brdb-posts, .brdb-merits { font-size: 11px !important; }
    
    /* Header: logo più piccolo */
    .logo { font-size: 28px !important; }
    .subtitle { font-size: 9px !important; letter-spacing: 1.5px !important; }
    
    /* Search handled by modal mobile CSS */
    
    /* Section title */
    .section-title { 
        font-size: 14px !important; 
        letter-spacing: 1px !important;
        margin: 20px 0 12px !important;
    }
    
    /* Grid 2 colonne → 1 colonna */
    .grid-2 { grid-template-columns: 1fr !important; gap: 12px !important; }
    
    /* Top bar */
    .top-bar { padding: 3px 0 !important; }
    .theme-btn { padding: 6px 12px !important; font-size: 11px !important; }
    
    /* Overflow globale */
    body { overflow-x: hidden !important; }
}

/* Extra small (iPhone SE, ecc.) */
@media (max-width: 380px) {
    .stat-val { font-size: 14px !important; }
    .stat-lbl { font-size: 7px !important; }
    .brdb-table { font-size: 10px !important; }
    .brdb-table td { padding: 6px 3px !important; font-size: 11px !important; }
    .logo { font-size: 24px !important; }
}
