/* --- DARK MODE CONFIGURATIE (VARIABELEN) --- */
:root {
    /* Standaard Kleuren (Light Mode) */
    --temp-bg-page: #ffffff;
    --temp-card-bg: #ffffff;
    --temp-text-main: #1e293b;
    --temp-text-muted: #64748b;
    --temp-border: #e2e8f0;
    --temp-shadow: rgba(0, 0, 0, 0.02);

    /* Knoppen Light Mode */
    --btn-delete-bg: #fff5f5;
    --btn-delete-text: #ff4757;
    --btn-delete-border: #ffe3e3;

    /* Vaste elementen */
    --accent-blue: #54c3ea;
}

/* Systeem-gebaseerde Dark Mode */
@media (prefers-color-scheme: dark) {
    :root:not(.light-mode-forced) {
        --temp-bg-page: #161c24; /* Jouw gevraagde kleur */
        --temp-card-bg: #1e252e; /* Iets lichter dan de bg voor diepte */
        --temp-text-main: #f1f5f9;
        --temp-text-muted: #94a3b8;
        --temp-border: #2d333b;
        --temp-shadow: rgba(0, 0, 0, 0.4);

        /* Knoppen Dark Mode */
        --btn-delete-bg: #4c1010;
        --btn-delete-text: #fecaca;
        --btn-delete-border: #7f1d1d;

        --accent-blue: #3BA7D9;
    }
}

/* Handmatige Dark Mode switch */
body.dark-mode {
    --temp-bg-page: #161c24;
    --temp-card-bg: #1e252e;
    --temp-text-main: #f1f5f9;
    --temp-text-muted: #94a3b8;
    --temp-border: #2d333b;
    --temp-shadow: rgba(0, 0, 0, 0.4);

    --btn-delete-bg: #4c1010;
    --btn-delete-text: #fecaca;
    --btn-delete-border: #7f1d1d;

    --accent-blue: #3BA7D9;
}

/* --- CONTAINER VOOR DE GRID --- */
.templates-container {
    padding: 20px;
    animation: fadeIn 0.4s ease-out;
    background-color: var(--temp-bg-page);
    min-height: 100vh;
    transition: background-color 0.3s ease;
}

/* --- DE GRID VAN KAARTEN --- */
.template-cards-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
    margin-top: 30px;
}

/* --- DE INDIVIDUELE LIJST KAART --- */
.template-card {
    background: var(--temp-card-bg);
    border: 1px solid var(--temp-border);
    border-radius: 20px;
    padding: 25px;
    display: flex;
    flex-direction: column;
    min-height: 200px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--temp-shadow);
}

.template-card:hover {
    transform: translateY(-8px);
    border-color: var(--accent-blue);
    box-shadow: 0 15px 30px rgba(59, 167, 217, 0.2);
}

.template-card h3 {
    margin: 0 0 10px 0;
    color: var(--temp-text-main);
    font-size: 1.5rem;
    font-weight: 800;
}

.template-card p {
    color: var(--temp-text-muted);
    font-weight: 500;
    margin-bottom: 20px;
}

/* --- KNOPPEN ONDERAAN UITLIJNEN --- */
.button-wrapper {
    margin-top: auto;
    display: flex;
    gap: 12px;
}

.view-template-button, .delete-template-button {
    flex: 1;
    padding: 12px;
    border-radius: 12px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-align: center;
}

/* View/Open knop gebruikt de accent kleur */
.view-template-button {
    background-color: var(--accent-blue);
    color: white;
}

.delete-template-button {
    background-color: var(--btn-delete-bg);
    color: var(--btn-delete-text);
    border: 1px solid var(--btn-delete-border);
}

.delete-template-button:hover {
    background-color: #ff4757;
    color: white;
}

.button-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.search-bar {
    width: 200px;
    margin: 0 !important;
}

/* --- FILTER DROPDOWN --- */
.custom-filter-dropdown {
    appearance: none;
    -webkit-appearance: none;
    background-color: var(--temp-card-bg);
    /* SVG icon kleur aangepast voor leesbaarheid in donker via %23 (hex) */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding: 10px 40px 10px 15px;
    border: 1px solid var(--temp-border);
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--temp-text-main);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 150px;
}

.custom-filter-dropdown:hover {
    background-color: var(--temp-bg-page);
    border-color: var(--temp-text-muted);
}

.custom-filter-dropdown:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(84, 195, 234, 0.1);
}

/* Browser opties styling (selectie lijst) */
.custom-filter-dropdown option {
    background-color: var(--temp-card-bg);
    color: var(--temp-text-main);
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- MEDIA QUERIES (MOBIEL) --- */
@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
        margin-bottom: 25px;
        border-bottom: 1px solid var(--temp-border);
    }

    .button-container {
        display: flex;
        flex-wrap: wrap;
        flex-direction: row;
        gap: 10px;
        width: 100%;
    }

    .search-bar {
        width: 100% !important;
        max-width: none !important;
        margin-right: 0 !important;
        flex: 0 0 100%;
        order: 1;
    }

    .custom-filter-dropdown {
        flex: 1;
        order: 2;
        margin-right: 0 !important;
        min-width: 0;
    }

    .new-template-btn {
        flex: 1;
        order: 3;
        margin-right: 0 !important;
        padding: 10px 5px;
        text-align: center;
        justify-content: center;
        display: flex;
        align-items: center;
        background-color: var(--accent-blue);
        color: white;
        border-radius: 10px;
        border: none;
        font-weight: bold;
    }
}