
:root {
    /* --- Feed System Variables (Scoped) --- */
    --feed-primary: #3b82f6; /* Blue 500 */
    --feed-primary-hover: #2563eb; /* Blue 600 */
    --feed-text-main: #1e293b; /* Slate 800 */
    --feed-text-secondary: #64748b; /* Slate 500 */
    --feed-bg-body: #f8fafc; /* Slate 50 */
    --feed-bg-card: #ffffff;
    --feed-border: #e2e8f0; /* Slate 200 */
    --feed-danger: #ef4444; /* Red 500 */
    --feed-success: #10b981; /* Green 500 */
    --feed-focus-ring: rgba(59, 130, 246, 0.25);
    --feed-radius: 16px;
    --feed-shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
    --feed-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --feed-shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.01);

    /* Variáveis do Sistema Principal */
    --bs-blue: #1e88e5;
    --bs-dark: #0f172a;
    --sidebar-width: 280px;
    --header-height: 70px;
}
/* =========================================
   FEED COMPONENT STYLES (feed-*)
   ========================================= */

        .feed-wrapper { max-width: 720px; margin: 0 auto; padding: 1rem 1rem; }
        @media (max-width: 576px) { .feed-wrapper { padding: 1rem 0; } }

        /* Cards Base */
        .feed-create-box, .feed-post {
            background: var(--feed-bg-card);
            border: 1px solid var(--feed-border);
            border-radius: var(--feed-radius);
            box-shadow: var(--feed-shadow-sm);
            transition: all 0.2s ease;
            margin-bottom: 1.5rem;
            position: relative; 
            z-index: 1; 
        }

        .feed-create-box:focus-within {
            border-color: var(--feed-primary);
            box-shadow: 0 0 0 4px var(--feed-focus-ring);
            z-index: 10; 
        }
        
        .feed-input {
            resize: none; font-size: 1rem; min-height: 60px; transition: min-height 0.2s;
            background: transparent; color: var(--feed-text-main); border: none; width: 100%;
        }
        .feed-input:focus { outline: none; min-height: 100px; }
        .feed-input::placeholder { color: var(--feed-text-secondary); }

        /* Tools */
        .feed-btn-tool {
            color: var(--feed-text-secondary); padding: 8px 14px; border-radius: 99px;
            font-size: 0.9rem; font-weight: 600; transition: all 0.2s; border: 1px solid transparent; background: transparent;
        }
        .feed-btn-tool:hover { background: #eff6ff; color: var(--feed-primary); border-color: #dbeafe; }
        .feed-btn-tool i { margin-right: 6px; }

        /* Post Card Hover / Foco */
        .feed-post:hover, .feed-post:focus-within {
            box-shadow: var(--feed-shadow-lg); 
            transform: translateY(-2px); 
            border-color: #cbd5e1;
            z-index: 10; 
        }

        /* CORREÇÃO: Garante que os dropdowns não ficam escondidos atrás dos cards seguintes */
        .feed-create-box:has(.show), 
        .feed-post:has(.show), 
        .pinned-box:has(.show) {
            z-index: 50 !important;
        }

        /* Post Header */
        .feed-avatar {
            width: 44px; height: 44px; border-radius: 50%; object-fit: cover;
            border: 2px solid #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
        .feed-meta h6 { font-weight: 600; color: var(--feed-text-main); font-size: 0.95rem; margin: 0; }
        .feed-meta small { color: var(--feed-text-secondary); font-size: 0.8rem; font-weight: 500; }
        .feed-content {
            color: #334155; font-size: 1rem; line-height: 1.6; white-space: pre-wrap;
            margin-top: 8px; margin-bottom: 16px;
        }

        /* Pinned Box Container */
        .pinned-box {
            background: var(--feed-bg-card);
            border: 1px solid var(--feed-border);
            border-radius: var(--feed-radius);
            box-shadow: var(--feed-shadow-sm);
            transition: all 0.2s ease;
            margin-bottom: 1.5rem;
            position: relative;
            z-index: 2; 
        }

        /* Pinned Posts Carousel (ESTILO COMPACTO) */
        .pinned-carousel-wrapper {
            display: flex;
            overflow-x: auto;
            gap: 1rem;
            padding-bottom: 1rem;
            scroll-behavior: smooth;
            scroll-snap-type: x mandatory;
            -webkit-overflow-scrolling: touch;
            scrollbar-width: thin;
            scrollbar-color: #cbd5e1 transparent;
        }
        .pinned-carousel-wrapper::-webkit-scrollbar { height: 6px; }
        .pinned-carousel-wrapper::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 10px; }
        
        .feed-pinned-compact {
            min-width: 280px;
            max-width: 320px;
            scroll-snap-align: center;
            flex-shrink: 0;
            margin-bottom: 0;
            box-shadow: var(--feed-shadow-sm);
            cursor: pointer;
            transition: all 0.2s ease;
        }
        @media (max-width: 576px) {
            .feed-pinned-compact { min-width: 85%; }
        }
        .feed-pinned-compact:hover {
            box-shadow: var(--feed-shadow-md);
            background-color: #f8fafc;
            transform: translateY(-2px);
        }
        .pinned-media-icons {
            display: flex;
            gap: 10px;
            margin-top: 8px;
            padding-top: 8px;
            border-top: 1px solid var(--feed-border);
            color: var(--feed-text-secondary);
        }

        /* Loading Skeleton Styles */
        .feed-post-skeleton {
            background: var(--feed-bg-card);
            border: 1px solid var(--feed-border);
            border-radius: var(--feed-radius);
            padding: 1.5rem;
            margin-bottom: 1.5rem;
        }
        .skeleton {
            background-color: #e2e8f0;
            position: relative;
            overflow: hidden;
        }
        .skeleton::after {
            content: "";
            position: absolute;
            top: 0; right: 0; bottom: 0; left: 0;
            transform: translateX(-100%);
            background-image: linear-gradient(90deg, rgba(255,255,255,0) 0, rgba(255,255,255,0.4) 20%, rgba(255,255,255,0.7) 60%, rgba(255,255,255,0));
            animation: shimmer 1.5s infinite;
        }
        @keyframes shimmer { 100% { transform: translateX(100%); } }
        
        .sk-avatar { width: 44px; height: 44px; border-radius: 50%; }
        .sk-line { height: 12px; border-radius: 4px; margin-bottom: 8px; }
        .sk-line.short { width: 30%; }
        .sk-line.medium { width: 60%; }
        .sk-media { width: 100%; height: 200px; border-radius: 8px; margin-top: 12px; }

        /* Media Container */
        .feed-media-wrapper {
            border-radius: var(--feed-radius); overflow: hidden;
            border: 1px solid var(--feed-border); background: #0f172a; position: relative;
            margin-bottom: 1rem;
        }
        
        /* Carousel Overrides for Feed */
        .feed-media-wrapper .carousel-item { background-color: #000; text-align: center; }
        .feed-media-wrapper .carousel-item img, 
        .feed-media-wrapper .carousel-item video {
            width: 100%; max-height: 500px; object-fit: contain; object-position: center;
        }
        .feed-audio-slide {
            width: 100%; height: 300px; display: flex; flex-direction: column;
            align-items: center; justify-content: center;
            background: radial-gradient(circle at center, #334155 0%, #0f172a 100%); color: white;
        }
        
        /* Estilos do Carousel Indicators */
        .feed-media-wrapper .carousel-indicators {
            position: absolute;
            right: 0;
            bottom: 0;
            left: 0;
            z-index: 2;
            display: flex;
            justify-content: center;
            padding: 0;
            margin-right: 15%;
            margin-bottom: 1rem;
            margin-left: 15%;
        }
        .feed-media-wrapper .carousel-indicators [data-bs-target] {
            box-sizing: content-box;
            flex: 0 1 auto;
            width: 30px;
            height: 3px;
            padding: 0;
            margin-right: 3px;
            margin-left: 3px;
            text-indent: -999px;
            cursor: pointer;
            background-color: #fff;
            background-clip: padding-box;
            border: 0;
            border-top: 10px solid transparent;
            border-bottom: 10px solid transparent;
            opacity: .5;
            transition: opacity .6s ease;
        }
        .feed-media-wrapper .carousel-indicators .active { 
            opacity: 1; 
        }

        .feed-media-wrapper .carousel-control-next, 
        .feed-media-wrapper .carousel-control-prev {
            width: 40px; height: 40px; top: 50%; transform: translateY(-50%);
            background: rgba(0,0,0,0.3); border-radius: 50%; margin: 0 10px; opacity: 0; transition: opacity 0.2s; z-index: 10;
        }
        .feed-media-wrapper:hover .carousel-control-next, 
        .feed-media-wrapper:hover .carousel-control-prev { opacity: 1; }

        /* Video Controls */
        .feed-video-container { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; background: #000; cursor: pointer; }
        .feed-play-btn {
            position: absolute; width: 64px; height: 64px; background: rgba(255,255,255,0.2); backdrop-filter: blur(4px);
            border-radius: 50%; display: flex; align-items: center; justify-content: center;
            color: white; font-size: 24px; cursor: pointer; border: 2px solid white;
            transition: all 0.2s ease; z-index: 10; padding: 0; pointer-events: none;
        }
        .feed-video-container:hover .feed-play-btn { background: var(--feed-primary); border-color: var(--feed-primary); transform: scale(1.1); }
        .feed-mute-btn {
            position: absolute; bottom: 20px; right: 20px; width: 36px; height: 36px;
            background: rgba(0,0,0,0.6); border-radius: 50%; display: flex; align-items: center; justify-content: center;
            color: white; font-size: 16px; cursor: pointer; z-index: 15; transition: all 0.2s ease;
        }

        /* CUSTOM VIDEO PLAYER STYLES */
        .custom-video-player {
            position: relative; width: 100%; height: 100%;
            background: #000; overflow: hidden;
            display: flex; align-items: center; justify-content: center;
        }
        .custom-video-player video { width: 100%; height: 100%; object-fit: contain; }
        
        .video-play-overlay {
            position: absolute; top: 0; left: 0; width: 100%; height: 100%;
            display: flex; align-items: center; justify-content: center;
            background: rgba(0,0,0,0.2); transition: opacity 0.3s;
            pointer-events: none;
        }
        .video-play-overlay.hidden { opacity: 0; }

        .video-big-play {
            width: 70px; height: 70px; border-radius: 50%;
            background: rgba(255,255,255,0.2); backdrop-filter: blur(8px); border: 2px solid #fff;
            color: #fff; font-size: 28px; display: flex; align-items: center; justify-content: center;
            cursor: pointer; pointer-events: auto; transition: transform 0.2s, background 0.2s;
            padding: 0;
        }
        .video-big-play:hover { transform: scale(1.1); background: var(--feed-primary); border-color: var(--feed-primary); transform: scale(1.1); }

        .video-controls-bar {
            position: absolute; bottom: 0; left: 0; width: 100%; padding: 10px 15px 15px;
            background: linear-gradient(to top, rgba(0,0,0,0.85) 0%, transparent 100%);
            display: flex; align-items: center; gap: 12px; color: white;
            opacity: 0; transition: opacity 0.3s ease; z-index: 20;
        }
        .custom-video-player:hover .video-controls-bar,
        .custom-video-player.paused .video-controls-bar { opacity: 1; }

        .video-btn {
            background: none; border: none; color: white; cursor: pointer; padding: 0; 
            font-size: 1rem; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center;
            transition: color 0.2s;
        }
        .video-btn:hover { color: var(--feed-primary); }
        .video-time { font-size: 0.8rem; min-width: 40px; text-align: center; font-weight: 500; font-variant-numeric: tabular-nums; }
        .video-slider {
            flex-grow: 1; height: 4px; background: rgba(255,255,255,0.3); border-radius: 2px;
            -webkit-appearance: none; cursor: pointer; position: relative;
        }
        .video-slider::-webkit-slider-thumb {
            -webkit-appearance: none; width: 12px; height: 12px; background: var(--feed-primary);
            border-radius: 50%; border: 2px solid #fff; transition: transform 0.1s;
        }
        .video-slider::-webkit-slider-thumb:hover { transform: scale(1.3); }
        .video-vol-slider { width: 60px; flex-grow: 0; }

        /* CUSTOM AUDIO PLAYER STYLES (CARD STYLE) */
        .custom-audio-player {
            position: relative;
            width: 100%;
            height: 200px; /* Card Height */
            background: radial-gradient(circle at center, #334155 0%, #0f172a 100%);
            border-radius: var(--feed-radius);
            overflow: hidden;
            display: flex;
            align-items: center;
            justify-content: center;
            border: 1px solid var(--feed-border);
            box-shadow: var(--feed-shadow-sm);
        }
        
        .feed-audio-slide .custom-audio-player {
            border: none;
            box-shadow: none;
            height: 100%; /* In carousel it takes full height */
            background: transparent;
        }

        /* Centered Play Button for Audio */
        .custom-audio-player .play-pause-btn {
            position: absolute;
            top: 50%; left: 50%;
            transform: translate(-50%, -50%);
            width: 64px; height: 64px; border-radius: 50%;
            background: rgba(255, 255, 255, 0.15); backdrop-filter: blur(4px); border: 2px solid #fff;
            color: #fff; font-size: 24px; display: flex; align-items: center; justify-content: center;
            cursor: pointer; transition: all 0.2s ease; z-index: 2; padding: 0;
        }
        .custom-audio-player .play-pause-btn:hover { background: var(--feed-primary); border-color: var(--feed-primary); transform: translate(-50%, -50%) scale(1.1); }
        .custom-audio-player .play-pause-btn.playing { padding-left: 0; }

        /* Bottom Controls for Audio */
        .custom-audio-player .audio-bottom-bar {
            position: absolute; bottom: 0; left: 0; width: 100%; padding: 15px;
            background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
            display: flex; align-items: center; gap: 12px; color: white; z-index: 2;
        }

        .custom-audio-player .audio-time { 
            font-size: 0.75rem; font-variant-numeric: tabular-nums; 
            min-width: 40px; text-align: center; color: rgba(255,255,255,0.9);
        }

        .custom-audio-player .seek-slider {
            flex-grow: 1; height: 4px; background: rgba(255,255,255,0.3); border-radius: 2px;
            -webkit-appearance: none; cursor: pointer;
        }
        .custom-audio-player .seek-slider::-webkit-slider-thumb {
            -webkit-appearance: none; width: 12px; height: 12px; border-radius: 50%; 
            background: var(--feed-primary); cursor: pointer; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3);
            transition: transform 0.2s;
        }
        .custom-audio-player .seek-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

        .custom-audio-player .volume-control { display: flex; align-items: center; gap: 8px; }
        
        .custom-audio-player .mute-btn { 
            background: none; border: none; color: white; cursor: pointer; padding: 0; font-size: 1rem;
            transition: color 0.2s;
        }
        .custom-audio-player .mute-btn:hover { color: var(--feed-primary); }

        .custom-audio-player .volume-slider {
            width: 60px; height: 4px; background: rgba(255,255,255,0.3); border-radius: 2px;
            -webkit-appearance: none; cursor: pointer;
        }
        .custom-audio-player .volume-slider::-webkit-slider-thumb {
            -webkit-appearance: none; width: 10px; height: 10px; background: #fff; border-radius: 50%;
            transition: transform 0.1s;
        }
        .custom-audio-player .volume-slider::-webkit-slider-thumb:hover { transform: scale(1.3); }

        /* Attachments */
        .feed-attachment {
            background: #f8fafc; border: 1px solid var(--feed-border); border-radius: var(--feed-radius); padding: 12px;
            display: flex; align-items: center; transition: all 0.2s; cursor: pointer; margin-bottom: 0.5rem;
        }
        .feed-attachment:hover { border-color: var(--feed-primary); background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
        .feed-attachment:last-child { margin-bottom: 1rem; }
        
        .feed-file-icon {
            width: 42px; height: 42px; border-radius: 10px; background: #e0f2fe; color: var(--feed-primary);
            display: flex; align-items: center; justify-content: center; font-size: 1.25rem; margin-right: 12px;
        }

        /* Actions Bar */
        .feed-actions-bar {
            border-top: 1px solid var(--feed-border); margin-top: 16px; padding-top: 12px;
            display: flex; gap: 8px;
        }
        .feed-btn-action {
            color: var(--feed-text-secondary); font-weight: 600; font-size: 0.9rem; padding: 8px 16px; border-radius: 8px;
            transition: all 0.2s; border: none; background: transparent; display: inline-flex; align-items: center;
        }
        .feed-btn-action:hover { background: #f1f5f9; color: var(--feed-text-main); }
        .feed-btn-action.liked { color: var(--feed-danger); }
        .feed-btn-action.liked i { animation: heartPulse 0.4s ease-out; }

        /* Dropdowns */
        .dropdown-menu { 
            border: none; box-shadow: var(--feed-shadow-lg); 
            border-radius: 12px; padding: 8px; font-size: 0.9rem; min-width: 180px;
            z-index: 1050; /* Garante que fica por cima de outros elementos no contexto de empilhamento */
        }
        .dropdown-item { border-radius: 8px; padding: 8px 16px; font-weight: 500; color: var(--feed-text-secondary); margin-bottom: 2px; }
        .dropdown-item:hover { background: var(--feed-bg-body); color: var(--feed-primary); }
        .dropdown-item.text-danger:hover { background: #fef2f2; color: var(--feed-danger); }

        /* Mentions */
        .feed-mention-list {
            position: absolute; background: white; border: 1px solid var(--feed-border); border-radius: 12px;
            box-shadow: var(--feed-shadow-lg); 
            z-index: 1060; /* Z-Index aumentado para ficar acima de modais */
            width: 280px; max-height: 300px;
            overflow-y: auto; display: none; flex-direction: column; padding: 6px;
        }
        .feed-mention-item { padding: 10px; cursor: pointer; display: flex; align-items: center; border-radius: 8px; transition: all 0.1s; }
        .feed-mention-item:hover, .feed-mention-item.active { background-color: #f1f5f9; border-left: 3px solid var(--feed-primary); }
        .feed-mention-link {
            color: var(--feed-primary); font-weight: 600; background: rgba(59, 130, 246, 0.1);
            padding: 0 4px; border-radius: 4px; text-decoration: none;
        }

        /* Recording & Preview */
        .feed-recording-status {
            display: none; align-items: center; background: #fef2f2; color: #b91c1c;
            padding: 8px 16px; border-radius: 12px; margin-bottom: 12px; font-size: 0.9rem;
            border: 1px solid #fecaca;
        }
        .feed-rec-dot {
            width: 10px; height: 10px; background: var(--feed-danger); border-radius: 50%; margin-right: 10px;
            animation: blink 1.5s infinite;
        }
        .feed-preview-thumb {
            position: relative; width: 120px; height: 80px; border-radius: 8px; overflow: hidden;
            border: 1px solid var(--feed-border); background: #000;
            cursor: grab; transition: transform 0.2s; display: flex; align-items: center; justify-content: center;
        }
        .feed-preview-thumb:hover { transform: scale(1.02); }
        .feed-preview-thumb img, .feed-preview-thumb video { width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
        .feed-preview-thumb .badge { position: absolute; top: 4px; right: 4px; cursor: pointer; background: rgba(220, 38, 38, 0.8); }

        /* Modal Specific */
        .feed-modal-view .modal-content { height: calc(100vh - 56px); border-radius: 12px; overflow: hidden; border: none; }
        .feed-modal-media { background: #000; height: 100%; display: flex; align-items: center; justify-content: center; width: 100%; }
        .feed-modal-media img, .feed-modal-media video { max-height: 100%; max-width: 100%; object-fit: contain; }
        
        /* CORREÇÃO AQUI: Garante que os comentários respeitam o tamanho do ecrã e ativam a barra de scroll */
        .feed-modal-comments { 
            display: flex; 
            flex-direction: column; 
            height: 100%; 
            max-height: 100%; 
            background: #fff; 
            overflow: hidden; /* Impede que o bloco cresça para fora do modal */
        }
        .feed-comments-list { 
            flex: 1 1 auto; /* Permite que cresça, mas também encolha */
            overflow-y: auto !important; /* Força a barra de rolamento */
            padding: 1rem; 
            height: 150px;
            scrollbar-width: thin;
            scrollbar-color: #cbd5e1 transparent;
        }
        .feed-comments-list::-webkit-scrollbar { width: 6px; }
        .feed-comments-list::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 10px; }
        .feed-comments-list::-webkit-scrollbar-track { background: transparent; }
        
        @keyframes heartPulse { 0% { transform: scale(1); } 50% { transform: scale(1.4); } 100% { transform: scale(1); } }
        @keyframes blink { 0% { opacity: 1; } 50% { opacity: 0.5; } 100% { opacity: 1; } }
        .feed-anim-enter { animation: slideUpFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; opacity: 0; transform: translateY(10px); }
        @keyframes slideUpFade { to { opacity: 1; transform: translateY(0); } }
        @keyframes slideInRight { from { opacity:0; transform: translateX(100%); } to { opacity:1; transform: translateX(0); } }

        /* Loading Spinner Overlay */
        .feed-loader-overlay {
            position: absolute; top:0; left:0; width:100%; height:100%;
            background: rgba(255,255,255,0.7); display:flex; align-items:center; justify-content:center;
            z-index:10;
        }

        /* --- UI/UX Enhancements for Modals --- */
        .modal-content {
            border: none;
            box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
            border-radius: 20px;
            overflow: hidden;
        }
        .modal-header {
            border-bottom: 1px solid rgba(0,0,0,0.05);
            padding: 1.25rem 1.5rem;
            background: #fff;
        }
        .modal-footer {
            border-top: 1px solid rgba(0,0,0,0.05);
            padding: 1rem 1.5rem;
            background: #fff;
        }

        /* Recording Controls UI */
        .recording-controls-wrapper {
            background: rgba(15, 23, 42, 0.6);
            backdrop-filter: blur(12px);
            -webkit-backdrop-filter: blur(12px);
            border-radius: 50px;
            padding: 8px 16px;
            border: 1px solid rgba(255,255,255,0.1);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
            display: inline-flex;
            align-items: center;
            gap: 12px;
        }

        /* Company Badge */
        .company-badge {
            background-color: #eff6ff; 
            color: var(--feed-primary);
            border: 1px solid #dbeafe;
            padding: 4px 10px;
            border-radius: 12px;
            font-size: 0.85rem;
            font-weight: 600;
            display: inline-flex;
            align-items: center;
        }
        .company-badge i.fa-times { cursor: pointer; margin-left: 6px; color: #94a3b8; }
        .company-badge i.fa-times:hover { color: var(--feed-danger); }

        /* Company Select Modal Item */
        .company-select-item {
            padding: 12px; border-bottom: 1px solid #f1f5f9; cursor: pointer; transition: background 0.2s;
            display: flex; align-items: center;
        }
        .company-select-item:hover { background-color: #f8fafc; }
        .company-select-item:last-child { border-bottom: none; }
        .company-select-item.selected { background-color: #eff6ff; }
        .company-select-item img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; margin-right: 12px; }

        /* Fix: Ensure Company Modal is above Edit Modal */
        #companySelectionModal { z-index: 1070; }

        /* Responsividade */
        @media (max-width: 991px) {
            .feed-modal-view .modal-body { flex-direction: column; overflow-y: auto; }
            .feed-modal-media { height: auto; min-height: 350px; flex-shrink: 0; }
            .feed-modal-comments { height: auto; flex: 1; }
        }