/**
 * Timeline View Styles
 * Vertical timeline showing documents chronologically grouped by month/year
 */

/* ============================================
   VIEW TOGGLE BUTTONS
   ============================================ */

/* Override results-info to ensure proper flex layout */
.results-info {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
}

.view-toggle-group {
    display: flex;
    gap: 0.25rem;
    background: #e2e8f0;
    padding: 0.25rem;
    border-radius: 8px;
    flex-shrink: 0;
}

.view-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: #64748b;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.view-toggle-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.5);
    color: #334155;
}

.view-toggle-btn.active {
    background: white;
    color: #667eea;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.view-toggle-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.view-icon {
    font-size: 1.1rem;
}

.view-label {
    display: none;
}

/* Show labels on larger screens */
@media (min-width: 640px) {
    .view-label {
        display: inline;
    }
}


/* ============================================
   TIMELINE CONTAINER
   ============================================ */
.timeline-container {
    position: relative;
    padding: 2rem 0;
    min-height: 400px;
}

.timeline-wrapper {
    position: relative;
    max-width: 900px;
    margin: 0 auto;
    padding-left: 60px;
}

/* The vertical timeline line with gradient */
.timeline-line {
    position: absolute;
    left: 24px;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(
        to bottom,
        #667eea 0%,
        #764ba2 50%,
        #667eea 100%
    );
    border-radius: 2px;
    box-shadow: 0 0 12px rgba(102, 126, 234, 0.3);
}


/* ============================================
   TIMELINE YEAR HEADER
   ============================================ */
.timeline-year {
    position: relative;
    margin: 2rem 0 1rem 0;
    padding-left: 1rem;
}

.timeline-year:first-child {
    margin-top: 0;
}

.timeline-year-label {
    display: inline-block;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    font-size: 1.5rem;
    font-weight: 700;
    padding: 0.5rem 1.5rem;
    border-radius: 25px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    position: relative;
    left: -40px;
}


/* ============================================
   TIMELINE MONTH HEADER
   ============================================ */
.timeline-month {
    position: relative;
    margin: 1.5rem 0 0.75rem 0;
}

.timeline-month-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: #f1f5f9;
    color: #475569;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.35rem 1rem;
    border-radius: 15px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Month dot on the timeline */
.timeline-month::before {
    content: '';
    position: absolute;
    left: -44px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background: white;
    border: 3px solid #667eea;
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2);
}


/* ============================================
   TIMELINE ITEM (Document Card)
   ============================================ */
.timeline-item {
    position: relative;
    margin-bottom: 1rem;
    opacity: 0;
    transform: translateX(-20px);
    animation: slideInTimeline 0.4s ease forwards;
}

/* Staggered animation delay - set via JS */
.timeline-item:nth-child(1) { animation-delay: 0.05s; }
.timeline-item:nth-child(2) { animation-delay: 0.1s; }
.timeline-item:nth-child(3) { animation-delay: 0.15s; }
.timeline-item:nth-child(4) { animation-delay: 0.2s; }
.timeline-item:nth-child(5) { animation-delay: 0.25s; }

@keyframes slideInTimeline {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Document type dot on the timeline */
.timeline-dot {
    position: absolute;
    left: -40px;
    top: 1.25rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #667eea;
    box-shadow: 0 0 0 3px white, 0 0 0 5px rgba(102, 126, 234, 0.3);
    transition: all 0.3s ease;
    z-index: 1;
}

/* Document type color coding */
.timeline-dot.type-brief { background: #3b82f6; }           /* Blue - Letter */
.timeline-dot.type-vertrag { background: #10b981; }         /* Green - Contract */
.timeline-dot.type-rechnung { background: #f59e0b; }        /* Yellow - Invoice */
.timeline-dot.type-genehmigung { background: #8b5cf6; }     /* Purple - Permit */
.timeline-dot.type-gutachten { background: #ef4444; }       /* Red - Expert Opinion */
.timeline-dot.type-protokoll { background: #06b6d4; }       /* Cyan - Protocol */
.timeline-dot.type-plan { background: #ec4899; }            /* Pink - Plan */
.timeline-dot.type-nachweis { background: #84cc16; }        /* Lime - Proof/Certificate */
.timeline-dot.type-antrag { background: #f97316; }          /* Orange - Application */
.timeline-dot.type-bescheid { background: #14b8a6; }        /* Teal - Notice/Decision */

/* Connecting line from dot to card */
.timeline-item::before {
    content: '';
    position: absolute;
    left: -28px;
    top: 1.5rem;
    width: 28px;
    height: 2px;
    background: linear-gradient(to right, rgba(102, 126, 234, 0.5), #e2e8f0);
}


/* ============================================
   TIMELINE CARD
   ============================================ */
.timeline-card {
    background: white;
    border-radius: 12px;
    padding: 1rem 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.timeline-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.15);
    border-color: #667eea;
}

.timeline-card:hover .timeline-dot {
    transform: scale(1.3);
    box-shadow: 0 0 0 3px white, 0 0 0 6px rgba(102, 126, 234, 0.4), 0 0 15px rgba(102, 126, 234, 0.3);
}

/* Card header with date and type */
.timeline-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.timeline-card-date {
    font-size: 0.8rem;
    color: #64748b;
    font-weight: 500;
}

.timeline-card-type {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: #f1f5f9;
    color: #475569;
}

/* Type-specific badge colors */
.timeline-card-type.type-brief { background: #dbeafe; color: #1e40af; }
.timeline-card-type.type-vertrag { background: #d1fae5; color: #065f46; }
.timeline-card-type.type-rechnung { background: #fef3c7; color: #92400e; }
.timeline-card-type.type-genehmigung { background: #ede9fe; color: #5b21b6; }
.timeline-card-type.type-gutachten { background: #fee2e2; color: #991b1b; }
.timeline-card-type.type-protokoll { background: #cffafe; color: #0e7490; }
.timeline-card-type.type-plan { background: #fce7f3; color: #9d174d; }
.timeline-card-type.type-nachweis { background: #ecfccb; color: #3f6212; }
.timeline-card-type.type-antrag { background: #ffedd5; color: #9a3412; }
.timeline-card-type.type-bescheid { background: #ccfbf1; color: #115e59; }

/* Card title */
.timeline-card-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    /* Truncate long titles */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Card metadata (sender, recipient) */
.timeline-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: #64748b;
}

.timeline-card-meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.timeline-card-meta-icon {
    opacity: 0.7;
}

/* Expanded state indicator */
.timeline-card.expanded {
    border-color: #667eea;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.2);
}

.timeline-card.expanded::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: linear-gradient(to bottom, #667eea, #764ba2);
}


/* ============================================
   TIMELINE CARD DETAILS (Expanded)
   ============================================ */
.timeline-card-details {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, margin-top 0.3s ease, padding-top 0.3s ease;
    margin-top: 0;
    padding-top: 0;
    border-top: 0 solid #e2e8f0;
}

.timeline-card.expanded .timeline-card-details {
    max-height: 500px;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top-width: 1px;
    overflow-y: auto;
}

.timeline-detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
}

.timeline-detail-item {
    font-size: 0.85rem;
}

.timeline-detail-label {
    font-weight: 600;
    color: #64748b;
    margin-bottom: 0.15rem;
}

.timeline-detail-value {
    color: #334155;
}

/* View document button */
.timeline-view-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.timeline-view-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}


/* ============================================
   TIMELINE EMPTY STATE
   ============================================ */
.timeline-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: #64748b;
}

.timeline-empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.timeline-empty p {
    font-size: 1.1rem;
}


/* ============================================
   BUILDING/GEBÄUDE VIEW
   ============================================ */
.building-container {
    padding: 1.5rem 0;
    min-height: 400px;
}

.building-content {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Building Group Card */
.building-group {
    background: white;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.building-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #f8fafc, #f1f5f9);
    border-bottom: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.2s ease;
}

.building-header:hover {
    background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
}

.building-icon {
    font-size: 2rem;
    line-height: 1;
}

.building-info {
    flex: 1;
}

.building-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0 0 0.25rem 0;
}

.building-address {
    font-size: 0.85rem;
    color: #64748b;
    margin: 0;
}

.building-count {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: #667eea;
    color: white;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.building-expand-icon {
    font-size: 1.25rem;
    color: #64748b;
    transition: transform 0.2s ease;
}

.building-group.expanded .building-expand-icon {
    transform: rotate(90deg);
}

/* Building Documents List */
.building-documents {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.building-group.expanded .building-documents {
    max-height: 2000px;
}

.building-doc-list {
    padding: 0;
    margin: 0;
    list-style: none;
}

.building-doc-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1.25rem;
    border-bottom: 1px solid #f1f5f9;
    transition: background 0.15s ease;
    cursor: pointer;
}

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

.building-doc-item:hover {
    background: #f8fafc;
}

.building-doc-date {
    min-width: 85px;
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
}

.building-doc-type {
    min-width: 100px;
}

.building-doc-title {
    flex: 1;
    font-weight: 500;
    color: #334155;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.building-doc-title:hover {
    color: #667eea;
}

/* Unknown Location Group */
.building-group.unknown-location .building-header {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
}

.building-group.unknown-location .building-icon {
    opacity: 0.6;
}

/* Document Type Sub-Groups within Buildings */
.building-type-group {
    border-bottom: 1px solid #f1f5f9;
}

.building-type-group:last-child {
    border-bottom: none;
}

.building-type-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.25rem;
    background: #fafbfc;
    cursor: pointer;
    transition: background 0.15s ease;
}

.building-type-header:hover {
    background: #f1f5f9;
}

.building-type-badge {
    min-width: 100px;
    text-align: center;
}

.building-type-count {
    font-size: 0.85rem;
    color: #64748b;
    font-weight: 500;
}

.building-type-count::before {
    content: '(';
}

.building-type-count::after {
    content: ')';
}

.building-type-expand {
    margin-left: auto;
    font-size: 0.9rem;
    color: #94a3b8;
    transition: transform 0.2s ease;
}

.building-type-group.expanded .building-type-expand {
    transform: rotate(90deg);
}

.building-type-docs {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: white;
}

.building-type-group.expanded .building-type-docs {
    max-height: 1000px;
}

.building-type-docs .building-doc-list {
    border-left: 3px solid #e2e8f0;
    margin-left: 1rem;
}

.building-type-docs .building-doc-item {
    padding-left: 1rem;
}

/* Empty State */
.building-empty {
    text-align: center;
    padding: 4rem 2rem;
    color: #64748b;
}

.building-empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.building-empty p {
    font-size: 1.1rem;
    margin: 0;
}

/* Responsive */
@media (max-width: 768px) {
    .building-header {
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .building-count {
        order: -1;
        margin-left: auto;
    }
    
    .building-doc-item {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .building-doc-date {
        min-width: auto;
    }
    
    .building-doc-type {
        min-width: auto;
    }
    
    .building-doc-title {
        width: 100%;
        flex: none;
    }
}


/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 768px) {
    .timeline-wrapper {
        padding-left: 40px;
    }
    
    .timeline-line {
        left: 12px;
        width: 3px;
    }
    
    .timeline-year-label {
        font-size: 1.2rem;
        padding: 0.4rem 1rem;
        left: -24px;
    }
    
    .timeline-month::before {
        left: -32px;
        width: 12px;
        height: 12px;
    }
    
    .timeline-dot {
        left: -30px;
        width: 10px;
        height: 10px;
    }
    
    .timeline-item::before {
        left: -20px;
        width: 20px;
    }
    
    .timeline-card {
        padding: 0.875rem 1rem;
    }
    
    .timeline-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .timeline-card-meta {
        flex-direction: column;
        gap: 0.25rem;
    }
}


/* ============================================
   DARK MODE SUPPORT (if needed later)
   ============================================ */
@media (prefers-color-scheme: dark) {
    /* Reserved for future dark mode */
}

