/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: system-ui, sans-serif; background: #f8fafc; color: #1e293b; }
button { cursor: pointer; font: inherit; border: none; }

/* ── Layout ── */
.app-header { padding: 16px 24px; background: #1e40af; color: white; display: flex; align-items: baseline; gap: 12px; }
.app-header h1 { font-size: 1.25rem; }
.subtitle { font-size: 0.85rem; opacity: 0.8; }
.loading, .error { padding: 48px; text-align: center; color: #64748b; }
.error { color: #dc2626; }
.layout { display: grid; grid-template-columns: 220px 1fr 200px; gap: 0; min-height: calc(100vh - 56px); }

/* ── Filters ── */
.sidebar-filters { padding: 16px; border-right: 1px solid #e2e8f0; background: white; overflow-y: auto; }
.filter-panel h2 { font-size: 0.75rem; text-transform: uppercase; color: #94a3b8; margin-bottom: 12px; }
.filter-group { margin-bottom: 16px; }
.filter-group h3 { font-size: 0.75rem; color: #64748b; margin-bottom: 6px; }
.filter-chip { display: inline-block; margin: 2px; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; background: #f1f5f9; color: #475569; transition: background 0.15s; }
.filter-chip.active { background: #1e40af; color: white; }
.filter-chip:hover:not(.active) { background: #e2e8f0; }

/* ── Exercise Grid ── */
.exercise-grid { padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; align-content: start; overflow-y: auto; max-height: calc(100vh - 56px); }
.no-results { grid-column: 1/-1; padding: 32px; text-align: center; color: #94a3b8; }

/* ── Exercise Card ── */
.exercise-card { background: white; border-radius: 8px; border: 2px solid transparent; box-shadow: 0 1px 3px rgba(0,0,0,.08); cursor: pointer; overflow: hidden; transition: border-color 0.15s, transform 0.1s; }
.exercise-card:hover { border-color: #93c5fd; transform: translateY(-1px); }
.exercise-card.in-basket { border-color: #22c55e; }
.card-thumb { height: 120px; background: #f1f5f9; overflow: hidden; }
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb-placeholder { height: 100%; display: flex; align-items: center; justify-content: center; color: #94a3b8; font-size: 0.75rem; }
.card-body { padding: 8px 10px; }
.card-chapter { font-weight: 600; font-size: 0.85rem; color: #1e293b; }
.card-origin { font-size: 0.72rem; color: #64748b; margin-top: 2px; }
.card-tags { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 3px; }
.tag { font-size: 0.65rem; padding: 1px 6px; border-radius: 3px; }
.tag-topic { background: #dcfce7; color: #166534; }
.tag-chapter { background: #dbeafe; color: #1e40af; }
.tag-auto-label { font-size: 0.65rem; color: #94a3b8; }
.card-actions { padding: 6px 10px 10px; }
.btn-add { width: 100%; padding: 5px; background: #eff6ff; color: #1e40af; border-radius: 5px; font-size: 0.8rem; }
.btn-add:hover { background: #1e40af; color: white; }
.badge-added { display: block; text-align: center; font-size: 0.78rem; color: #16a34a; padding: 4px; }

/* ── Basket ── */
.sidebar-basket { padding: 16px; border-left: 1px solid #e2e8f0; background: white; display: flex; flex-direction: column; }
.basket-panel h2 { font-size: 0.75rem; text-transform: uppercase; color: #94a3b8; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.basket-count { font-weight: normal; }
.warning { font-size: 0.75rem; color: #b45309; background: #fef3c7; padding: 6px 8px; border-radius: 4px; margin-bottom: 10px; }
.basket-slots { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.basket-slot { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 5px; font-size: 0.78rem; }
.basket-slot.filled { background: #f1f5f9; }
.basket-slot.empty { border: 1px dashed #cbd5e1; color: #94a3b8; }
.slot-num { width: 18px; height: 18px; background: #1e40af; color: white; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.65rem; flex-shrink: 0; }
.slot-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot-remove { color: #94a3b8; font-size: 0.75rem; padding: 0 4px; }
.slot-remove:hover { color: #dc2626; }
.slot-placeholder { flex: 1; font-style: italic; }
.btn-export { margin-top: 16px; padding: 10px; background: #1e40af; color: white; border-radius: 6px; font-size: 0.85rem; }
.btn-export:hover:not(:disabled) { background: #1e3a8a; }
.btn-export:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Modal Carousel ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-content { background: white; border-radius: 10px; width: min(90vw, 800px); max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.modal-header { padding: 12px 16px; border-bottom: 1px solid #e2e8f0; display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.modal-origin { color: #64748b; font-size: 0.85rem; }
.modal-actions { display: flex; gap: 8px; align-items: center; }
.btn-remove { padding: 5px 12px; background: #fee2e2; color: #dc2626; border-radius: 5px; font-size: 0.8rem; }
.btn-close { padding: 5px 10px; color: #64748b; font-size: 1rem; }
.carousel { flex: 1; display: flex; align-items: center; gap: 8px; padding: 12px; overflow: hidden; }
.carousel-prev, .carousel-next { font-size: 2rem; color: #94a3b8; padding: 0 8px; background: none; flex-shrink: 0; }
.carousel-prev:hover:not(:disabled), .carousel-next:hover:not(:disabled) { color: #1e40af; }
.carousel-prev:disabled, .carousel-next:disabled { opacity: 0.2; cursor: default; }
.carousel-image { flex: 1; overflow-y: auto; max-height: 60vh; }
.carousel-image img { width: 100%; display: block; }
.carousel-dots { display: flex; justify-content: center; gap: 6px; padding: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; cursor: pointer; }
.dot.active { background: #1e40af; }
.modal-tags { padding: 10px 16px; border-top: 1px solid #e2e8f0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-input { border: 1px solid #cbd5e1; border-radius: 4px; padding: 2px 8px; font-size: 0.75rem; width: 120px; }
.tag-add { width: 80px; color: #94a3b8; }
