/* =========================================
   Frontend Train Status - Main Layout
   ========================================= */

/* Container & Font Globals */
.train-status-section {
    font-family: 'Arial', sans-serif;
    /* Link to site font if needed */
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    color: #333;
}

.train-status-container {
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    overflow: hidden;
    padding: 1rem;
}

/* Header & Navigation */
.train-frontend-header {
    display: flex;
    justify-content: center;
    /* Center everything */
    align-items: center;
    gap: 1.5rem;
    /* Arrows near title */
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #D40054;
    position: relative;
}

.train-frontend-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: #D40054;
    text-transform: uppercase;
    font-weight: 700;
    min-width: 200px;
    /* Prevent jump */
    text-align: center;
}

.frontend-nav-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #555;
    transition: all 0.2s;
}

.frontend-nav-btn:hover {
    background-color: #D40054;
    border-color: #D40054;
    color: white;
}

/* Filters */
.train-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    padding: 0.5rem 0;
    margin-bottom: 1rem;
    border-bottom: 1px solid #eee;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-group strong {
    margin-right: 0.5rem;
    font-size: 0.9rem;
    color: #555;
}

.filter-label {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
}

.filter-label input[type="checkbox"] {
    accent-color: #D40054;
    width: 16px;
    height: 16px;
}

/* Legend */
.status-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
    color: #666;
    padding: 0.5rem;
    background: #f9f9f9;
    border-radius: 4px;
}

.legend-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.legend-label {
    font-weight: bold;
    color: #333;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.legend-dot.green {
    background-color: #28a745;
}

.legend-dot.yellow {
    background-color: #ffc107;
}

.legend-dot.red {
    background-color: #dc3545;
}

.station-flag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 0.7rem;
    font-weight: bold;
    color: white;
    background-color: #666;
    /* Default neutral */
    border-radius: 50%;
}

/* Calendar Grid */
.train-frontend-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-top: 1px solid #ddd;
    border-left: 1px solid #ddd;
}

.grid-header-cell {
    background-color: #f8f9fa;
    color: #333;
    font-weight: bold;
    text-align: center;
    padding: 10px;
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
}

.day-short {
    display: none;
}

@media (max-width: 768px) {
    .day-full {
        display: none;
    }

    .day-short {
        display: inline;
    }
}

.grid-day-cell {
    position: relative;
    cursor: pointer;
    transition: background-color 0.2s ease;
    min-height: 65px;
    border-right: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    padding: 5px;
    background: white;
}

.grid-day-cell:hover {
    background-color: #fff5f8;
    /* Light pink tint on hover */
}

.grid-day-cell.other-month {
    background-color: #fcfcfc;
    opacity: 0.5;
    pointer-events: none;
}

.grid-day-cell.today {
    background-color: #fff9fa;
    box-shadow: inset 0 0 0 2px #D40054;
}

.day-number {
    font-weight: bold;
    font-size: 0.9rem;
    color: #555;
    margin-bottom: 5px;
    text-align: right;
}

.today .day-number {
    color: #D40054;
}

/* Icon on Hover */
.clickable-day:hover::after {
    content: '\f002';
    /* FontAwesome Search Icon */
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    position: absolute;
    bottom: 5px;
    right: 5px;
    color: #D40054;
    opacity: 0.3;
    font-size: 0.8rem;
}

/* Buy Ticket Button */
.btn-buy-ticket {
    background-color: #28a745;
    /* Green for action */
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: bold;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    transition: background-color 0.2s;
    margin-right: 1rem;
    /* Space from close button */
}

.btn-buy-ticket:hover {
    background-color: #218838;
}

.btn-buy-ticket i {
    font-size: 0.8rem;
}

/* Compact Train View Blocks */
.day-blocks-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    /* Reduced gap since we add padding/border */
}

.direction-block-compact {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 0;
    /* Increased padding slightly */
}

/* Add separator line between blocks */
.direction-block-compact:not(:first-child) {
    border-top: 1px solid #f0f0f0;
}

.direction-arrow {
    font-size: 0.7rem;
    color: #999;
    width: 12px;
    text-align: center;
}

.compact-train-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}



.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid white;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
}

.status-green {
    background-color: #28a745;
}

.status-yellow {
    background-color: #ffc107;
}

.status-red {
    background-color: #dc3545;
}

.no-trains-small {
    font-size: 0.75rem;
    color: #999;
    text-align: center;
    margin-top: 10px;
    font-style: italic;
}

/* Popup Styles */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
}

.popup-content {
    background: white;
    width: 95%;
    max-width: 900px;
    max-height: 90vh;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: popupFadeIn 0.2s ease-out;
}

@keyframes popupFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.popup-header {
    background: #D40054;
    color: white;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.popup-header h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.close-popup-btn {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.close-popup-btn:hover {
    opacity: 1;
}

.popup-body {
    padding: 1.5rem;
    display: flex;
    gap: 1.5rem;
    overflow-y: auto;
    flex: 1;
    background-color: #f4f6f8;
}

.popup-direction-col {
    flex: 1;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 1rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
    height: fit-content;
    /* Ensure it wraps content */
}

.popup-direction-col h3 {
    margin-top: 0;
    border-bottom: 2px solid #D40054;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    text-align: center;
    color: #333;
    font-size: 1.1rem;
}

.popup-train-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.popup-train-item {
    background: white;
    border: 1px solid #eee;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

/* Status colored left border */
.popup-train-item.status-green {
    border-left: 4px solid #28a745;
}

.popup-train-item.status-yellow {
    border-left: 4px solid #ffc107;
}

.popup-train-item.status-red {
    border-left: 4px solid #dc3545;
}

/* Train Item Layout */
.train-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #eee;
    background: #fff;
}

.train-time {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
}

.train-status-badge {
    padding: 4px 10px;
    border-radius: 12px;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
}

.badge-green {
    background-color: #28a745;
}

.badge-yellow {
    background-color: #ffc107;
    color: #333;
}

.badge-red {
    background-color: #dc3545;
}

.train-details-table {
    padding: 10px 15px;
    background: #f9f9f9;
    font-size: 0.9rem;
}

.train-station-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px dotted #e0e0e0;
    color: #555;
}

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

.station-name {
    flex: 1;
}

.station-time {
    font-weight: 600;
    color: #333;
}

.train-main-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    border-bottom: 1px solid #f0f0f0;
}

.train-time-big {
    font-size: 1.2rem;
    font-weight: bold;
    color: #333;
}

.status-badge {
    padding: 3px 10px;
    border-radius: 12px;
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    text-transform: uppercase;
}

.status-badge.green {
    background-color: #28a745;
}

.status-badge.yellow {
    background-color: #ffc107;
}

.status-badge.red {
    background-color: #dc3545;
}

.train-full-schedule {
    font-size: 0.85rem;
    color: #555;
    background: #fafafa;
    padding: 10px 15px;
}

.schedule-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px dotted #e0e0e0;
}

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

.sched-station {
    color: #666;
}

.sched-time {
    font-weight: 600;
    color: #333;
}

.no-trains-msg {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 2rem;
}

/* Status Icon (Mobile Only by default) */
.day-status-icon {
    display: none;
    font-size: 1.5rem;
    margin-top: 10px;
    text-align: center;
}

.day-status-icon.icon-green {
    color: var(--color-acc);
}

.day-status-icon.icon-red {
    color: var(--color-dark);
}

/* Train Count (Mobile) */
.train-count {
    display: none;
    font-size: 0.8rem;
    font-weight: bold;
    color: #555;
    background: #f0f0f0;
    padding: 0 4px;
    border-radius: 4px;
    line-height: 1;
}

/* Mobile Intro (Hidden by default) */
.mobile-calendar-intro {
    display: none;
    text-align: center;
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f9f9f9;
    border-radius: 8px;
    border: 1px solid #eee;
}

.mobile-calendar-intro h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
    color: #333;
}

.mobile-calendar-intro p {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}

/* Mobile Responsive */
@media (max-width: 768px) {

    /* Show Mobile Intro */
    .mobile-calendar-intro {
        display: block;
    }

    .train-frontend-header {
        flex-wrap: nowrap;
        justify-content: space-between;
        gap: 0.5rem;
    }

    /* ... rest of existing mobile styles ... */

    .train-frontend-header h2 {
        order: 0;
        width: auto;
        margin-bottom: 0;
        font-size: 1.2rem;
        min-width: 0;
        white-space: nowrap;
        flex: 1;
        text-align: center;
    }

    .grid-day-cell {
        min-height: 60px;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        /* Space number and icon */
        padding-bottom: 10px;
    }

    .popup-body {
        flex-direction: column;
    }

    /* Hide Filters & Legend */
    .train-filters,
    .status-legend {
        display: none !important;
    }

    /* Hide Desktop/Tablet Elements */
    .day-blocks-container,
    .compact-train-dots,
    .train-count,
    .no-trains-small {
        display: none !important;
    }

    /* Show Mobile Icon */
    .day-status-icon {
        display: block;
    }

    .day-number {
        margin-bottom: 0;
        /* Reset margin since we flex */
    }

    /* Adjust Popup Header for multiline date */
    .popup-header {
        align-items: center;
    }

    .popup-header h2 {
        font-size: 1.1rem;
        line-height: 1.2;
    }

    .btn-buy-ticket {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}