@font-face {
    font-family: 'Inter';
    src: url('fonts/inter.woff2') format('woff2');
    font-weight: 100 900;
    font-style: normal;
    font-display: swap;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #161616;
    background: #f4f4f4;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.app {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.navbar {
    display: flex;
    align-items: center;
    padding: 0 32px;
    height: 72px;
    background: white;
    box-shadow: 0px 1px 3px rgba(22, 22, 22, 0.32);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    color: #F05D5E;
}

.nav-items {
    display: flex;
    align-items: center;
    margin-left: 32px;
    padding-left: 16px;
    border-left: 1px solid rgba(22, 22, 22, 0.16);
    height: 48px;
}

.source-select {
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font-size: 14px;
    font-family: inherit;
    background: white;
    cursor: pointer;
    min-width: 200px;
}

.source-select:hover {
    border-color: #9ca3af;
}

.source-select:focus {
    outline: none;
    border-color: #F05D5E;
    box-shadow: 0 0 0 2px rgba(240, 93, 94, 0.2);
}

.nav-spacer {
    flex: 1;
}

.container {
    display: flex;
    flex: 1;
    min-height: 0;
}

.sidebar {
    width: 280px;
    min-width: 280px;
    background: white;
    border-right: 1px solid #ddd;
    overflow-y: auto;
    padding: 12px 0;
}

.content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: white;
}

.placeholder {
    color: #888;
    text-align: center;
    padding: 60px 20px;
}

/* Tree styles */
.tree-node {
    user-select: none;
}

.tree-node-header {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    cursor: pointer;
    gap: 6px;
}

.tree-node-header:hover {
    background: #f0f0f0;
}

.tree-node-header.selected {
    background: #e8f0fe;
    color: #1a73e8;
}

.tree-toggle {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #666;
    flex-shrink: 0;
}

.tree-toggle.expanded {
    transform: rotate(90deg);
}

.tree-toggle.hidden {
    visibility: hidden;
}

.tree-label {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-code {
    font-size: 11px;
    color: #888;
    margin-left: 4px;
}

.tree-children {
    padding-left: 20px;
}

.tree-children.collapsed {
    display: none;
}

/* Detail view styles */
.detail-header {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid #F05D5E;
}

.breadcrumb {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
}

.breadcrumb a {
    color: #1a73e8;
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.detail-title {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.detail-code {
    font-size: 14px;
    color: #F05D5E;
    font-weight: 500;
}

.detail-meta {
    display: flex;
    gap: 16px;
    margin-top: 12px;
    font-size: 13px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.badge {
    background: #F05D5E;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.badge.grundanspruch {
    background: #2e7d32;
}

.detail-description {
    margin: 20px 0;
    padding: 16px;
    background: #fafafa;
    border-radius: 8px;
    white-space: pre-wrap;
}

/* Children list */
.children-section {
    margin-top: 24px;
}

.children-section h3 {
    font-size: 16px;
    margin-bottom: 12px;
    color: #666;
}

.child-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 16px;
    background: #fafafa;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.child-item:hover {
    background: #e8f0fe;
}

.child-code {
    font-weight: 600;
    color: #F05D5E;
    min-width: 80px;
    flex-shrink: 0;
}

.child-title {
    flex: 1;
}

.child-badges {
    display: flex;
    gap: 6px;
    margin-left: 12px;
}

/* Cycle columns layout */
.cycle-columns {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-top: 20px;
}

.cycle-column {
    background: #fafafa;
    border-radius: 8px;
    padding: 16px;
}

.cycle-column h4 {
    font-size: 14px;
    color: #666;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid;
}

.cycle-column.cycle-1 h4 { border-color: #ffcc80; }
.cycle-column.cycle-2 h4 { border-color: #a5d6a7; }
.cycle-column.cycle-3 h4 { border-color: #90caf9; }

.cycle-item {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    cursor: pointer;
}

.cycle-item:last-child {
    border-bottom: none;
}

.cycle-item:hover {
    color: #1a73e8;
}

/* Grouped sections (LP21-style) */
.grouped-sections {
    margin-top: 20px;
}

.section-group {
    margin-bottom: 24px;
}

.section-header {
    font-size: 18px;
    color: #F05D5E;
    padding-bottom: 8px;
    border-bottom: 2px solid #F05D5E;
    margin-bottom: 12px;
    cursor: pointer;
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.section-header:hover {
    color: #a01830;
}

.section-code {
    font-weight: 700;
    min-width: 24px;
}

.section-title {
    font-weight: 500;
}

.section-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.section-item-wrapper {
    margin-bottom: 8px;
}

.section-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s;
    gap: 8px;
}

.section-item:hover {
    background: #e8f0fe;
    border-color: #1a73e8;
}

.section-item.expanded {
    background: #e8f0fe;
    border-color: #1a73e8;
    border-radius: 4px 4px 0 0;
}

.section-item.empty {
    color: #888;
    cursor: default;
}

.section-item.empty:hover {
    background: #fafafa;
    border-color: #e0e0e0;
}

.item-toggle {
    font-size: 10px;
    color: #666;
    transition: transform 0.2s;
    width: 16px;
}

.item-toggle.expanded {
    transform: rotate(90deg);
}

.item-number {
    font-weight: 600;
    color: #666;
    min-width: 28px;
    flex-shrink: 0;
}

.item-text {
    flex: 1;
}

.item-content {
    border: 1px solid #1a73e8;
    border-top: none;
    border-radius: 0 0 4px 4px;
    padding: 16px;
    background: #fff;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.item-content.collapsed {
    display: none;
}

/* Inline cycle columns */
.inline-cycles {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.inline-cycle {
    background: #f8f9fa;
    border-radius: 4px;
    padding: 12px;
}

.inline-cycle-header {
    font-weight: 600;
    font-size: 13px;
    color: #666;
    padding-bottom: 8px;
    margin-bottom: 8px;
    border-bottom: 2px solid;
}

.inline-cycle.cycle-1 .inline-cycle-header { border-color: #ffcc80; }
.inline-cycle.cycle-2 .inline-cycle-header { border-color: #a5d6a7; }
.inline-cycle.cycle-3 .inline-cycle-header { border-color: #90caf9; }

.inline-cycle-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.inline-cycle-item {
    font-size: 13px;
}

.inline-cycle-item-header {
    font-weight: 600;
    color: #F05D5E;
    margin-bottom: 6px;
    cursor: pointer;
}

.inline-cycle-item-header:hover {
    text-decoration: underline;
}

.inline-cycle-children {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-left: 8px;
}

.inline-cycle-child {
    display: flex;
    gap: 6px;
    font-size: 12px;
    line-height: 1.4;
    color: #333;
    cursor: pointer;
}

.inline-cycle-child:hover {
    color: #1a73e8;
}

.inline-cycle-child.grundanspruch {
    font-weight: 500;
}

.inline-cycle-child .child-marker {
    color: #F05D5E;
    flex-shrink: 0;
}

.inline-cycle-empty {
    color: #888;
    font-size: 13px;
}

.inline-empty {
    color: #888;
    padding: 12px;
    text-align: center;
}

.inline-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.inline-item {
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.inline-item:hover {
    background: #e8f0fe;
}

/* Kompetenz grid (LP21-style detailed view) */
.kompetenz-grid {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

/* Fach cycle timeline chart */
.fach-cycle-chart {
    margin: 24px 0;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

.cycle-header-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
}

.cycle-header {
    padding: 12px 16px;
    text-align: center;
    border-left: 1px solid #ddd;
}

.cycle-header.cycle-1 {
    border-top: 4px solid #e6b84d;
}

.cycle-header.cycle-2 {
    border-top: 4px solid #8fbc8f;
}

.cycle-header.cycle-3 {
    border-top: 4px solid #87ceeb;
}

.cycle-header-title {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.cycle-header-subtitle {
    font-size: 11px;
    color: #666;
}

.fach-rows {
    display: flex;
    flex-direction: column;
}

.fach-cycle-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    min-height: 36px;
    border-bottom: 1px solid #eee;
}

.fach-cycle-row:last-child {
    border-bottom: none;
}

.fach-bar {
    display: flex;
    align-items: center;
    padding: 8px 16px;
    font-weight: 500;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: filter 0.15s;
}

.fach-bar:hover {
    filter: brightness(0.95);
}

.fach-cell-empty {
    background: #fafafa;
}

/* Band structure - cycles and transitions */
.kompetenz-band {
    display: flex;
}

/* Kompetenz sections (Aufbau grouping) */
.kompetenz-section {
    margin-bottom: 32px;
}

.kompetenz-section.highlighted {
    animation: highlight-fade 2s ease-out;
}

@keyframes highlight-fade {
    0% { background: rgba(196, 30, 58, 0.15); }
    100% { background: transparent; }
}

.kompetenz-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #ddd;
}

.section-title-text {
    font-size: 16px;
    font-weight: 500;
    font-style: italic;
    color: #666;
}

.section-code-badge {
    background: #F05D5E;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.section-intro {
    font-size: 14px;
    color: #333;
}

/* Cycle bands */
.cycle-band.cycle-1 {
    background: #fef6e9;
}

.cycle-band.cycle-2 {
    background: #eef7ef;
}

.cycle-band.cycle-3 {
    background: #e9f4fb;
}

/* Transition bands - indented, floating between cycles */
.transition-band {
    margin: 4px 8px 4px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}

.transition-band.transition-1-2 {
    background: linear-gradient(135deg, #fef6e9 0%, #f5f9f5 100%);
}

.transition-band.transition-2-3 {
    background: linear-gradient(135deg, #eef7ef 0%, #f0f7fc 100%);
}

/* Band indicator column */
.band-indicator {
    width: 48px;
    min-width: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
}

.cycle-indicator.cycle-1 {
    background: #e6a800;
}

.cycle-indicator.cycle-2 {
    background: #7cb342;
}

.cycle-indicator.cycle-3 {
    background: #42a5f5;
}

.transition-indicator {
    width: 36px;
    min-width: 36px;
    background: linear-gradient(160deg, var(--from-color) 0%, var(--from-color) 45%, var(--to-color) 55%, var(--to-color) 100%);
    border-radius: 8px 0 0 8px;
}

.transition-indicator.transition-1-2 {
    --from-color: #e6a800;
    --to-color: #7cb342;
}

.transition-indicator.transition-2-3 {
    --from-color: #7cb342;
    --to-color: #42a5f5;
}

.indicator-text {
    font-size: 24px;
    font-weight: 300;
}

.transition-indicator .indicator-text {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.band-rows {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.kompetenz-row {
    display: flex;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    min-height: 40px;
}

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

.kompetenz-row-wrapper {
    position: relative;
}

.kompetenz-row.grundanspruch {
    background: rgba(0, 0, 0, 0.06);
}

.orientierungspunkt-line {
    position: relative;
    height: 20px;
    display: flex;
    align-items: center;
    margin: 0 -12px;
    padding: 0 12px;
}

.orientierungspunkt-line::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 2px;
    background: repeating-linear-gradient(
        to right,
        #F05D5E 0,
        #F05D5E 8px,
        transparent 8px,
        transparent 12px
    );
}

.orientierungspunkt-circle {
    position: relative;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #F05D5E;
    border: 3px solid #fff;
    box-shadow: 0 0 0 2px #F05D5E;
    z-index: 1;
    margin-left: -8px;
}

.row-letter {
    width: 40px;
    min-width: 40px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 10px;
    font-weight: 700;
    font-size: 14px;
    color: #F05D5E;
    border-right: 1px solid rgba(0, 0, 0, 0.1);
}

.row-items {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 8px 12px;
    gap: 4px;
}

.kompetenz-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    line-height: 1.5;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s;
}

.kompetenz-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.item-bullet {
    color: #F05D5E;
    font-weight: 700;
    flex-shrink: 0;
}

.item-description {
    flex: 1;
}

.orientierungspunkt-marker {
    color: #F05D5E;
    font-size: 10px;
    margin-left: 4px;
}

.kompetenz-item.orientierungspunkt {
    font-weight: 500;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 40px;
    color: #888;
}

.loading::after {
    content: "...";
    animation: dots 1.5s infinite;
}

@keyframes dots {
    0%, 20% { content: "."; }
    40% { content: ".."; }
    60%, 100% { content: "..."; }
}

/* Media search panel */
.media-panel {
    position: absolute;
    left: 20px;
    right: 20px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 100;
    max-height: 500px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.media-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: #f5f5f5;
    border-bottom: 1px solid #ddd;
    font-weight: 500;
}

.media-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #666;
    padding: 0 4px;
}

.media-close:hover {
    color: #333;
}

.media-loading {
    padding: 40px;
    text-align: center;
    color: #888;
}

.media-error {
    padding: 20px;
    color: #F05D5E;
}

.media-results {
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.media-card {
    padding: 12px 16px;
    background: #fafafa;
    border-radius: 8px;
    border: 1px solid #eee;
}

.media-card:hover {
    background: #f0f0f0;
}

.media-card-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
}

.media-card-subtitle {
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
}

.media-card-desc {
    font-size: 13px;
    color: #555;
    line-height: 1.5;
    margin-bottom: 8px;
}

.media-card-meta {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 12px;
    color: #888;
}

.media-card-meta .badge {
    font-size: 10px;
}

.media-id {
    font-family: monospace;
    color: #999;
}

/* Footer */
.app-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 32px;
    color: #6b7280;
    font-size: 13px;
    line-height: 1.6;
}

.footer-edupool {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.footer-logo {
    width: 32px;
    height: 32px;
}

.footer-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.footer-text p {
    margin: 0 0 8px;
}

.footer-text p:last-child {
    margin-bottom: 0;
}

.footer-text a {
    color: #0ea5e9;
    text-decoration: none;
}

.footer-text a:hover {
    text-decoration: underline;
}

.footer-content {
    display: flex;
    gap: 48px;
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.footer-links a {
    color: #6b7280;
    text-decoration: none;
}

.footer-links a:hover {
    color: #374151;
}

@media (max-width: 768px) {
    .app-footer {
        flex-direction: column;
        gap: 24px;
        padding: 24px;
    }

    .footer-content {
        gap: 32px;
    }

    .navbar {
        padding: 0 16px;
        height: 60px;
    }

    .nav-items {
        margin-left: 16px;
        padding-left: 12px;
    }

    .source-select {
        min-width: 150px;
    }
}
