/* =========================================
   1. GRUNDINSTÄLLNINGAR & RESET
   ========================================= */
html {
    scrollbar-gutter: stable;
}

html, body {
    margin: 0; 
    padding: 0; 
    background-color: #f4f4f4; 
    font-family: 'Helvetica Neue', Arial, sans-serif; 
    color: #111;
    width: 100%;
}
* { box-sizing: border-box; }

body.noscroll { 
    overflow: hidden; 
    padding-right: 0; 
}


/* =========================================
   2. TOPP BAR (Profil, Ikoner, Notiser)
   ========================================= */
.cc-top-bar { 
    background: #fff; 
    border-bottom: 1px solid #ddd; 
    height: 50px; 
    position: sticky; 
    top: 0; 
    z-index: 1000; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); 
}

.cc-top-container { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 0 15px; 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    height: 100%; 
}

/* --- VÄNSTER: Profil-knapp --- */
.cc-top-profile-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: #333;
    font-weight: bold;
    font-size: 0.9rem;
    text-align: left;
}
.cc-top-profile-btn:hover { opacity: 0.8; }

.cc-top-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #ddd;
}

/* --- HÖGER: Ikoner --- */
.cc-top-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.cc-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.4rem;
    padding: 5px;
    display: flex;
    align-items: center;
    color: #333;
}

.cc-hamburger-btn {
    display: block; 
    font-size: 1.6rem;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    line-height: 1;
}

/* Notiser */
.cc-notification-wrapper { position: relative; }

.cc-notif-btn {
    position: relative; 
    font-size: 1.4rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #333;
    padding: 5px;
}

.cc-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background-color: #e74c3c;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    border: 1px solid #fff;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}


/* =========================================
   3. NOTIS-DROPDOWN & MODALER
   ========================================= */
.cc-notif-dropdown {
    display: none; 
    position: absolute;
    top: 45px;
    right: -10px; 
    width: 300px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
    border: 1px solid #eee;
    z-index: 2000;
    overflow: hidden;
}
.cc-notif-dropdown.show { display: block; }

.cc-notif-header {
    background: #f9f9f9;
    padding: 10px 15px;
    font-weight: bold;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
    display: flex;
    justify-content: space-between;
}

.cc-notif-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 300px;
    overflow-y: auto;
}

.cc-notif-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px;
    border-bottom: 1px solid #f9f9f9;
    cursor: pointer;
    transition: background 0.2s;
}
.cc-notif-item:hover { background: #f0f8ff; }

.cc-notif-icon {
    width: 35px;
    height: 35px;
    background: #eee;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
}

.icon-green { background: #e8f5e9; color: #2e7d32; }
.icon-blue { background: #e3f2fd; color: #1565c0; }
.icon-red { background: #ffebee; color: #c62828; }

.cc-notif-text { font-size: 0.85rem; line-height: 1.3; }
.cc-notif-time { font-size: 0.7rem; color: #999; display: block; margin-top: 3px; }

/* SÖK-MODAL */
.cc-modal-overlay {
    display: none; 
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); 
    z-index: 2000; 
    align-items: flex-start;
    justify-content: center;
    padding-top: 60px; 
    backdrop-filter: blur(3px); 
}
.cc-modal-overlay.open { display: flex; }

.cc-search-box {
    background: #fff;
    width: 90%;
    max-width: 500px;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    overflow: hidden;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.cc-modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    background: #f9f9f9;
}

.cc-modal-body { padding: 20px; }
.cc-adv-input { width: 100%; padding: 12px; font-size: 1rem; border: 1px solid #ddd; border-radius: 4px; margin-bottom: 15px; }
.cc-filter-group { margin-bottom: 15px; }
.cc-filter-label { display: block; font-size: 0.8rem; font-weight: bold; margin-bottom: 5px; color: #666; }

.cc-primary-btn {
    width: 100%;
    padding: 12px;
    background: #000; 
    color: #fff;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}


/* =========================================
   4. HEADER (Logga)
   ========================================= */
.cc-main-header { 
    background: #fff; 
    padding: 20px 0; 
    border-bottom: 1px solid #eee; 
}

.cc-header-grid { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 0 15px; 
    display: grid; 
    grid-template-columns: 1fr; 
    align-items: center; 
}

.cc-logo-area h1 { 
    margin: 0; 
    font-family: 'Arial Black', sans-serif; 
    font-size: 3rem; 
    text-transform: uppercase; 
    line-height: 1; 
    display: flex; 
    flex-wrap: wrap; 
    column-gap: 5px; 
    justify-content: center; 
}

.cc-logo-black { color: #000; }
.cc-logo-color { color: #ea8c00; }

.cc-header-ad-desktop { display: none; }
.cc-header-ad-mobile { display: none; margin-top: 20px; text-align: center; }

@media (max-width: 600px) { 
    .cc-logo-area h1 { flex-direction: column; font-size: 2.5rem; line-height: 0.9; } 
    .cc-logo-black, .cc-logo-color { display: block; }
    .cc-header-ad-mobile { display: block; }
}


/* =========================================
   5. MENY (Navigation - Sidebar)
   ========================================= */
.cc-nav-bar { 
    display: block;
    position: fixed; 
    top: 50px; 
    left: 0; 
    bottom: 0; 
    width: 100%; 
    max-width: 320px; 
    background: #fff; 
    border-right: 1px solid #ddd; 
    box-shadow: 2px 0 10px rgba(0,0,0,0.1); 
    transform: translateX(-100%); 
    transition: transform 0.3s ease-in-out;
    z-index: 900; 
    overflow-y: auto; 
    overscroll-behavior: contain; 
}

.cc-nav-bar.open { transform: translateX(0); }

.cc-nav-container { display: block; padding: 0; }

.cc-nav-link { 
    display: flex !important; 
    align-items: center;
    width: 100%;
    text-align: left; 
    font-size: 1rem; 
    font-weight: 600;
    padding: 20px 25px; 
    border-bottom: 1px solid #f9f9f9; 
    margin: 0;
    background: transparent;
    color: #333;
    transition: background 0.2s;
}

.cc-nav-link:hover {
    background: #f4f4f4;
    color: #000;
}

.cc-nav-link.cc-active {
    background: #fff5e6; 
    color: #ea8c00; 
    border-left: 5px solid #ea8c00; 
}

.cc-nav-icon { 
    width: 30px; 
    display: flex; 
    justify-content: center; 
    font-size: 1.1rem;
    color: #888;
}
.cc-nav-link:hover .cc-nav-icon { color: #333; }
.cc-nav-link.cc-active .cc-nav-icon { color: #ea8c00; }

.cc-nav-container hr { 
    display: block; 
    border: 0;
    border-top: 1px solid #eee; 
    margin: 10px 0; 
}


/* =========================================
   6. LAYOUT & GRID
   ========================================= */
.cc-layout-grid { 
    display: grid; 
    grid-template-columns: 2fr 1fr 1fr; /* Feed | Ads | Profile */
    gap: 25px; 
    max-width: 1200px; 
    margin: 30px auto; 
    padding: 0 15px; 
}
@media (max-width: 900px) {
    .cc-layout-grid { grid-template-columns: 1fr; }
    .cc-col-feed { order: 1; }
    .cc-col-ads { order: 2; }
    .cc-col-profile { order: 3; }
}


/* =========================================
   7. FEED & INLÄGG (Post Cards)
   ========================================= */
.cc-post-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 25px;
    overflow: hidden; 
    width: 100%;      
    box-sizing: border-box; 
}

/* Header (Avatar + Namn) */
.cc-post-header {
    display: flex;
    align-items: center;
    padding: 15px;
}

.cc-post-avatar {
    width: 45px;       
    height: 45px;      
    border-radius: 50%; 
    object-fit: cover; 
    margin-right: 10px;
    border: 1px solid #eee;
    flex-shrink: 0;    
}

.cc-post-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.cc-post-time { font-size: 0.8rem; color: #999; }
.cc-post-headline { font-family: 'Georgia', serif; font-size: 1.6rem; margin: 0 0 10px 0; line-height: 1.1; font-weight: bold; }
.cc-post-headline a { color: #000; text-decoration: none; }

/* Innehåll (Text + Bild) */
.cc-post-content {
    padding: 0 15px 15px 15px; 
    font-size: 0.95rem;
    line-height: 1.5;
    color: #333;
    overflow-wrap: break-word;
}

/* Tvinga alla bilder i inlägg att anpassa sig */
.cc-post-content img,
.cc-img-wrapper img {
    max-width: 100% !important;   
    height: auto !important;      
    border-radius: 4px;
    margin-top: 10px;
    display: block;    
}

/* Knappar (Gilla/Dela) */
.cc-post-actions {
    border-top: 1px solid #f0f0f0;
    display: flex;
}

.cc-action-btn {
    flex: 1; 
    background: none;
    border: none;
    padding: 12px 0;
    color: #666;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px; 
}
.cc-action-btn:hover { background-color: #f9f9f9; color: #ea8c00; }

/* Generisk Avatar-klass */
.cc-avatar-circle {
    width: 45px !important;       
    height: 45px !important;      
    border-radius: 50%;           
    object-fit: cover;            
    flex-shrink: 0;               
    border: 1px solid #ddd;       
    display: block;
    background-color: #fff;       
}


/* =========================================
   8. SIDOSPALTER & FOOTER
   ========================================= */
.cc-in-feed-ad { margin-bottom: 25px; text-align: center; padding: 20px 0; background: #f9f9f9; border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; }
.cc-ad-box { background: #fff; border: 1px solid #ddd; border-top: 4px solid #000; padding: 15px; margin-bottom: 20px; }
.cc-ad-title { font-weight: bold; border-bottom: 1px solid #eee; padding-bottom: 5px; margin-bottom: 10px; text-transform: uppercase; font-size: 0.9rem; background: #000; color: #fff; display: inline-block; padding: 2px 5px; }

.cc-mobile-footer { display: none; text-align: center; padding: 20px; background: #222; color: #fff; margin-top: 20px; }
@media (max-width: 900px) { .cc-mobile-footer { display: block; } }


/* =========================================
   9. PROFIL-SIDA (FINAL FIX)
   ========================================= */
/* Tvinga layouten att ta full bredd (fixar "Tiny Header") */
.profile-header, .profile-grid {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.profile-header { 
    position: relative; 
    background: #fff; 
    margin-bottom: 20px; 
    border-radius: 0 0 8px 8px; 
    border: 1px solid #ddd; 
    border-top: none; 
    display: flex;
    flex-direction: column;
}

.cover-photo { 
    width: 100%; 
    height: 250px; 
    object-fit: cover; 
    background: #eee; 
    display: block;
}

/* AVATAR - Låst från toppen för stabilitet */
.avatar-container { 
    position: absolute; 
    z-index: 20; 
    width: 150px; 
    height: 150px; 
    border: 4px solid #fff; 
    border-radius: 50%; 
    background: #fff; 
    overflow: hidden; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.15);
    top: 170px; 
    left: 30px; 
}

.avatar-img { width: 100%; height: 100%; object-fit: cover; }

.online-badge { 
    position: absolute; 
    z-index: 21;
    width: 20px; 
    height: 20px; 
    background: #4caf50; 
    border: 3px solid #fff; 
    border-radius: 50%; 
    top: 280px; 
    left: 145px; 
}

/* MENYRADEN */
.profile-nav { 
    padding-left: 200px; 
    min-height: 90px; 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    padding-right: 20px; 
    padding-top: 15px; 
    padding-bottom: 15px; 
    flex-wrap: wrap; 
}

/* Fix för bilder i flödet (Stoppar explosionen) */
.post-image {
    max-width: 100%; /* Hindrar bilden från att bli bredare än rutan */
    height: auto; 
    border-radius: 5px; 
    margin-top: 10px; 
    border: 1px solid #eee;
    display: block;
}

/* Övrig Text & Knappar */
.stats-container { display: flex; gap: 20px; margin-top: 5px; font-size: 0.9rem; }
.stat-item { color: #555; cursor: pointer; }
.stat-item strong { color: #000; font-weight: bold; }

.action-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; align-items: center; }

.action-btn { padding: 8px 16px; border-radius: 20px; border: 1px solid #ccc; background: #f9f9f9; color: #333; text-decoration: none; font-size: 0.85rem; font-weight: bold; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; transition: 0.2s; white-space: nowrap; }
.action-btn:hover { background: #eee; }
.btn-follow { background: #ea8c00; color: #fff; border-color: #d67c00; }
.btn-follow:hover { background: #d67c00; }
.btn-unfollow { background: #fff; color: #ea8c00; border-color: #ea8c00; }

.btn-icon { background:none; border:none; cursor:pointer; font-size:1.2rem; color:#777; padding: 5px; }
.btn-icon:hover { transform: scale(1.1); }
.btn-icon.active-up { color: #4caf50; }
.btn-icon.active-down { color: #f44336; }

.popover-details { position:relative; display:inline-block; }
.popover-details summary { cursor:pointer; list-style:none; }
.popover-details summary::-webkit-details-marker { display: none; }
.popover-box { position:absolute; top: 100%; right:0; margin-top:5px; background:#fff; border:1px solid #ccc; padding:10px; z-index:100; width:260px; border-radius:5px; box-shadow:0 4px 15px rgba(0,0,0,0.15); text-align: left;}
.popover-input { width:100%; padding:6px; margin-bottom:8px; border:1px solid #ddd; border-radius:3px; box-sizing: border-box; }
.popover-btn { width:100%; padding:6px; background:#333; color:#fff; border:none; border-radius:3px; cursor:pointer; }

/* Innehålls-grid */
.profile-grid { display: grid; grid-template-columns: 280px 1fr; gap: 20px; }
.p-box { background: #fff; border: 1px solid #ddd; border-radius: 8px; padding: 20px; margin-bottom: 20px; }
.p-title { font-weight: bold; font-size: 0.95rem; margin-bottom: 15px; border-bottom: 1px solid #eee; padding-bottom: 10px; color: #444; text-transform: uppercase; letter-spacing: 0.5px; }
.info-row { display: flex; margin-bottom: 10px; font-size: 0.9rem; }
.info-label { width: 110px; color: #777; font-weight: 500; }
.info-val { color: #333; font-weight: 500; flex: 1; }
.social-link { display: block; padding: 8px 0; color: #555; text-decoration: none; border-bottom: 1px solid #f9f9f9; transition: 0.2s; }
.social-link:hover { color: #ea8c00; padding-left: 5px; }

/* MOBILANPASSNING */
@media (max-width: 768px) {
    .profile-grid { grid-template-columns: 1fr; }
    .cover-photo { height: 200px; } 
    
    .avatar-container { 
        left: 50%; 
        transform: translateX(-50%); 
        top: 130px; 
        width: 130px; 
        height: 130px;
    }

    .online-badge {
        left: calc(50% + 40px); 
        top: 220px; 
    }

    .profile-nav { 
        display: flex;
        flex-direction: column; 
        align-items: center;
        text-align: center;
        padding-left: 20px; 
        padding-right: 20px;
        padding-top: 70px; 
    }

    .action-bar { justify-content: center; margin-top: 15px; }
    .popover-box { left: 50%; transform: translateX(-50%); right: auto; width: 280px; }
}