:root {
    /* Colors */
    --bg-color: #f8f9fa;
    --sidebar-bg: #ffffff;
    --sidebar-alt: #f1f3f5;
    --card-bg: #ffffff;
    --text-main: #212529;
    --text-muted: #6c757d;
    --primary: #0d6efd;
    --primary-hover: #0a58ca;
    --success: #198754;
    --error: #dc3545;
    --border-color: #dee2e6;
    --nav-bg: #ffffff;
    --mox-purple: #4b2c6d;
    
    /* Spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    
    /* Shadows & Borders */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.08);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
    
    /* Layout */
    --navbar-height: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
}

.hidden { display: none !important; }
.w-full { width: 100% !important; }

/* --- ATOMS --- */
.btn {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-sm);
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-xs);
    font-size: 0.9rem;
}
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-secondary { background: var(--text-muted); color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border-color); color: var(--text-main); }
.btn-outline:hover { background: #f1f3f5; }
.btn-sm { padding: 0.35rem 0.8rem; font-size: 0.8rem; }

.btn-icon { background: transparent; border: none; cursor: pointer; font-size: 1.1rem; padding: 2px 5px; border-radius: 4px; }
.btn-icon:hover { background: #eee; }

.card { background: var(--card-bg); border-radius: var(--radius-md); border: 1px solid var(--border-color); overflow: hidden; cursor:pointer; }

/* --- NAVBAR --- */
.navbar {
    background-color: var(--nav-bg);
    border-bottom: 1px solid var(--border-color);
    height: var(--navbar-height);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
}
.nav-container { max-width: 1400px; width: 100%; margin: 0 auto; display: flex; justify-content: space-between; padding: 0 var(--space-lg); }
.brand { font-size: 1.25rem; font-weight: bold; color: var(--text-main); text-decoration: none; }
.nav-links { display: flex; gap: var(--space-lg); }
.nav-link { text-decoration: none; color: var(--text-muted); font-weight: 500; padding: var(--space-xs) 0; border-bottom: 2px solid transparent; }
.nav-link.active { color: var(--primary); border-bottom-color: var(--primary); }

/* --- DISCOVERY HEADER & SEARCH --- */
.page-header { text-align: center; margin-bottom: 3rem; margin-top: 1rem; }
.page-header h1 { font-size: 2.2rem; margin-bottom: 0.5rem; color: var(--text-main); }
.page-header p { color: var(--text-muted); font-size: 1rem; }

.search-bar { margin-top: 2rem; max-width: 600px; margin-inline: auto; position: relative; }
.search-bar input {
    width: 100%; padding: 1rem 1.5rem; padding-left: 3.5rem; border-radius: 50px;
    border: 1px solid var(--border-color); font-size: 1.05rem; background: white;
    box-shadow: var(--shadow-sm); transition: all 0.2s ease;
}
.search-bar input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(13, 110, 253, 0.1); }
.search-bar::before { content: "🔍"; position: absolute; left: 1.4rem; top: 50%; transform: translateY(-50%); font-size: 1.1rem; opacity: 0.5; }

.filter-bar { display: flex; justify-content: center; gap: 1rem; margin-top: 1.5rem; }

/* --- PAGE LAYOUTS --- */
.view-container { max-width: 1200px; margin: var(--space-xl) auto; padding: 0 var(--space-lg); }
.view-container-wide { max-width: 1600px; margin: 0 auto; padding: 0 var(--space-lg); }
.view-container-full { height: calc(100vh - var(--navbar-height)); overflow: hidden; }

/* --- DISCOVERY GRID --- */
.discovery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--space-xl); margin-top: 3rem; }
.deck-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.deck-card-image { 
    height: 160px; 
    position: relative;
    overflow: hidden;
    display: flex; 
    align-items: center; 
    justify-content: center; 
    border-bottom: 1px solid var(--border-color);
    background: #f1f3f5; /* Light gray base */
    transition: background 0.3s ease;
}

.deck-card-image.has-art {
    background: #1a1a1a; /* Dark base when art is expected/loaded */
}

.deck-card-art-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover;
    background-position: center;
    filter: blur(4px) brightness(0.6); /* Slightly darker for better logo contrast */
    transform: scale(1.1);
    z-index: 1;
    opacity: 0;
    transition: opacity 0.5s ease;
}

.deck-card-image.has-art .deck-card-art-bg {
    opacity: 1;
}

.deck-card-logo { 
    max-width: 60px; 
    position: relative;
    z-index: 2;
    transition: filter 0.3s ease;
    filter: brightness(0.1); /* Default dark logo */
}

.deck-card-image.has-art .deck-card-logo {
    filter: brightness(0) invert(1) drop-shadow(0 2px 5px rgba(0,0,0,0.5)); 
}

.deck-card-content { padding: var(--space-md); background: white; position: relative; z-index: 3; }

/* --- MOXFIELD DETAIL LAYOUT --- */
/* --- NIEUWE HEADER STYLING (MOXFIELD VIBE) --- */

.mox-banner {
    width: 100%;
    /* Een mooie diepe paarse gradient */
    background: linear-gradient(to right, rgba(75, 44, 109, 1) 0%, rgba(100, 60, 140, 0.9) 100%), var(--mox-purple);
    color: white;
    padding: 1.5rem 0 2.5rem 0;
    margin-bottom: 0;
}

.mox-banner-content {
    max-width: 1600px; /* Zelfde als je .view-container-wide */
    margin: 0 auto;
    padding: 0 var(--space-lg);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
}

/* Subtiele styling voor de Back-knop in de donkere banner */
.btn-text-light {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0 0 1rem 0;
    transition: color 0.2s ease;
}

.btn-text-light:hover {
    color: white;
}

.mox-deck-title {
    font-size: 2.5rem;
    font-weight: 800;
    margin: 0;
    line-height: 1.2;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.mox-deck-tags {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.25rem;
}

.mox-tag {
    background: rgba(255, 255, 255, 0.15);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    backdrop-filter: blur(4px);
    color: #e2d9f3;
}

/* --- ACTIEBALK ONDER DE BANNER --- */
.mox-action-bar {
    background-color: var(--sidebar-alt); /* Lichtgrijze balk */
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 0;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-sm);
}

.mox-action-content {
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 var(--space-lg);
    display: flex;
    justify-content: flex-start; /* Of 'flex-end' als je de knop rechts wil hebben */
}

/* Clean styling voor de print knop */
.btn-mox-action {
    background: white;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: all 0.2s ease;
}

.btn-mox-action:hover {
    background: #f8f9fa;
    border-color: #caced1;
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.btn-mox-action .icon {
    font-size: 1.1rem;
}
.detail-header-row { display: flex; justify-content: space-between; align-items: center; padding: 1.5rem 0; margin-bottom: 1rem; }
.title-section { display: flex; align-items: center; }
.deck-title-meta h1 { font-size: 1.5rem; margin: 0; line-height: 1.2; }
.deck-title-meta span { font-size: 0.85rem; color: var(--text-muted); }

.moxfield-main-layout { display: grid; grid-template-columns: 280px 1fr; gap: 3rem; align-items: start; margin-bottom: 4rem; }
.moxfield-sidebar { position: sticky; top: calc(var(--navbar-height) + 1.5rem); width: 280px; }
.card-image-wrapper { width: 100%; margin-bottom: 1rem; }
.card-image-wrapper img { width: 100%; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); background: #222; aspect-ratio: 63/88; display: block; }

.card-name-label { font-weight: 700; text-align: center; margin-top: 1rem; color: var(--text-main); font-size: 0.9rem; }
.card-price-display { margin-top: 1rem; background: white; padding: 0.75rem; border-radius: var(--radius-sm); border: 1px solid var(--border-color); text-align: center; }
.price-label { font-size: 0.7rem; text-transform: uppercase; color: var(--text-muted); font-weight: 800; display: block; margin-bottom: 2px; }
.price-value { font-size: 1.1rem; font-weight: 800; color: var(--primary); }

/* Row 2 Controls */
.deck-control-bar {
    display: flex; justify-content: space-between; align-items: center; background: white;
    padding: 0.6rem 1.25rem; border-radius: var(--radius-md); border: 1px solid var(--border-color);
    margin-bottom: 2rem; box-shadow: var(--shadow-sm);
}
.control-group { display: flex; gap: 2rem; }
.dropdown-select-group { display: flex; align-items: center; gap: 0.5rem; font-size: 0.85rem; color: var(--text-muted); }
.minimal-select {
    border: 1px solid var(--border-color); background: white; font-weight: 700; color: var(--text-main); cursor: pointer; font-size: 0.85rem;
    padding: 0.4rem 2rem 0.4rem 0.8rem; border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: calc(100% - 0.5rem) center;
}
.minimal-select:focus { outline: none; border-color: var(--primary); }

.decklist-columns-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2rem; }
.deck-col { display: flex; flex-direction: column; gap: 2.5rem; }
.type-group h3 { font-size: 0.7rem; text-transform: uppercase; color: var(--text-muted); border-bottom: 1px solid var(--border-color); padding-bottom: 4px; margin-bottom: 0.75rem; letter-spacing: 1.2px; display: flex; justify-content: space-between; font-weight: 800; }
.card-item { display: flex; align-items: center; padding: 4px 0; font-size: 0.85rem; cursor: pointer; color: var(--text-main); transition: color 0.1s; }
.card-item:hover { color: var(--primary); }
.card-count { color: var(--text-muted); min-width: 25px; font-weight: 500; }
.card-name { flex-grow: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Mana */
.mana-cost { display: flex; gap: 2px; margin-left: 0.5rem; }
.mana-symbol { width: 14px; height: 14px; border-radius: 50%; display: inline-block; font-size: 0.6rem; text-align: center; line-height: 14px; font-weight: bold; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.mana-symbol.W { background: #f9faf4; color: #000; }
.mana-symbol.U { background: #0e68ab; color: #fff; }
.mana-symbol.B { background: #150b00; color: #fff; }
.mana-symbol.R { background: #d3202a; color: #fff; }
.mana-symbol.G { background: #00733e; color: #fff; }
.mana-symbol.N { background: #969798; color: #000; }
.card-arrow { color: #ccc; margin-left: 0.5rem; font-size: 0.7rem; }

/* --- CUSTOM PRINT LAYOUT --- */
.app-layout { display: flex; height: 100%; background: #f1f3f5; }
.sidebar { width: var(--sidebar-width, 350px); min-width: 300px; max-width: 45vw; background: var(--sidebar-bg); display: flex; flex-direction: column; z-index: 10; }
.sidebar-header { padding: 1.5rem; border-bottom: 1px solid var(--border-color); }
.sidebar-header h2 { font-size: 1.1rem; color: var(--text-main); }
.sidebar-header p { font-size: 0.8rem; color: var(--text-muted); }
.sidebar-section { padding: 1.5rem; border-bottom: 1px solid var(--border-color); }
.decklist-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; }
.decklist-header label { font-size: 0.85rem; font-weight: bold; color: var(--text-muted); text-transform: uppercase; }
textarea { width: 100%; min-height: 200px; padding: 0.75rem; border-radius: 6px; border: 1px solid var(--border-color); background: #fdfdfd; font-family: monospace; font-size: 0.85rem; resize: none; }
.sidebar-scroll-area { flex-grow: 1; overflow-y: auto; padding: 1.5rem; }
.settings-group { margin-bottom: 2rem; }
.settings-group h4 { font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); margin-bottom: 1rem; letter-spacing: 0.5px; border-bottom: 1px solid #f1f3f5; padding-bottom: 5px; }
.setting-row { margin-bottom: 0.75rem; }
.setting-row.inline { display: flex; align-items: center; justify-content: space-between; font-size: 0.85rem; }
.checkbox-label { display: flex; align-items: center; gap: 0.6rem; font-size: 0.85rem; cursor: pointer; color: var(--text-main); }
.sidebar-footer { padding: 1.5rem; border-top: 1px solid var(--border-color); display: flex; flex-direction: column; gap: 0.75rem; background: #fafafa; }
.resizer { width: 4px; background: #dee2e6; cursor: col-resize; transition: background 0.2s; position: relative; }
.resizer:hover, .resizer.resizing { background: var(--primary); }
.resizer-line { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 2px; height: 40px; background: #adb5bd; border-radius: 2px; }

/* --- PRINT CONTENT AREA --- */
.main-content { flex-grow: 1; padding: 2rem; overflow-y: auto; background: #f8f9fa; }
.print-toolbar { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 2.5rem; padding-bottom: 1.5rem; border-bottom: 2px solid #eee; }
.print-stats { display: flex; gap: 2rem; }
.p-stat { display: flex; flex-direction: column; align-items: flex-end; }
.p-stat span { font-size: 0.7rem; text-transform: uppercase; color: var(--text-muted); font-weight: bold; }
.p-stat strong { font-size: 1.2rem; color: var(--text-main); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1.5rem; }
.card-preview { border-radius: 10px; box-shadow: var(--shadow-md); position: relative; }
.card-preview img { width: 100%; border-radius: 10px; display: block; }
.empty-state-visual { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 60%; color: #adb5bd; text-align: center; }
.empty-icon { font-size: 4rem; margin-bottom: 1.5rem; opacity: 0.3; }

/* Modals */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); display: flex; justify-content: center; align-items: center; z-index: 1000; backdrop-filter: blur(2px); }
.modal { background: white; border-radius: var(--radius-md); width: 450px; max-width: 90vw; box-shadow: var(--shadow-lg); }
.modal-header { padding: 1rem 1.5rem; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 1.5rem; max-height: 70vh; overflow-y: auto; }
.saved-deck-item { display: flex; justify-content: space-between; align-items: center; background: #f8f9fa; padding: 1rem; border-radius: 8px; border: 1px solid #eee; margin-bottom: 0.5rem; cursor: pointer; }

/* Pagination */
.pagination-container { display: flex; justify-content: center; align-items: center; gap: 0.5rem; margin: 4rem 0; padding-bottom: 2rem; }
.pagination-btn {
    background: white; border: 1px solid var(--border-color); padding: 0.6rem 1rem; border-radius: var(--radius-sm);
    cursor: pointer; font-weight: 600; font-size: 0.85rem; transition: all 0.15s ease; color: var(--text-main);
}
.pagination-btn:hover:not(:disabled) { background-color: var(--primary); color: white; border-color: var(--primary); }
.pagination-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.page-info { font-size: 0.9rem; color: var(--text-muted); margin: 0 1rem; font-weight: 500; }

/* --- UTILS --- */
.loading-state { grid-column: 1 / -1; text-align: center; padding: 6rem 2rem; color: var(--text-muted); font-style: italic; font-size: 1.1rem; }

.empty-results {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6rem 2rem;
    text-align: center;
    background: white;
    border-radius: var(--radius-lg);
    border: 2px dashed var(--border-color);
    color: var(--text-muted);
    margin-top: 2rem;
}

.empty-results::before {
    content: "🔎";
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    display: block;
    opacity: 0.5;
}

.empty-results h3 { color: var(--text-main); margin-bottom: 0.5rem; }

.error-banner { background: #f8d7da; color: #842029; padding: 1rem; border-radius: 6px; margin-bottom: 1rem; }

/* Loader */
.loader { border: 2px solid rgba(255,255,255,0.3); border-radius: 50%; border-top: 2px solid #fff; width: 14px; height: 14px; animation: spin 1s linear infinite; margin-left: 8px; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

@media (max-width: 1000px) { .decklist-columns-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 800px) {
    .app-layout { flex-direction: column; height: auto; overflow: visible; }
    .sidebar { width: 100%; max-width: 100%; }
    .resizer { display: none; }
    .view-container-full { height: auto; overflow: visible; }
}
