/* =========================================
   1. GLOBAL VARIABLES & RESET
   ========================================= */
:root { 
    --ns-dark: #0A2342; 
    --ns-teal: #6ec1ae; 
    --ns-yellow: #f0d44d;
    --ns-bg: #F8FAFC;
    --ns-white: #FFFFFF;
    --ns-border: #E2E8F0;
    --trans: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body { margin: 0; padding: 0; width: 100%; height: 100%; overflow: hidden; }
body { font-family: 'Inter', sans-serif; background: var(--ns-bg); color: var(--ns-dark); display: flex; flex-direction: column; }

/* =========================================
   2. HEADER & SIDEBAR
   ========================================= */
.header-main { background: var(--ns-white); z-index: 1000; flex: 0 0 auto; border-bottom: 1px solid var(--ns-border); }
.header-wrap { padding: 12px 25px; display: flex; align-items: center; justify-content: space-between; }
.header-title { font-weight: 800; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 1.5px; color: #94a3b8; }
.bar-gradient { height: 4px; background: linear-gradient(90deg, var(--ns-teal) 0%, var(--ns-yellow) 100%); width: 100%; display: block; }
.menu-btn { display: none; background: var(--ns-dark); color: white; border: none; padding: 8px 12px; border-radius: 6px; font-weight: 700; cursor: pointer; transition: var(--trans); }

.app-body { display: flex; flex: 1; overflow: hidden; position: relative; }
.sidebar { width: 340px; background: var(--ns-dark); color: white; padding: 30px; display: flex; flex-direction: column; overflow-y: auto; transition: transform 0.3s ease; z-index: 1500; box-shadow: 5px 0 15px rgba(0,0,0,0.05); }

.search-box { margin-bottom: 25px; position: relative; }
.search-inp { width: 100%; background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: white; padding: 10px 15px 10px 35px; border-radius: 10px; font-size: 0.9rem; outline: none; transition: var(--trans); box-sizing: border-box; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); opacity: 0.5; font-size: 1rem; }

.fav-toggle { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; background: rgba(255,255,255,0.05); padding: 10px 15px; border-radius: 10px; cursor: pointer; transition: var(--trans); border: 1px solid transparent; }
.fav-toggle.active { border-color: var(--ns-teal); background: rgba(110, 193, 174, 0.15); }
.fav-label { font-size: 0.85rem; font-weight: 600; }
.switch { width: 36px; height: 20px; background: rgba(255,255,255,0.2); border-radius: 20px; position: relative; transition: var(--trans); }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; background: white; border-radius: 50%; transition: var(--trans); }
.fav-toggle.active .switch { background: var(--ns-teal); }
.fav-toggle.active .switch::after { left: 19px; }

.nav-item { padding: 12px 18px; cursor: pointer; border-radius: 10px; margin-bottom: 8px; font-weight: 600; color: rgba(255,255,255,0.6); transition: var(--trans); display: flex; align-items: center; gap: 10px; font-size: 0.9rem; }
.nav-item.active { background: rgba(110, 193, 174, 0.15); color: var(--ns-teal); }
.filter-area { margin-top: 25px; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 20px; }
.filter-label { color: var(--ns-teal); font-size: 0.7rem; font-weight: 800; text-transform: uppercase; margin-bottom: 15px; display: block; letter-spacing: 1px; }
.tags-wrap { display: flex; flex-wrap: wrap; gap: 6px; }
.f-tag { padding: 5px 10px; border-radius: 6px; font-size: 0.7rem; font-weight: 700; cursor: pointer; transition: var(--trans); background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.7); border: 1px solid transparent; }
.f-tag.active { background: var(--ns-teal); color: white; }
.sb-info { margin-top: auto; padding-top: 30px; border-top: 1px solid rgba(255,255,255,0.1); }
.sb-text { font-size: 0.8rem; line-height: 1.5; color: rgba(255,255,255,0.6); margin-bottom: 15px; }
.btn-web { display: block; text-align: center; background: var(--ns-teal); color: white; padding: 12px; border-radius: 8px; text-decoration: none; font-weight: 700; transition: var(--trans); font-size: 0.85rem; }

/* =========================================
   3. CONTENT & CARDS
   ========================================= */
.content { flex: 1; padding: 40px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.grid { display: none; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 25px; }
.grid.active { display: grid; }
.card { background: var(--ns-white); padding: 25px; border-radius: 16px; border: 1px solid var(--ns-border); cursor: pointer; transition: var(--trans); position: relative; display: flex; flex-direction: column; }
.card:hover { transform: translateY(-5px); border-color: var(--ns-teal); box-shadow: 0 15px 35px rgba(10,35,66,0.08); }

.c-fav { position: absolute; top: 15px; right: 15px; font-size: 1.3rem; color: #cbd5e1; transition: var(--trans); z-index: 10; }
.c-fav.active { color: #ef4444; }
.st-badge { position: absolute; top: 15px; left: 15px; padding: 4px 10px; border-radius: 50px; font-size: 0.65rem; font-weight: 800; text-transform: uppercase; }
.st-open { background: #dcfce7; color: #166534; }
.st-bijna { background: #ffedd5; color: #9a3412; }
.st-gesloten { background: #fee2e2; color: #991b1b; }
.st-b-open { background: #e0f2fe; color: #0369a1; }
.new-badge { position: absolute; top: -10px; left: -10px; background: var(--ns-teal); color: white; padding: 6px 12px; border-radius: 8px; font-size: 0.7rem; font-weight: 800; transform: rotate(-5deg); z-index: 20; box-shadow: 0 5px 15px rgba(110, 193, 174, 0.4); animation: popIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
@keyframes popIn { 0% { transform: scale(0) rotate(0); } 100% { transform: scale(1) rotate(-5deg); } }

.icon-w { position: relative; width: 55px; height: 55px; margin: 25px 0 15px; }
.icon { width: 100%; height: 100%; background: #F8FAFC; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; transition: var(--trans); }
.card:hover .icon { background: #f0fdf4; transform: scale(1.05); }
.card h3 { font-size: 1.15rem; font-weight: 800; margin: 0 0 10px; letter-spacing: -0.3px; transition: var(--trans); }
.card:hover h3 { color: var(--ns-teal); }
.card p { font-size: 0.9rem; color: #64748b; line-height: 1.5; margin: 0 0 20px; flex-grow: 1; }
.c-meta { display: flex; justify-content: space-between; align-items: flex-end; font-size: 0.75rem; color: #94a3b8; font-weight: 600; margin-top: auto; padding-top: 15px; border-top: 1px solid #f1f5f9; }
.card-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 12px; }
.mini-tag { font-size: 0.65rem; padding: 4px 8px; border-radius: 4px; font-weight: 700; color: white; display: inline-block; }

/* =========================================
   4. DETAIL PANEL
   ========================================= */
.panel { position: fixed; right: -100%; top: 0; width: 45%; height: 100%; background: white; box-shadow: -20px 0 80px rgba(0,0,0,0.15); transition: 0.4s cubic-bezier(0.16, 1, 0.3, 1); z-index: 2000; display: flex; flex-direction: column; }
.panel.open { right: 0; }
.p-head { background: var(--ns-dark); padding: 50px 30px 25px; color: white; position: relative; flex: 0 0 auto; }
.p-close { position: absolute; top: 20px; right: 20px; width: 35px; height: 35px; background: rgba(255,255,255,0.1); border: none; border-radius: 50%; color: white; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; transition: var(--trans); }
.p-close:hover { background: var(--ns-teal); transform: rotate(90deg); }
.p-meta { display: flex; gap: 10px; align-items: center; margin-top: 12px; font-size: 0.85rem; color: rgba(255,255,255,0.8); }

/* ALERTS styling */
.p-alerts { margin-top: 15px; display: flex; flex-direction: column; gap: 8px; }
.alert-box { 
    background: rgba(240, 212, 77, 0.15); 
    border-left: 4px solid var(--ns-yellow); 
    padding: 12px; 
    color: var(--ns-yellow); 
    font-size: 0.85rem; 
    font-weight: 700; 
    border-radius: 4px; 
    line-height: 1.4; 
}

.p-body { padding: 30px; overflow-y: auto; flex: 1 1 auto; font-size: 1rem; line-height: 1.7; color: #334155; }
.p-body h2 { font-size: 1.2rem; color: var(--ns-dark); margin-top: 20px; }
.p-foot { padding: 25px 30px; border-top: 1px solid var(--ns-border); background: #fafafa; flex: 0 0 auto; }

/* STAPELBAAR STYLING (VERBETERD) */
.stapel-section { 
    margin-bottom: 20px; 
    padding-bottom: 20px; 
    border-bottom: 1px solid var(--ns-border); 
}
.stapel-label { 
    font-size: 0.7rem; 
    font-weight: 800; 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
    color: #94a3b8; 
    margin-bottom: 10px; 
    display: block; 
}
.stapel-badges { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 8px; 
}
.stapel-b { 
    background: white; 
    border: 1px solid var(--ns-border); 
    padding: 8px 12px; 
    border-radius: 8px; 
    font-size: 0.8rem; 
    font-weight: 600; 
    color: var(--ns-dark); 
    cursor: pointer; 
    transition: var(--trans); 
    display: inline-flex; 
    align-items: center; 
    gap: 6px;
}
/* Plusje toevoegen */
.stapel-b::before { content: '+'; color: var(--ns-teal); font-weight: 800; }
.stapel-b:hover { border-color: var(--ns-teal); color: var(--ns-teal); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.05); }

/* FOOTER BUTTONS */
.action-row { display: flex; justify-content: flex-end; gap: 10px; align-items: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: #fff; color: var(--ns-dark); border: 1px solid var(--ns-border); padding: 12px 20px; border-radius: 50px; text-decoration: none; font-weight: 700; font-size: 0.85rem; cursor: pointer; transition: var(--trans); }
.btn:hover { border-color: var(--ns-dark); transform: translateY(-2px); }
.btn.primary { background: var(--ns-dark); color: white; border-color: var(--ns-dark); }
.btn.primary:hover { background: var(--ns-teal); border-color: var(--ns-teal); }

.detail-status { padding: 6px 14px; border-radius: 50px; font-weight: 800; text-transform: uppercase; font-size: 0.75rem; letter-spacing: 0.5px; display: inline-block; color: #0f172a; }
.detail-status.st-open { background: #dcfce7 !important; color: #166534 !important; }
.detail-status.st-bijna { background: #ffedd5 !important; color: #9a3412 !important; }
.detail-status.st-gesloten { background: #fee2e2 !important; color: #991b1b !important; }
.detail-status.st-b-open { background: #e0f2fe !important; color: #0369a1 !important; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(10,35,66,0.85); z-index: 3000; display: none; align-items: center; justify-content: center; backdrop-filter: blur(4px); }
.modal.active { display: flex; animation: fadeIn 0.2s; }
.m-box { background: white; width: 90%; max-width: 400px; padding: 35px; border-radius: 20px; position: relative; box-shadow: 0 20px 40px rgba(0,0,0,0.3); }
.m-close { position: absolute; top: 15px; right: 15px; border: none; background: none; font-size: 1.2rem; cursor: pointer; }
.inp { width: 100%; padding: 12px; border: 1px solid #E2E8F0; border-radius: 8px; margin-bottom: 12px; box-sizing: border-box; font-family: inherit; }
.btn-sub { width: 100%; background: var(--ns-teal); color: white; border: none; padding: 14px; border-radius: 10px; font-weight: 700; cursor: pointer; transition: var(--trans); }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

/* =========================================
   5. MOBILE FIXES (ALERTS COMPACT & BUTTONS)
   ========================================= */
@media (max-width: 768px) {
    body { height: 100dvh; }
    .menu-btn { display: block; padding: 4px 10px; font-size: 0.8rem; }
    .sidebar { position: absolute; left: 0; top: 0; bottom: 0; transform: translateX(-100%); width: 260px; padding: 20px; }
    .sidebar.active { transform: translateX(0); }
    .sb-overlay { display: none; position: absolute; inset: 0; background: rgba(0,0,0,0.5); z-index: 1400; }
    .sb-overlay.active { display: block; }
    .header-wrap { padding: 10px 15px; } .header-title { display: none; }
    .content { padding: 10px; } .grid { grid-template-columns: 1fr; gap: 10px; }
    .card { padding: 12px; border-radius: 12px; min-height: 0; }
    .card h3 { font-size: 0.95rem; margin: 0 0 5px; }
    .card p { font-size: 0.75rem; margin-bottom: 8px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
    .icon-w { width: 36px; height: 36px; margin: 15px 0 10px; } .icon { font-size: 1.2rem; border-radius: 8px; }
    .st-badge { top: 8px; left: 8px; padding: 2px 8px; font-size: 0.5rem; } .c-fav { top: 6px; right: 8px; font-size: 1.1rem; }
    .new-badge { font-size: 0.55rem; padding: 3px 6px; top: -5px; left: -5px; }
    .mini-tag { font-size: 0.55rem; padding: 2px 6px; border-radius: 3px; } .c-meta { padding-top: 8px; font-size: 0.65rem; }
    
    /* DETAIL PANEL MOBILE */
    .panel { width: 100%; }
    .p-head { padding: 15px; border-bottom: 1px solid #f1f5f9; }
    .p-head h2 { font-size: 1.1rem; margin: 0 35px 5px 0; line-height: 1.2; }
    .p-close { top: 10px; right: 10px; width: 32px; height: 32px; background: rgba(255,255,255,0.2); }
    .p-meta { margin-top: 5px; font-size: 0.7rem; gap: 8px; }
    .detail-status { padding: 2px 8px; font-size: 0.6rem; }
    
    /* ALERT COMPACT FIX MOBIEL */
    .p-alerts { margin-top: 8px; gap: 5px; }
    .alert-box { 
        padding: 8px 10px;       /* Minder padding */
        font-size: 0.75rem;      /* Kleiner lettertype */
        line-height: 1.3;        /* Strakkere regels */
        border-left-width: 3px; 
    }
    
    .p-body { padding: 15px; font-size: 0.9rem; }
    .p-foot { padding: 10px 15px; }
    
    /* STAPELBAAR MOBIEL COMPACTER */
    .stapel-section { margin-bottom: 15px; padding-bottom: 10px; }
    .stapel-label { margin-bottom: 5px; font-size: 0.65rem; }
    .stapel-b { padding: 6px 10px; font-size: 0.75rem; }
    
    /* BUTTON FIXES */
    .action-row { flex-direction: row; gap: 8px; width: 100%; align-items: stretch; }
    .btn { padding: 8px 4px; font-size: 0.75rem; flex: 1; white-space: normal; text-align: center; line-height: 1.2; height: auto; }
    #d-url { display: contents; }
    .action-row button:first-child { display: none; }
    
    .m-box { padding: 25px; width: 85%; } .modal-title { font-size: 1.2rem; }
}

@media print {
    @page { margin: 2cm; size: A4 portrait; }
    html, body { height: auto !important; overflow: visible !important; background: #fff !important; color: #000 !important; width: 100% !important; margin: 0 !important; padding: 0 !important; }
    .sidebar, .header-main, .menu-btn, .sb-overlay, .app-body, .p-close, .action-row, .stapel-section, .modal, .filter-area, .fav-toggle { display: none !important; }
    .panel { position: relative !important; inset: 0 !important; width: 100% !important; height: auto !important; transform: none !important; background: #fff !important; box-shadow: none !important; display: block !important; overflow: visible !important; }
    .p-head { background: #fff !important; color: #000 !important; padding: 0 0 20px 0 !important; border-bottom: 2px solid var(--ns-dark) !important; margin-bottom: 20px !important; }
    .p-head h2 { font-size: 24pt !important; color: var(--ns-dark) !important; margin-bottom: 5px !important; }
    .p-head::before { content: "NEXT SOURCE | Subsidiewijzer"; display: block; font-size: 10pt; font-weight: 800; color: var(--ns-teal); text-transform: uppercase; margin-bottom: 15px; letter-spacing: 2px; }
    .p-meta { color: #444 !important; font-size: 10pt !important; margin-top: 10px !important; }
    .detail-status { border: 1px solid #ccc !important; background: #fff !important; color: #000 !important; }
    .p-alerts { border: 1px solid #000; padding: 10px; margin-top: 15px; font-weight: bold; }
    .p-body { padding: 0 !important; font-size: 11pt !important; line-height: 1.6 !important; color: #000 !important; }
    .p-body h2, .p-body h3 { color: var(--ns-dark) !important; margin-top: 25px !important; page-break-after: avoid; }
    .p-body p, .p-body li { orphans: 3; widows: 3; }
    .p-foot { background: #fff !important; border-top: none !important; padding: 20px 0 0 0 !important; margin-top: 30px !important; }
    #d-url { display: block !important; font-size: 9pt; color: #666; }
    #d-url a::after { content: " (" attr(href) ")"; font-size: 0.8em; }
    #d-url a { text-decoration: none; color: #000; border: none !important; padding: 0 !important; background: none !important; }
}