/* Lesson Browser - Standalone lesson browsing component
   Used by plan pages for adding individual lessons.
   Prefixed with .lb- to avoid conflicts with teacher dashboard styles.
*/

/* ============================================
   OVERLAY
   ============================================ */

.lesson-browser-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: flex-end;
    justify-content: center;
}

.lesson-browser-overlay.active {
    display: flex;
}

.lesson-browser-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.lesson-browser-panel {
    position: relative;
    background: white;
    border-radius: 16px 16px 0 0;
    max-width: 540px;
    width: 100%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
    animation: lb-slide-up 0.25s ease-out;
}

@keyframes lb-slide-up {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.lesson-browser-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.lesson-browser-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.lesson-browser-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #f1f5f9;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    transition: background 0.15s;
}

.lesson-browser-close:hover {
    background: #e2e8f0;
}

#lesson-browser-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* ============================================
   FILTERS
   ============================================ */

.lb-filters {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    flex-shrink: 0;
}

.lb-search {
    position: relative;
    margin-bottom: 10px;
}

.lb-search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 14px;
}

.lb-search-input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    background: white;
    box-sizing: border-box;
}

.lb-search-input:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.lb-filter-row {
    display: flex;
    gap: 8px;
}

.lb-filter-select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    cursor: pointer;
}

.lb-published-toggle {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 10px;
    font-size: 13px;
    color: #4b5563;
    cursor: pointer;
}

/* ============================================
   TOOLBAR (Expand All / Collapse All)
   ============================================ */

.lb-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 6px 16px;
    border-bottom: 1px solid #f3f4f6;
}

.lb-expand-toggle {
    border: none;
    background: none;
    color: #3b82f6;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s;
}

.lb-expand-toggle:hover {
    background: #eff6ff;
}

/* ============================================
   DONE FOOTER
   ============================================ */

.lb-done-footer {
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: white;
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
}

.lb-done-btn {
    width: 100%;
    padding: 12px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.lb-done-btn:hover {
    background: #059669;
}

/* ============================================
   CONTENT & EMPTY/LOADING STATES
   ============================================ */

.lb-content {
    padding: 8px 0;
}

.lb-loading,
.lb-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    color: #6b7280;
    text-align: center;
}

.lb-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #e5e7eb;
    border-top-color: #10b981;
    border-radius: 50%;
    animation: lb-spin 1s linear infinite;
    margin-bottom: 12px;
}

@keyframes lb-spin {
    to { transform: rotate(360deg); }
}

.lb-empty-icon {
    font-size: 40px;
    margin-bottom: 8px;
}

.lb-empty h3 {
    margin: 0 0 6px 0;
    color: #1e293b;
    font-size: 15px;
}

.lb-empty p {
    margin: 0;
    font-size: 13px;
}

/* ============================================
   PILLAR ACCORDION
   ============================================ */

.lb-accordion {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
}

.lb-pillar {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.lb-pillar-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: #f9fafb;
    border: none;
    cursor: pointer;
    text-align: left;
    font-size: 14px;
    transition: background 0.15s;
}

.lb-pillar-header:hover {
    background: #e5e7eb;
}

.lb-expand-icon {
    font-size: 10px;
    color: #9ca3af;
    width: 12px;
    flex-shrink: 0;
}

.lb-pillar-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.lb-pillar-name {
    font-weight: 600;
    color: #1e293b;
    flex: 1;
}

.lb-pillar-count {
    font-size: 12px;
    color: #9ca3af;
    font-weight: 400;
}

.lb-pillar-content {
    display: none;
    border-top: 1px solid #e5e7eb;
}

.lb-pillar-content.expanded {
    display: block;
}

/* ============================================
   SKILL SUITE SUB-ACCORDION
   ============================================ */

.lb-suite {
    border-bottom: 1px solid #e5e7eb;
}

.lb-suite:last-child {
    border-bottom: none;
}

.lb-suite-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    cursor: pointer;
    background: #f9fafb;
    transition: background 0.15s;
}

.lb-suite-header:hover {
    background: #f3f4f6;
}

.lb-suite-toggle {
    font-size: 10px;
    color: #9ca3af;
    width: 12px;
}

.lb-suite-name {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
}

.lb-suite-count {
    font-size: 11px;
    color: #9ca3af;
}

.lb-suite-lessons {
    padding-left: 20px;
    background: white;
}

/* ============================================
   LESSON ROWS
   ============================================ */

.lb-lesson-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid #f3f4f6;
    transition: background 0.15s;
}

.lb-lesson-row:last-child {
    border-bottom: none;
}

.lb-lesson-row:not(.lb-lesson-disabled):not(.lb-lesson-excluded):hover {
    background: rgba(0, 0, 0, 0.03);
}

.lb-lesson-icon {
    font-size: 18px;
    flex-shrink: 0;
    width: 24px;
    text-align: center;
}

.lb-lesson-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.lb-lesson-title {
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-lesson-meta {
    display: flex;
    gap: 8px;
    align-items: center;
}

.lb-lesson-level {
    font-size: 10px;
    font-weight: 600;
}

.lb-status-badge {
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.lb-status-badge.published {
    background: #d1fae5;
    color: #065f46;
}

.lb-status-badge.planned {
    background: #e0e7ff;
    color: #4338ca;
}

.lb-in-plan-tag {
    font-size: 9px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: #f3f4f6;
    color: #9ca3af;
    text-transform: uppercase;
}

/* Disabled states */
.lb-lesson-disabled {
    opacity: 0.5;
    cursor: default;
}

.lb-lesson-excluded {
    opacity: 0.5;
    cursor: default;
}

/* Action buttons */
.lb-lesson-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    opacity: 0.5;
    transition: opacity 0.15s;
}

.lb-lesson-row:hover .lb-lesson-actions {
    opacity: 1;
}

.lb-btn-preview,
.lb-btn-add {
    width: 28px;
    height: 28px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: all 0.15s;
}

.lb-btn-preview:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}

.lb-btn-add {
    background: #10b981;
    border-color: #10b981;
    color: white;
    font-weight: 700;
}

.lb-btn-add:hover {
    background: #059669;
    border-color: #059669;
}

/* Flat search-results list (search by name → titles in a list, no pillar drilling) */
.lb-flat-count { font-size: 12px; font-weight: 700; color: #6B7280; padding: 4px 2px 10px; }
.lb-lesson-suite { font-size: 11px; color: #6B7280; font-weight: 600; }
.lb-flat .lb-lesson-icon { display: none; }
