/* =========================================
   1. GRUND & FÄRGER
   ========================================= */
:root {
    --brand-primary: #0056b3; 
    --brand-accent: #e68a00; 
    --brand-bg: #ffffff;
    --text-dark: #111111;
    --text-grey: #666666;
    --border: #e0e0e0;
    --font-stack: "Inter", -apple-system, sans-serif;
    --profile-cover-height: 200px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-stack);
    background-color: #f4f6f8; /* Lite mörkare bakgrund för kontrast */
    color: var(--text-dark);
    line-height: 1.5;
    overflow-x: hidden; 
    padding-top: 70px; /* För fast header */
}

/* Fix för länkar */
a { text-decoration: none; color: inherit; transition: color 0.2s; cursor: pointer; }
a:hover { color: var(--brand-primary); }

img { display: block; max-width: 100%; height: auto; }

/* KNAPPAR & UI */
.btn-create { background: var(--brand-primary); color: white; padding: 10px 20px; border-radius: 4px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; border: none; font-size: 0.9rem; cursor: pointer; }
.btn-create:hover { background: #004494; color:white; }

.btn-action { padding: 10px 20px; border-radius: 25px; font-weight: 600; cursor: pointer; border: none; transition: transform 0.1s; display:inline-block; text-align:center; text-decoration:none; }
.btn-action:hover { transform: scale(1.02); }
.btn-primary { background: var(--brand-primary); color: white; } 
.btn-secondary { background: #eee; color: #333; }
.btn-secondary:hover { background: #ddd; }
.btn-green { background: #2ecc71; color: white; }
.btn-green:hover { background: #27ae60; }
.btn-outline { background: transparent; border: 2px solid var(--brand-primary); color: var(--brand-primary); }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; border-radius: 4px; width: auto; display:inline-block; }

/* =========================================
   2. HEADER (Fixad)
   ========================================= */
.main-header { 
    background: white; 
    border-bottom: 3px solid var(--brand-primary); 
    height: 70px; 
    display: flex; 
    align-items: center; 
    padding: 0 20px; 
    position: fixed; 
    top: 0; 
    width: 100%; 
    z-index: 2000; 
    box-sizing: border-box; 
    justify-content: space-between; 
}

.brand { font-size: 24px; font-weight: 900; color: #000; text-decoration: none; display: flex; align-items: center; gap: 10px; }
.nav-wrap { display: flex; align-items: center; gap: 20px; flex: 1; justify-content: flex-end; margin-left: 20px; }
.nav-links { display: flex; gap: 20px; }
.nav-links a { text-decoration: none; color: #333; font-weight: 600; font-size: 14px; text-transform: uppercase; }
.nav-links a:hover { color: var(--brand-primary); }

.search-box { background: #f1f3f4; border-radius: 20px; padding: 5px 15px; display: flex; align-items: center; margin-right:auto; }
.search-box input { border: none; background: transparent; outline: none; font-size:0.9rem; }

.icon-link { font-size: 1.2rem; color: #555; position: relative; text-decoration: none; margin-left: 10px; }
.badge { position: absolute; top: -5px; right: -8px; background: #d63031; color: white; font-size: 10px; padding: 2px 5px; border-radius: 10px; border:2px solid white; }

.user-menu { display: flex; align-items: center; gap: 10px; border-left:1px solid #eee; padding-left:20px; margin-left:10px; }
.av-circle { width: 40px; height: 40px; border-radius: 50%; overflow: hidden; border: 1px solid #ddd; }
.av-circle img { width: 100%; height: 100%; object-fit: cover; }

/* Mobilmeny */
.mobile-btn { display: none; font-size: 24px; background: none; border: none; cursor: pointer; color:#333; }
.mobile-only { display:none; }

@media (max-width: 900px) {
    .nav-wrap { display: none; position: absolute; top: 70px; left: 0; right: 0; background: white; flex-direction: column; padding: 20px; border-bottom: 1px solid #ddd; box-shadow: 0 5px 10px rgba(0,0,0,0.1); }
    .nav-wrap.show { display: flex; align-items:flex-start; }
    .nav-links { flex-direction: column; width: 100%; gap:15px; }
    .mobile-btn { display: block; }
    .user-menu { display: none; } 
    .search-box { width:100%; margin-bottom:15px; }
    .mobile-only { display:block; }
}

/* =========================================
   3. LAYOUT & GRID
   ========================================= */
.main-content { max-width: 1200px; margin: 30px auto; padding: 0 15px; min-height: 80vh; }
.layout-grid-3 { display: flex; flex-direction: column; gap: 20px; }

@media (min-width: 1100px) {
    .layout-grid-3 { display: grid; grid-template-columns: 260px 1fr 280px; gap: 25px; align-items: start; }
    .sidebar-left, .sidebar-right { display: block; }
}
@media (max-width: 1099px) {
    .layout-grid-3 { display: flex; flex-direction: column; }
}

/* Sidebarboxar */
.sb-section { background: white; border-radius: 8px; border: 1px solid #ddd; overflow: hidden; margin-bottom:20px; }

/* =========================================
   4. FLÖDE & INLÄGG
   ========================================= */
.feed-filter { display: flex; background: #fff; border-radius: 8px; overflow: hidden; border: 1px solid #ddd; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.filter-item { flex: 1; text-align: center; padding: 12px; cursor: pointer; text-decoration: none; color: #555; font-weight: 600; border-right: 1px solid #eee; background: #fff; transition:0.2s; }
.filter-item:last-child { border-right: none; }
.filter-item:hover { background: #f9f9f9; color: var(--brand-primary); }
.filter-item.active { background: #f0f7ff; color: var(--brand-primary); border-bottom: 3px solid var(--brand-primary); }

.news-card { background: white; border-radius: 8px; border: 1px solid #ddd; margin-bottom: 20px; }
.dropdown { position: relative; display: inline-block; }
.dropdown-content { display: none; position: absolute; right: 0; top: 100%; background-color: #fff; min-width: 180px; box-shadow: 0 8px 16px rgba(0,0,0,0.2); z-index: 100; border-radius: 4px; border: 1px solid #eee; overflow: hidden; }
.dropdown-content a, .dropdown-content button { color: #333; padding: 12px 16px; text-decoration: none; display: block; width: 100%; text-align: left; border: none; background: none; cursor: pointer; font-size: 0.9rem !important; font-family: inherit; }
.dropdown-content a:hover, .dropdown-content button:hover { background-color: #f1f1f1; }

/* =========================================
   5. ANNONSER
   ========================================= */
.market-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; }
.market-card { background: white; border-radius: 8px; overflow: hidden; border: 1px solid #ddd; transition: transform 0.2s; display: flex; flex-direction: column; text-decoration:none; color:inherit; }
.market-card:hover { transform: translateY(-3px); box-shadow: 0 5px 15px rgba(0,0,0,0.1); border-color: var(--brand-primary); }
.market-img-box { height: 180px; background: #eee; position: relative; overflow: hidden; }
.market-img-box img { width: 100%; height: 100%; object-fit: cover; transition:0.3s; }
.market-blur { filter: blur(20px); transform: scale(1.1); cursor: pointer; }
.market-badge { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,0.7); color: white; padding: 3px 8px; border-radius: 4px; font-size: 0.75rem; text-transform: uppercase; z-index:2; }
.market-body { padding: 15px; flex-grow: 1; display: flex; flex-direction: column; }
.market-cat { color: var(--brand-primary); font-size: 0.8rem; font-weight: bold; text-transform: uppercase; margin-bottom: 5px; }
.market-title { margin: 0 0 10px 0; font-size: 1.1rem; line-height: 1.3; font-weight: bold; color: #333; }
.market-meta { font-size: 0.85rem; color: #666; margin-top: auto; padding-top: 10px; border-top: 1px solid #eee; display: flex; justify-content: space-between; align-items: center;}

/* =========================================
   6. FORMULÄR
   ========================================= */
.form-group { margin-bottom: 15px; }
.form-label { display: block; font-weight: 600; margin-bottom: 5px; font-size: 0.9rem; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 4px; font-family: inherit; font-size: 1rem; background:white; }
.form-textarea { height: 150px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
@media (max-width: 700px) { .grid-2 { grid-template-columns: 1fr; } }

/* =========================================
   7. REAKTIONER & KOMMENTARER
   ========================================= */
.reaction-wrapper { position: relative; display: inline-block; }
.reaction-box { 
    position: absolute; 
    bottom: 100%; 
    left: -10px; 
    background: white; 
    border-radius: 50px; 
    padding: 5px 10px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.2); 
    display: none !important; 
    gap: 8px; 
    z-index: 100; 
    white-space: nowrap; 
}
.reaction-wrapper:hover .reaction-box { display: flex !important; animation: popUp 0.2s ease; }
.reaction-btn { font-size: 1.5rem; cursor: pointer; transition: transform 0.2s; background: none; border: none; padding: 0; line-height: 1; }
.reaction-btn:hover { transform: scale(1.3) translateY(-5px); }
@keyframes popUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.btn-like { border:none; background:none; font-weight:600; cursor:pointer; font-size: 0.95rem; color: #666; display:flex; align-items:center; gap:5px; padding: 5px 10px; border-radius: 4px; }
.btn-like:hover { background: #f0f2f5; }
.react-like { color: #0056b3; } .react-love { color: #e91e63; } .react-haha { color: #f7b928; } .react-wow { color: #f7b928; } .react-sad { color: #f7b928; } .react-angry { color: #e44d3a; }

.comment-item { display: flex; gap: 10px; font-size: 0.9rem; margin-bottom: 8px; align-items: flex-start; }

/* FIX FÖR KLÄMDA AVATARER */
.comment-avatar { 
    width: 30px; 
    height: 30px; 
    min-width: 30px; /* Tvingar bredden att aldrig bli mindre än 30px */
    border-radius: 50%; 
    object-fit: cover; 
    flex-shrink: 0;  /* Förbjuder flexbox att krympa elementet */
}

.comment-bubble { background: #f0f2f5; padding: 8px 12px; border-radius: 12px; flex-grow: 1; position: relative; min-width: 0; }
.comment-action-btn { background: none; border: none; cursor: pointer; color: #888; font-size: 0.8rem; padding: 0; margin-left: 8px; }
.comment-action-btn:hover { color: #555; }
.reaction-box.small { padding: 3px 6px; gap: 4px; }
.reaction-box.small .reaction-btn { font-size: 1.1rem; }

/* =========================================
   8. STATUS DOTS
   ========================================= */
.status-dot {
    height: 10px; width: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-left: 5px;
    vertical-align: middle;
    border: 2px solid white;
}
.dot-green { background-color: #2ecc71; }
.dot-yellow { background-color: #f1c40f; }
.dot-red { background-color: #e74c3c; }

/* =========================================
   9. MEDDELANDEN (Mobilfix)
   ========================================= */
.messages-container { display: grid; grid-template-columns: 320px 1fr; background: #fff; border: 1px solid var(--border); border-radius: 8px; height: 600px; overflow: hidden; position: relative; }
.msg-sidebar { border-right: 1px solid #eee; display: flex; flex-direction: column; background: #fff; }
.msg-list { flex-grow: 1; overflow-y: auto; }
.msg-chat-area { display: flex; flex-direction: column; background: #f9f9f9; }

@media (max-width: 768px) {
    .messages-container { display: block; position: relative; height: 80vh; }
    .msg-sidebar { width: 100%; height: 100%; display: flex; } 
    .msg-chat-area { width: 100%; height: 100%; display: none; position: absolute; top:0; left:0; z-index: 10; }
    /* Klasser för JS toggle */
    .messages-container.view-chat .msg-sidebar { display: none; }
    .messages-container.view-chat .msg-chat-area { display: flex; }
}

.msg-item { display: flex; gap: 10px; padding: 15px; cursor: pointer; border-bottom: 1px solid #f9f9f9; text-decoration:none; color:inherit; }
.msg-item:hover { background: #f4f4f4; }
.msg-item.active { background: #eef6fc; border-left: 3px solid var(--brand-primary); }