/* ================================================================
   VERKEERSBORDEN — Dedicated stylesheet
   Module: driving_school (shared across templates, see tokens.css)
   ================================================================ */

/* ---- Filter bar ---- */
.ts-filter-bar {
    position: sticky;
    top: 65px;
    z-index: 100;
    background: #fff;
    border-bottom: 1px solid var(--ds-line);
    box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

/* ---- Toolbar row ---- */
.ts-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 0 10px;
    flex-wrap: wrap;
}

.ts-search-wrap {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 520px;
}
.ts-search-wrap svg {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ds-muted);
    pointer-events: none;
}
.ts-search-wrap input {
    width: 100%;
    padding: 12px 44px 12px 46px;
    border: 1.5px solid var(--ds-line);
    border-radius: 999px;
    font-size: .95rem;
    outline: none;
    font-family: inherit;
    color: var(--ds-ink);
    transition: border-color .2s, box-shadow .2s;
    background: #fff;
}
.ts-search-wrap input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px var(--color-primary-90);
}
.ts-search-clear {
    display: none;
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--ds-muted);
    padding: 4px;
    line-height: 0;
}

.ts-quiz-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 20px;
    border-radius: 999px;
    border: 1.5px solid var(--ds-line);
    background: #fff;
    font-size: .88rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    color: var(--ds-ink);
    cursor: pointer;
    white-space: nowrap;
    transition: background .18s, border-color .18s, color .18s;
    flex-shrink: 0;
}
.ts-quiz-btn:hover,
.ts-quiz-btn.active {
    background: var(--ds-ink);
    border-color: var(--ds-ink);
    color: #fff;
}

/* ---- Two-column layout ---- */
.ts-layout {
    display: flex;
    align-items: flex-start;
    gap: 28px;
    padding-top: 28px;
    padding-bottom: 80px;
}
.ts-main { flex: 1; min-width: 0; }

/* ---- Sidebar ---- */
.ts-sidebar {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: 150px;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--ds-line) transparent;
}
.ts-sidebar-inner {
    background: #fff;
    border-radius: var(--ds-radius);
    box-shadow: var(--ds-shadow);
    border: 1px solid var(--ds-line);
    padding: 10px 8px 14px;
}
.ts-sidebar-section-label {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--ds-muted);
    padding: 10px 12px 5px;
}
.ts-sidebar-divider {
    height: 1px;
    background: var(--ds-line);
    margin: 8px 12px;
}
.ts-sidebar-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    border-radius: var(--ds-radius-sm);
    padding: 8px 12px;
    font-family: 'Inter', sans-serif;
    font-size: .875rem;
    font-weight: 500;
    color: var(--ds-ink-soft);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.ts-sidebar-item:hover {
    background: var(--ds-bg-alt);
    color: var(--ds-ink);
}
.ts-sidebar-item.active {
    background: var(--color-primary-90);
    color: var(--color-primary);
    font-weight: 600;
}
.ts-sb-label { flex: 1; }
.ts-sidebar-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--item-color, var(--ds-muted));
    flex-shrink: 0;
    opacity: .6;
    transition: opacity .15s;
}
.ts-sidebar-item:hover .ts-sidebar-dot,
.ts-sidebar-item.active .ts-sidebar-dot { opacity: 1; }
.ts-sidebar-count {
    margin-left: auto;
    font-size: .72rem;
    font-weight: 600;
    color: var(--ds-muted);
    background: var(--ds-bg-alt);
    border-radius: 999px;
    padding: 1px 7px;
    flex-shrink: 0;
}
.ts-sidebar-item.active .ts-sidebar-count {
    background: rgba(255,255,255,0.7);
    color: var(--color-primary);
}

/* ---- Mobile filter dropdown ---- */
.ts-mobile-filter {
    display: none;
    position: relative;
    margin-bottom: 14px;
}
.ts-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    background: #fff;
    border: 1.5px solid var(--ds-line);
    border-radius: var(--ds-radius);
    padding: 11px 16px;
    font-family: 'Inter', sans-serif;
    font-size: .95rem;
    font-weight: 600;
    color: var(--ds-ink);
    cursor: pointer;
    text-align: left;
    transition: border-color .18s, box-shadow .18s;
}
.ts-dropdown-btn.open,
.ts-dropdown-btn:focus-visible {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-90);
    outline: none;
}
.ts-dropdown-chevron {
    margin-left: auto;
    flex-shrink: 0;
    color: var(--ds-muted);
    transition: transform .22s ease;
}
.ts-dropdown-btn.open .ts-dropdown-chevron { transform: rotate(180deg); }
.ts-dropdown-panel {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0; right: 0;
    background: #fff;
    border: 1.5px solid var(--ds-line);
    border-radius: var(--ds-radius);
    box-shadow: var(--ds-shadow-md);
    padding: 8px;
    z-index: 200;
    max-height: 55vh;
    overflow-y: auto;
}
.ts-dropdown-panel.open { display: block; animation: panelIn .18s ease; }
@keyframes panelIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: none; }
}

/* ---- Meta bar (count + progress) ---- */
.ts-meta-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding-top: 0;
    padding-bottom: 12px;
}
.ts-meta-bar p {
    font-size: .9rem;
    color: var(--ds-muted);
    margin: 0;
}
.ts-progress-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: .82rem;
    color: var(--ds-muted);
}
.ts-progress-bar {
    width: 120px;
    height: 6px;
    background: var(--ds-line);
    border-radius: 999px;
    overflow: hidden;
}
.ts-progress-fill {
    height: 100%;
    background: #10b981;
    border-radius: 999px;
    width: 0%;
    transition: width .4s ease;
}

/* ---- Grid ---- */
.ts-grid-container {
    padding-top: 0;
}
.ts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
}

/* ---- Cards ---- */
.ts-card {
    background: #fff;
    border-radius: var(--ds-radius);
    box-shadow: var(--ds-shadow);
    border: 1.5px solid var(--ds-line);
    padding: 14px 10px 12px;
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease, border-color .2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
    outline: none;
    position: relative;
}
.ts-card:hover,
.ts-card:focus-visible {
    transform: translateY(-4px);
    box-shadow: var(--ds-shadow-md);
    border-color: var(--color-primary);
}
.ts-card.is-learned {
    border-color: #10b981;
}

/* Star button on card */
.ts-card-star {
    position: absolute;
    top: 7px;
    right: 7px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    line-height: 0;
    opacity: 0;
    transition: opacity .18s, transform .18s;
    color: #d1d5db;
    z-index: 1;
}
.ts-card:hover .ts-card-star,
.ts-card.is-starred .ts-card-star { opacity: 1; }
.ts-card.is-starred .ts-card-star { color: #f59e0b; }
.ts-card-star:hover { transform: scale(1.25); }

/* Learned badge on card */
.ts-card-learned-badge {
    position: absolute;
    top: 7px;
    left: 7px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #10b981;
    color: #fff;
    font-size: .68rem;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.ts-card.is-learned .ts-card-learned-badge { display: flex; }

.ts-img-wrap {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.ts-img-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}
.ts-img-fallback {
    width: 80px;
    height: 80px;
    border-radius: 12px;
    background: var(--ds-bg-alt);
    color: var(--ds-muted);
    font-size: 1.6rem;
    display: none;
    align-items: center;
    justify-content: center;
}
.ts-code {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: .85rem;
    color: var(--ds-ink);
    line-height: 1.2;
    word-break: break-all;
}

/* ---- Empty state ---- */
.ts-empty {
    display: none;
    text-align: center;
    padding: 80px 20px;
}
.ts-empty-icon { font-size: 3rem; margin-bottom: 16px; }
.ts-empty h3 { color: var(--ds-ink); margin-bottom: 8px; }
.ts-empty p { color: var(--ds-muted); }

/* ---- Modal overlay ---- */
.ts-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1050;
    padding: 20px;
    box-sizing: border-box;
    align-items: center;
    justify-content: center;
}
.ts-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20,22,40,0.55);
    backdrop-filter: blur(4px);
}

/* ---- Modal box ---- */
.ts-modal-box {
    position: relative;
    background: #fff;
    border-radius: var(--ds-radius-lg);
    box-shadow: var(--ds-shadow-lg);
    width: 100%;
    max-width: 480px;
    height: min(90vh, 580px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1;
    animation: modalIn .25s ease;
    touch-action: pan-y;
}

.ts-modal-strip {
    height: 6px;
    border-radius: var(--ds-radius-lg) var(--ds-radius-lg) 0 0;
    flex-shrink: 0;
}

/* Modal header: action icons */
.ts-modal-header {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    padding: 12px 14px 0;
    flex-shrink: 0;
}
.ts-icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--ds-bg-alt);
    border: none;
    cursor: pointer;
    display: grid;
    place-items: center;
    color: var(--ds-muted);
    transition: background .18s, color .18s, transform .15s;
    line-height: 0;
}
.ts-icon-btn:hover { background: var(--ds-line); color: var(--ds-ink); }
.ts-icon-btn.ts-close-btn:hover { background: #fee2e2; color: #ef4444; }
.ts-icon-btn.starred { color: #f59e0b; background: #fef3c7; }
.ts-icon-btn.learned { color: #10b981; background: #d1fae5; }

/* ---- Modal content (scrollable) ---- */
.ts-modal-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    transition: opacity .18s ease, transform .18s ease;
}
.ts-modal-content.slide-out-left  { opacity: 0; transform: translateX(-28px); }
.ts-modal-content.slide-out-right { opacity: 0; transform: translateX(28px); }
.ts-modal-content.slide-in-left   { opacity: 0; transform: translateX(28px); }
.ts-modal-content.slide-in-right  { opacity: 0; transform: translateX(-28px); }

.ts-modal-inner {
    margin: auto;
    padding: 20px 32px 28px;
    width: 100%;
}

.ts-modal-img-wrap {
    width: 150px;
    height: 150px;
    margin: 0 auto 22px;
    background: var(--ds-bg-alt);
    border-radius: var(--ds-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.ts-modal-img-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: opacity .15s ease;
}

.ts-modal-meta { text-align: center; }

.ts-modal-cat {
    display: inline-block;
    font-size: .72rem;
    font-weight: 600;
    letter-spacing: .1em;
    text-transform: uppercase;
    padding: 4px 14px;
    border-radius: 999px;
    margin-bottom: 10px;
}
.ts-modal-code {
    font-size: 1.6rem;
    margin-bottom: 14px;
    color: var(--ds-ink);
}
.ts-modal-desc {
    color: var(--ds-muted);
    font-size: .97rem;
    line-height: 1.75;
    text-align: left;
    margin: 0;
}

/* ---- Modal nav footer ---- */
.ts-modal-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px 18px;
    border-top: 1px solid var(--ds-line);
    gap: 12px;
    flex-shrink: 0;
}
.ts-nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--ds-bg-alt);
    border: 1.5px solid var(--ds-line);
    border-radius: 999px;
    padding: 9px 18px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: .85rem;
    color: var(--ds-ink);
    transition: border-color .18s, background .18s, color .18s;
}
.ts-nav-btn:hover:not(:disabled) { border-color: var(--ds-ink); background: var(--ds-ink); color: #fff; }
.ts-nav-btn:disabled { opacity: .35; cursor: not-allowed; }
.ts-modal-counter {
    font-size: .82rem;
    color: var(--ds-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

/* ---- Animations ---- */
@keyframes modalIn {
    from { opacity: 0; transform: scale(.94) translateY(12px); }
    to   { opacity: 1; transform: none; }
}

/* ---- Responsive ---- */
@media (max-width: 991px) {
    /* Switch to single-column: sidebar hidden, mobile dropdown shown */
    .ts-layout { flex-direction: column; gap: 0; padding-top: 16px; }
    .ts-sidebar  { display: none; }
    .ts-mobile-filter { display: block; }
}

@media (max-width: 480px) {
    .ts-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
    .ts-img-wrap { width: 70px; height: 70px; }
    .ts-modal-inner { padding: 16px 20px 20px; }
    .ts-modal-box { height: min(92vh, 560px); }
    .ts-card-star { opacity: .3; }
    .ts-card.is-starred .ts-card-star { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    .ts-modal-content { transition: none; }
    @keyframes modalIn  { from { opacity:1; transform:none; } }
    @keyframes panelIn  { from { opacity:1; transform:none; } }
}
