/* ==========================================================================
   UNLIMITS DESIGN SYSTEM • components/style.css
   ========================================================================== */

:root {
    --un-bg: #090a0c;
    --un-surface: #111317;
    --un-surface-hover: #16191f;
    --un-surface-subtle: #1a1e24;
    --un-border: rgba(255, 255, 255, 0.07);
    --un-border-focus: rgba(255, 255, 255, 0.16);
    --un-text-high: #fcfcfd;
    --un-text-med: #9ba1ad;
    --un-text-muted: #5e6472;
    --un-brand: #7b61ff;
    --un-brand-glow: rgba(123, 97, 255, 0.22);
    --un-brand-hover: #8f77ff;
    --un-accent-coral: #ff4757;

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-pill: 9999px;

    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --transition-fast: 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    --transition-normal: 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    -webkit-tap-highlight-color: transparent; 
}

html, body {
    background-color: var(--un-bg);
    color: var(--un-text-high);
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

body { 
    display: flex; 
    justify-content: center; 
    overflow-y: scroll; 
}

a { color: inherit; text-decoration: none; }
button, input, textarea { font-family: inherit; }

/* ==========================================================================
   LAYOUT PRINCIPAL
   ========================================================================== */
.app-container {
    width: 100%;
    max-width: 640px;
    min-height: 100vh;
    border-left: 1px solid var(--un-border);
    border-right: 1px solid var(--un-border);
    display: flex;
    flex-direction: column;
    position: relative;
    padding-bottom: 90px;
    background: linear-gradient(180deg, rgba(17, 19, 23, 0.4) 0%, rgba(9, 10, 12, 0.8) 100%);
}

/* ==========================================================================
   HEADER & NAVEGAÇÃO
   ========================================================================== */
header {
    position: sticky;
    top: 0;
    background: rgba(9, 10, 12, 0.85);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    z-index: 100;
    border-bottom: 1px solid var(--un-border);
}

.brand-bar {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-identity {
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}

.brand-logo-symbol {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: linear-gradient(135deg, #7b61ff 0%, #4f29f0 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px var(--un-brand-glow);
}

.brand-logo-symbol svg { width: 16px; height: 16px; fill: #fff; }

.brand-name {
    font-weight: 800;
    font-size: 17px;
    letter-spacing: 0.08em;
    color: var(--un-text-high);
    text-transform: uppercase;
}

/* Botão de Conta no Header */
.account-header-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--un-surface);
    border: 1px solid var(--un-border);
    padding: 4px 12px 4px 6px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.account-header-trigger:hover {
    border-color: var(--un-border-focus);
    background: var(--un-surface-hover);
}

.account-header-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--un-brand);
}

.account-header-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--un-text-high);
    max-width: 100px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.primary-navigation { display: flex; padding: 0 20px; gap: 8px; overflow-x: auto; }
.primary-navigation::-webkit-scrollbar { display: none; }

.nav-link {
    background: none;
    border: none;
    color: var(--un-text-muted);
    font-size: 14px;
    font-weight: 600;
    padding: 12px 14px;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
    transition: color var(--transition-fast);
}

.nav-link:hover { color: var(--un-text-med); }
.nav-link.active { color: var(--un-text-high); }

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 12px;
    right: 12px;
    height: 2.5px;
    background: var(--un-brand);
    border-radius: 4px 4px 0 0;
    box-shadow: 0 0 12px var(--un-brand);
}

.trending-filter-bar {
    display: none;
    padding: 10px 20px 14px 20px;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    background: rgba(13, 15, 18, 0.5);
}
.trending-filter-bar::-webkit-scrollbar { display: none; }
.trending-filter-bar.visible { display: flex; }

.period-chip {
    background: var(--un-surface);
    border: 1px solid var(--un-border);
    color: var(--un-text-muted);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    white-space: nowrap;
}
.period-chip.active {
    background: var(--un-surface-subtle);
    color: var(--un-text-high);
    border-color: rgba(255, 255, 255, 0.22);
}

/* ==========================================================================
   COMPOSER (TEXTO E ENQUETE)
   ========================================================================== */
.composer-section {
    padding: 18px 20px;
    border-bottom: 1px solid var(--un-border);
    background: rgba(17, 19, 23, 0.35);
}

.composer-mode-selector { display: flex; gap: 8px; margin-bottom: 14px; }
.composer-mode-btn {
    background: none;
    border: 1px solid var(--un-border);
    color: var(--un-text-muted);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    cursor: pointer;
}
.composer-mode-btn.active {
    background: var(--un-surface-subtle);
    color: var(--un-text-high);
    border-color: var(--un-brand);
}

.composer-layout { display: flex; gap: 14px; }

.author-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: var(--un-surface-subtle);
    border: 1px solid var(--un-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--un-text-med);
    flex-shrink: 0;
    object-fit: cover;
    cursor: pointer;
    overflow: hidden;
    transition: transform var(--transition-fast);
}
.author-avatar:hover { transform: scale(1.05); }

.composer-core { flex: 1; }
.composer-core textarea {
    width: 100%;
    background: transparent;
    border: none;
    outline: none;
    color: var(--un-text-high);
    font-size: 15px;
    line-height: 1.6;
    resize: none;
    margin-bottom: 10px;
    min-height: 44px;
}

.poll-inputs-container { display: none; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.poll-option-input {
    width: 100%;
    background: var(--un-surface);
    border: 1px solid var(--un-border);
    border-radius: var(--radius-md);
    padding: 9px 14px;
    color: var(--un-text-high);
    font-size: 13.5px;
    outline: none;
}
.btn-add-poll-option { 
    background: none; 
    border: none; 
    color: var(--un-brand); 
    font-size: 12.5px; 
    font-weight: 600; 
    cursor: pointer; 
    text-align: left; 
    padding: 4px 0; 
}

.composer-bottom { display: flex; justify-content: space-between; align-items: center; }
.visitor-context-tag { font-size: 12px; color: var(--un-text-muted); display: flex; align-items: center; gap: 6px; }

.btn-brand-action {
    background: var(--un-brand);
    color: #ffffff;
    border: none;
    padding: 8px 20px;
    border-radius: var(--radius-pill);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}
.btn-brand-action:hover:not(:disabled) { 
    background: var(--un-brand-hover); 
    box-shadow: 0 4px 14px var(--un-brand-glow); 
}
.btn-brand-action:disabled { opacity: 0.35; cursor: not-allowed; }

/* ==========================================================================
   FEED & CARDS
   ========================================================================== */
.feed-container { display: flex; flex-direction: column; }
.un-post-card { padding: 22px 20px; border-bottom: 1px solid var(--un-border); }
.card-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-meta-author { display: flex; align-items: center; gap: 10px; }
.meta-author-name { font-size: 14px; font-weight: 600; color: var(--un-text-high); }
.meta-timestamp { font-size: 12px; color: var(--un-text-muted); }

.heat-pill {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--un-border);
}

/* Enquetes */
.poll-card {
    border-left: 4px solid #7b61ff;
    background: var(--un-surface);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    margin: 10px 0 14px 0;
}
.poll-question-title { font-size: 15.5px; font-weight: 700; margin-bottom: 12px; }
.poll-options-group { display: flex; flex-direction: column; gap: 8px; }
.poll-option-item {
    position: relative;
    background: var(--un-surface-subtle);
    border: 1px solid var(--un-border);
    border-radius: var(--radius-md);
    padding: 11px 16px;
    cursor: pointer;
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.poll-progress-bar {
    position: absolute; left: 0; top: 0; bottom: 0;
    background: rgba(123, 97, 255, 0.25);
    border-right: 2px solid var(--un-brand);
    transition: width 0.6s var(--ease-out);
    z-index: 1;
}
.poll-opt-text { position: relative; z-index: 2; font-size: 13.5px; }
.poll-opt-pct { position: relative; z-index: 2; font-size: 12.5px; font-weight: 700; color: var(--un-text-med); }

/* Trecho Editorial */
.editorial-snippet {
    font-family: 'Newsreader', Georgia, serif;
    font-size: 17.5px;
    line-height: 1.55;
    font-style: italic;
    padding: 16px 18px;
    border-radius: var(--radius-md);
    margin: 10px 0 12px 0;
    cursor: pointer;
    background: var(--un-surface);
    border-left: 4px solid #ffd54f;
}

.origin-link-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--un-text-med);
    background: var(--un-surface);
    border: 1px solid var(--un-border);
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    margin-bottom: 10px;
}

.post-content, .comment-content-text { 
    font-size: 15px; 
    line-height: 1.65; 
    margin: 8px 0 12px 0; 
    word-break: break-word; 
}

/* ==========================================================================
   COMPORTAMENTO DE SELEÇÃO: DESKTOP VS MOBILE
   ========================================================================== */
@media (min-width: 601px) {
    .post-content, .comment-content-text { user-select: text !important; cursor: text; }
    .btn-select-mode { display: none !important; }
    #select-action-bar { display: none !important; }
}

@media (max-width: 600px) {
    .post-content.selecting, .comment-content-text.selecting { user-select: none !important; }
    .word { display: inline-block; padding: 1px 2px; border-radius: 4px; cursor: pointer; }
    .word.word-hl { background: #ffd54f !important; color: #111 !important; }
    #snippet-bubble { display: none !important; }
}

.btn-select-mode {
    background: var(--un-surface);
    border: 1px solid var(--un-border);
    color: var(--un-text-muted);
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    cursor: pointer;
}

.stf-highlight {
    padding: 2px 5px;
    border-radius: 4px;
    cursor: pointer;
    display: inline;
    position: relative;
    font-weight: 500;
}

/* Ações Inferiores do Card */
.card-bottom-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; }
.actions-left-group { display: flex; align-items: center; gap: 16px; }

.card-action-btn {
    background: none;
    border: none;
    color: var(--un-text-muted);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
}
.card-action-btn.liked { color: var(--un-accent-coral); }
.card-action-btn.liked svg { fill: var(--un-accent-coral); stroke: var(--un-accent-coral); }

/* ==========================================================================
   BOTÃO "VER CONTEXTO COMPLETO" (ESTILIZAÇÃO DE LUXO CORRIGIDA)
   ========================================================================== */
.btn-view-context {
    font-family: inherit;
    font-size: 11.5px;
    font-weight: 600;
    color: var(--un-text-med);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--un-border);
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all var(--transition-fast);
    text-decoration: none;
    white-space: nowrap;
}

.btn-view-context:hover {
    color: var(--un-text-high);
    border-color: var(--un-border-focus);
    background: var(--un-surface-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* ==========================================================================
   BOTÃO FLUTUANTE & SELEÇÃO
   ========================================================================== */
#snippet-bubble {
    position: fixed !important;
    display: none;
    z-index: 100000;
    background: #ffffff;
    color: #000000;
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-pill);
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    transform: translate(-50%, -100%);
}

#select-action-bar {
    position: fixed; left: 0; right: 0; bottom: 0;
    display: none; z-index: 100000;
    background: var(--un-surface);
    border-top: 1px solid var(--un-border);
    padding: 12px 18px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
}
#select-action-bar.visible { display: flex; flex-direction: column; gap: 8px; }
.select-bar-preview { font-size: 12.5px; color: var(--un-text-muted); }
.select-bar-buttons { display: flex; gap: 8px; justify-content: flex-end; }
.btn-cancel-select { 
    background: transparent; 
    border: 1px solid var(--un-border); 
    color: var(--un-text-med); 
    padding: 6px 14px; 
    border-radius: var(--radius-pill); 
    font-size: 12px; 
    cursor: pointer; 
}

/* ==========================================================================
   MODAL / DRAWER
   ========================================================================== */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8); backdrop-filter: blur(8px);
    display: none; align-items: flex-end; justify-content: center; z-index: 10000;
}
@media (min-width: 601px) { .modal-overlay { align-items: center; } }

.modal-window {
    background: #0f1115; border: 1px solid var(--un-border); width: 100%;
    max-width: 580px; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    max-height: 85vh; display: flex; flex-direction: column; overflow: hidden;
}
@media (min-width: 601px) { .modal-window { border-radius: var(--radius-lg); width: 95%; } }

.modal-top { padding: 14px 18px; border-bottom: 1px solid var(--un-border); display: flex; justify-content: space-between; align-items: center; }
.modal-title-text { font-weight: 700; font-size: 14px; }
.modal-close-trigger { background: none; border: none; color: var(--un-text-muted); font-size: 20px; cursor: pointer; }
.modal-scroll-area { padding: 18px; overflow-y: auto; flex: 1; }

.thread-sorting-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; margin-bottom: 10px; border-bottom: 1px solid var(--un-border); padding-bottom: 8px; }
.thread-tabs-switch { display: flex; gap: 4px; background: var(--un-surface); padding: 3px; border-radius: var(--radius-pill); border: 1px solid var(--un-border); }
.thread-tab-btn { background: none; border: none; color: var(--un-text-muted); font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: var(--radius-pill); cursor: pointer; }
.thread-tab-btn.active { background: var(--un-surface-subtle); color: var(--un-text-high); }

.thread-replies-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.thread-item-card { background: var(--un-surface); border: 1px solid var(--un-border); border-radius: var(--radius-md); padding: 12px 14px; }
.thread-item-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.thread-item-author { font-size: 13px; font-weight: 600; }
.thread-item-date { font-size: 11px; color: var(--un-text-muted); }
.thread-subreplies-tree { list-style: none; margin-top: 8px; padding-left: 12px; border-left: 2px solid var(--un-surface-subtle); display: flex; flex-direction: column; gap: 6px; }
.thread-subreply-item { background: rgba(255, 255, 255, 0.02); padding: 8px 10px; border-radius: var(--radius-sm); border: 1px solid var(--un-border); }

.reply-banner { background: var(--un-surface-subtle); padding: 6px 18px; font-size: 12px; color: var(--un-text-med); display: none; justify-content: space-between; }
.modal-bottom-input-bar { padding: 12px 18px; border-top: 1px solid var(--un-border); display: flex; gap: 8px; background: #0f1115; }
.modal-bottom-input-bar input { flex: 1; background: var(--un-surface); border: 1px solid var(--un-border); border-radius: var(--radius-pill); padding: 9px 16px; color: #fff; outline: none; font-size: 13px; }

.origin-context-container { background: var(--un-surface); border: 1px solid var(--un-border); border-radius: var(--radius-md); padding: 12px; margin-bottom: 12px; }
.origin-badge-label { font-size: 10px; font-weight: 700; text-transform: uppercase; margin-bottom: 4px; }
.origin-badge-label.external { color: #38bdf8; }
.origin-badge-label.internal { color: #f59e0b; }
.origin-headline-anchor { color: #fff; font-weight: 600; font-size: 13px; }
.origin-quote-excerpt { background: var(--un-bg); padding: 10px; border-radius: 6px; font-size: 12.5px; color: var(--un-text-med); margin-top: 6px; border-left: 3px solid var(--un-brand); }
.context-highlight-match { background: rgba(123, 97, 255, 0.3); color: #fff; font-weight: 600; padding: 1px 3px; border-radius: 2px; }

.state-notice { text-align: center; padding: 48px 24px; color: var(--un-text-muted); font-size: 14px; }