/* =========================
   Schritt-Explorer Styles
   ========================= */

:root {
    --brand: #615f4e;
    --brand-light: #aeac99;
    --brand-lighter: #f5f4f0;
    --brand-kreativ: #e69b41;
    --text-dark: #333;
    --text-muted: #666;
    --bg-light: #f0f2f5;
    --white: #fff;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: 0.3s ease;
}

/* =========================
   Body & Container
   ========================= */

.explorer-body {
    display: block;
    background: var(--bg-light);
}

.explorer-container {
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
    background: var(--white);
    position: relative;
}

/* =========================
   Header
   ========================= */

.explorer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-bottom: 1px solid #eee;
    background: var(--white);
    position: sticky;
    top: 0;
    z-index: 100;
}

.back-link {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--brand);
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.back-link:hover {
    background: var(--brand-lighter);
}

.explorer-logo {
    height: 50px;
    width: auto;
}

/* =========================
   Step Selector
   ========================= */

.step-selector {
    padding: 20px 24px;
    background: var(--brand-lighter);
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    gap: 16px;
}

.step-selector label {
    font-weight: 600;
    color: var(--text-dark);
}

.step-selector select {
    flex: 1;
    max-width: 500px;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid var(--brand-light);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--text-dark);
    cursor: pointer;
    transition: var(--transition);
}

.step-selector select:hover,
.step-selector select:focus {
    border-color: var(--brand);
    outline: none;
}

/* =========================
   Main Content
   ========================= */

.explorer-main {
    padding: 24px;
    min-height: calc(100vh - 200px);
}

/* Step Header */
.step-header {
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--brand-lighter);
}

.step-header.hidden {
    display: none;
}

.step-header h1 {
    font-size: 28px;
    color: var(--brand);
    margin: 0 0 12px 0;
}

.step-description {
    font-size: 16px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 16px;
}

.step-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    display: inline-block;
    padding: 4px 12px;
    background: var(--brand-lighter);
    color: var(--brand);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

/* =========================
   Entity Groups
   ========================= */

.entity-groups {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: var(--text-muted);
    text-align: center;
}

.loading-placeholder i {
    font-size: 48px;
    margin-bottom: 16px;
    color: var(--brand-light);
}

.loading-placeholder.error i {
    color: #e74c3c;
}

.entity-group {
    background: var(--white);
}

/* Show More Button */
.show-more-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 20px;
    margin-top: 12px;
    background: var(--brand-lighter);
    border: 2px dashed var(--brand-light);
    border-radius: var(--radius-sm);
    color: var(--brand);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.show-more-btn:hover {
    background: var(--brand-light);
    color: var(--white);
    border-style: solid;
}

.show-more-btn.expanded {
    background: var(--brand);
    color: var(--white);
    border-color: var(--brand);
    border-style: solid;
}

.show-more-btn i {
    transition: transform 0.3s ease;
}

.show-more-btn.expanded i {
    transform: rotate(180deg);
}

.entity-group-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 16px 0;
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
}

.group-icon {
    font-size: 24px;
}

.group-label {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-dark);
}

.group-count {
    color: var(--text-muted);
    font-weight: normal;
}

/* =========================
   Entity Cards
   ========================= */

.entity-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.entity-card {
    background: var(--white);
    border: 1px solid #e0e0e0;
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: var(--transition);
}

.entity-card:hover {
    border-color: var(--brand);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.card-icon {
    font-size: 18px;
}

.card-id {
    font-size: 12px;
    color: var(--text-muted);
    background: var(--brand-lighter);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 8px 0;
    line-height: 1.4;
}

.card-preview {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* =========================
   Detail Panel
   ========================= */

.detail-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 550px;
    height: 100vh;
    background: var(--white);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow: hidden;
}

.detail-panel:not(.hidden) {
    transform: translateX(0);
}

.detail-panel.hidden {
    pointer-events: none;
}

.detail-panel-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.close-detail-btn {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: none;
    background: var(--brand-lighter);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-dark);
    transition: var(--transition);
    z-index: 10;
}

.close-detail-btn:hover {
    background: var(--brand-light);
    color: var(--white);
}

.detail-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 60px 12px 24px;
    border-bottom: 1px solid #eee;
}

.detail-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: var(--brand);
    color: var(--white);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
}

.detail-id {
    font-family: monospace;
    font-size: 13px;
    color: var(--text-muted);
    background: var(--brand-lighter);
    padding: 4px 10px;
    border-radius: 4px;
}

.detail-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0;
    padding: 16px 24px;
    line-height: 1.3;
}

.detail-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 24px 24px;
}

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

.detail-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--brand);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 8px 0;
}

.detail-text {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-dark);
}

.detail-text p {
    margin: 0 0 12px 0;
}

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

.detail-text blockquote {
    margin: 0;
    padding: 16px 20px;
    background: var(--brand-lighter);
    border-left: 4px solid var(--brand);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-style: italic;
}

.detail-text blockquote p {
    margin: 0;
}

/* Typ Badge (for Konzepte) */
.typ-badge {
    display: inline-block;
    padding: 4px 12px;
    background: #e8e8e8;
    color: #666;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.typ-badge.kern {
    background: var(--brand);
    color: white;
}

/* Info Lines (Erzähler, Sprecher, Rolle) */
.info-line {
    margin-bottom: 12px;
    font-size: 14px;
}

.info-label {
    font-weight: 600;
    color: var(--brand);
}

.info-value {
    color: var(--text-dark);
}

/* Tags Section */
.detail-tags {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid #eee;
}

.tags-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.detail-tag {
    display: inline-block;
    padding: 3px 10px;
    background: var(--brand-lighter);
    color: var(--brand);
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

/* Practice Details */
.practice-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.practice-item {
    font-size: 14px;
    color: var(--text-dark);
}

.practice-item strong {
    color: var(--brand);
}

/* Sources Section */
.detail-sources {
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.sources-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sources-label i {
    font-size: 12px;
    opacity: 0.7;
}

.sources-list {
    margin: 0;
    padding: 0 0 0 18px;
    list-style-type: disc;
}

.sources-list li {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.6;
    padding: 2px 0;
}

/* Process Steps */
.process-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.process-step {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--brand-lighter);
    border-radius: var(--radius-sm);
    border-left: 4px solid var(--brand);
}

.step-number {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--brand);
    color: var(--white);
    font-weight: 700;
    font-size: 14px;
    border-radius: 50%;
}

.step-content {
    flex: 1;
    min-width: 0;
}

.step-name {
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.step-description {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
}

.detail-meta {
    background: var(--brand-lighter);
    padding: 16px;
    border-radius: var(--radius-sm);
}

.meta-item {
    font-size: 14px;
    color: var(--text-dark);
    margin-bottom: 6px;
}

.meta-item:last-child {
    margin-bottom: 0;
}

.meta-item strong {
    color: var(--brand);
}

/* Relations */
.detail-relations {
    padding: 0 24px;
}

.relation-group {
    margin-bottom: 16px;
}

.relation-group h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin: 0 0 8px 0;
}

.relation-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.relation-link {
    padding: 6px 12px;
    background: var(--brand-lighter);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--brand);
    font-size: 13px;
    font-family: monospace;
    cursor: pointer;
    transition: var(--transition);
}

.relation-link:hover {
    background: var(--brand);
    color: var(--white);
}

/* Actions */
.detail-actions {
    padding: 16px 24px;
    border-top: 1px solid #eee;
    background: var(--white);
}

.chat-about-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    background: var(--brand);
    color: var(--white);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.chat-about-btn:hover {
    background: var(--text-dark);
    transform: translateY(-1px);
}

/* =========================
   Chat Panel
   ========================= */

.chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    max-width: 550px;
    height: 100vh;
    background: var(--white);
    box-shadow: var(--shadow-lg);
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.chat-panel:not(.hidden) {
    transform: translateX(0);
}

.chat-panel.hidden {
    pointer-events: none;
}

.chat-panel-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chat-panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    background: var(--brand);
    color: var(--white);
}

.back-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--white);
    transition: var(--transition);
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-context-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-context-info span:first-child {
    font-size: 12px;
    opacity: 0.8;
}

.chat-context-info span:last-child {
    font-weight: 600;
}

.chat-panel-header .close-detail-btn {
    position: static;
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
}

.chat-panel-header .close-detail-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.6;
    font-size: 15px;
}

.chat-message.bot-message {
    align-self: flex-start;
    background: var(--brand);
    color: var(--white);
}

.chat-message.user-message {
    align-self: flex-end;
    background: var(--brand-light);
    color: var(--white);
}

.chat-message p {
    margin: 0 0 8px 0;
}

.chat-message p:last-child {
    margin-bottom: 0;
}

.typing-indicator {
    display: flex;
    gap: 4px;
}

.typing-indicator i {
    font-size: 8px;
    animation: typingBounce 1s infinite;
}

.typing-indicator i:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator i:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% { opacity: 0.3; }
    30% { opacity: 1; }
}

.error-message {
    color: #e74c3c;
}

.waiting-message {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255, 255, 255, 0.9);
    font-style: italic;
}

.waiting-message i {
    font-size: 14px;
}

/* Chat Input */
.chat-input-area {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid #eee;
    background: var(--white);
}

.chat-input-area textarea {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: var(--radius-sm);
    font-size: 15px;
    resize: none;
    font-family: inherit;
    transition: var(--transition);
}

.chat-input-area textarea:focus {
    border-color: var(--brand);
    outline: none;
}

.chat-send-btn {
    width: 48px;
    height: 48px;
    border: none;
    background: var(--brand);
    color: var(--white);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.chat-send-btn:hover:not(:disabled) {
    background: var(--text-dark);
}

.chat-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* =========================
   Overlay
   ========================= */

.panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.panel-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: auto;
}

.panel-overlay.hidden {
    display: none;
}

body.panel-open {
    overflow: hidden;
}

/* =========================
   Responsive
   ========================= */

@media (max-width: 768px) {
    .explorer-header {
        padding: 12px 16px;
    }

    .back-link span {
        display: none;
    }

    .step-selector {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 16px;
    }

    .step-selector select {
        max-width: none;
    }

    .explorer-main {
        padding: 16px;
    }

    .step-header h1 {
        font-size: 22px;
    }

    .entity-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 500px) {
    .entity-cards {
        grid-template-columns: 1fr;
    }

    .detail-panel,
    .chat-panel {
        max-width: none;
    }
}

/* =========================
   Animations
   ========================= */

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

.entity-card {
    animation: fadeIn 0.3s ease-out;
}

.entity-group:nth-child(1) .entity-card { animation-delay: 0.05s; }
.entity-group:nth-child(2) .entity-card { animation-delay: 0.1s; }
.entity-group:nth-child(3) .entity-card { animation-delay: 0.15s; }
.entity-group:nth-child(4) .entity-card { animation-delay: 0.2s; }
