/* Airplane Diary - Public/Frontend Styles */

/* Block wrapper layout - allow blocks to sit side-by-side */
.wp-site-blocks .wp-block-airplane-diary-stats,
.wp-site-blocks .wp-block-airplane-diary-map,
.wp-site-blocks .wp-block-airplane-diary-chart,
.wp-site-blocks .wp-block-airplane-diary-list,
.wp-site-blocks .wp-block-airplane-diary-list-data,
.wp-block-airplane-diary-stats,
.wp-block-airplane-diary-map,
.wp-block-airplane-diary-chart,
.wp-block-airplane-diary-list,
.wp-block-airplane-diary-list-data {
    display: inline-block !important;
    vertical-align: top !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

/* Fix for inline-block whitespace causing wrapping */
.wp-block-airplane-diary-stats + .wp-block-airplane-diary-stats,
.wp-block-airplane-diary-stats + .wp-block-airplane-diary-list-data,
.wp-block-airplane-diary-list-data + .wp-block-airplane-diary-stats,
.wp-block-airplane-diary-list-data + .wp-block-airplane-diary-list-data,
.wp-block-airplane-diary-map + .wp-block-airplane-diary-map,
.wp-block-airplane-diary-chart + .wp-block-airplane-diary-chart {
    margin-left: -4px !important;
}

/* Flight Data Dashboard - Flexbox Layout */
.airplane-diary-dashboard {
    display: flex;
    gap: 20px;
    width: 100%;
    box-sizing: border-box;
}

.airplane-diary-dashboard .dashboard-column {
    flex: 1;
    min-width: 0; /* Prevent flex items from overflowing */
    box-sizing: border-box;
}

/* Specific column layouts */
.airplane-diary-dashboard.columns-1 .dashboard-column {
    flex-basis: 100%;
}

.airplane-diary-dashboard.columns-2 .dashboard-column {
    flex-basis: calc(50% - 10px);
}

.airplane-diary-dashboard.columns-3 .dashboard-column {
    flex-basis: calc(33.333% - 14px);
}

/* Responsive: Stack on mobile */
@media (max-width: 768px) {
    .airplane-diary-dashboard {
        flex-direction: column;
    }
    
    .airplane-diary-dashboard .dashboard-column {
        flex-basis: 100% !important;
    }
}

/* Statistics Grid */
.airplane-diary-stats {
    box-sizing: border-box;
    padding: 10px;
}

.airplane-diary-stats.inline-block {
    display: inline-block;
    vertical-align: top;
}

.ad-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.ad-stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 25px 15px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.ad-stat-value {
    font-size: 2em;
    font-weight: bold;
    display: block;
    margin-bottom: 8px;
}

.ad-stat-label {
    font-size: 0.8em;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Multi-item stat cards (for seat types, classes, reasons) */
.ad-stat-card-multi {
    text-align: left;
}

.ad-stat-card-multi .ad-stat-label {
    font-size: 0.85em;
    opacity: 1;
    margin-bottom: 12px;
    display: block;
    text-align: center;
    font-weight: 600;
}

.ad-stat-breakdown {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ad-stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.15);
    padding: 8px 12px;
    border-radius: 4px;
}

.ad-stat-item-label {
    font-size: 0.9em;
    font-weight: 500;
}

.ad-stat-item-value {
    font-size: 1.1em;
    font-weight: bold;
}

/* Map Container */
.airplane-diary-map {
    border-radius: 8px;
    border: 2px solid #e0e0e0;
    overflow: hidden;
    box-sizing: border-box;
    margin: 10px;
}

/* Chart Container */
.airplane-diary-chart-container {
    padding: 20px 20px 30px 20px;
    margin: 10px;
    background: white;
    border-radius: 8px;
    box-sizing: border-box;
    border: 2px solid #e0e0e0;
    min-height: 380px;
}

.airplane-diary-chart-container h3 {
    margin: 0 0 20px 0;
    font-size: 1.3em;
    font-weight: 600;
    color: #2c3e50;
    text-align: center;
}

.airplane-diary-chart-container canvas {
    max-height: 300px;
}

/* Scrollable legend for pie charts */
.airplane-diary-chart-container .chartjs-legend {
    max-height: 250px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Flights List Table */
.airplane-diary-flights-list {
    margin: 20px 0;
    overflow-x: auto;
}

.ad-flights-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ad-flights-table thead {
    background: #2c3e50;
    color: white;
}

.ad-flights-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.5px;
}

.ad-flights-table td {
    padding: 12px 15px;
    border-bottom: 1px solid #e0e0e0;
}

.ad-flights-table tbody tr:hover {
    background: #e3f2fd;
    cursor: pointer;
}

.ad-flights-table tbody tr:last-child td {
    border-bottom: none;
}

/* Widget Styles */
.airplane-diary-widget-stats {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ad-widget-stat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    background: #f6f7f7;
    border-radius: 4px;
    border-left: 3px solid #667eea;
}

.ad-widget-stat-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #667eea;
}

.ad-widget-stat-label {
    font-size: 0.85em;
    color: #646970;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .ad-stats-grid {
        grid-template-columns: 1fr;
    }
    
    .ad-flights-table {
        font-size: 0.9em;
    }
    
    .ad-flights-table th,
    .ad-flights-table td {
        padding: 10px 8px;
    }
    
    .ad-stat-value {
        font-size: 2em;
    }
}

@media (max-width: 480px) {
    .ad-stat-card {
        padding: 20px 15px;
    }
    
    .ad-stat-value {
        font-size: 1.8em;
    }
    
    .ad-flights-table {
        font-size: 0.8em;
    }
}

/* Leaflet Map Fixes */
.airplane-diary-map .leaflet-container {
    font-family: inherit;
}

.airplane-diary-map .leaflet-popup-content-wrapper {
    border-radius: 4px;
}

.airplane-diary-map .leaflet-popup-content {
    margin: 10px;
}

.airplane-diary-map .leaflet-tooltip {
    font-size: 12px;
    padding: 6px 10px;
}

/* Flights List Controls */
.ad-list-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: #f5f5f5;
    border-radius: 4px;
}

.ad-per-page-selector {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ad-per-page-selector label {
    margin: 0;
    font-weight: 500;
}

.ad-per-page-select {
    padding: 5px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background: white;
    cursor: pointer;
}

.ad-results-info {
    color: #666;
    font-size: 0.9em;
}

/* Pagination */
.ad-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin-top: 20px;
    padding: 15px;
    flex-wrap: wrap;
}

.ad-page-link,
.ad-page-number {
    display: inline-block;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: #667eea;
    background: white;
    transition: all 0.2s;
}

.ad-page-link:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.ad-current-page {
    padding: 8px 12px;
    background: #667eea;
    color: white;
    border: 1px solid #667eea;
    border-radius: 4px;
    font-weight: bold;
}

.ad-page-ellipsis {
    padding: 8px 5px;
    color: #999;
}

.ad-page-prev,
.ad-page-next {
    font-weight: 500;
}

.ad-page-numbers {
    display: flex;
    gap: 5px;
    align-items: center;
}

/* Responsive List Controls */
@media (max-width: 600px) {
    .ad-list-controls {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }
    
    .ad-pagination {
        font-size: 0.85em;
    }
    
    .ad-page-link,
    .ad-page-number,
    .ad-current-page {
        padding: 6px 10px;
    }
}

/* Flight Details Modal */
.ad-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
}

.ad-modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 30px;
    border: 1px solid #888;
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    position: relative;
}

.ad-modal-content h2 {
    margin-top: 0;
    color: #667eea;
    border-bottom: 2px solid #667eea;
    padding-bottom: 10px;
}

.ad-modal-close {
    color: #aaa;
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.2s;
}

.ad-modal-close:hover,
.ad-modal-close:focus {
    color: #667eea;
}

.ad-flight-detail-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ad-detail-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.ad-detail-row.ad-detail-full {
    grid-template-columns: 1fr;
}

.ad-detail-item {
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #667eea;
}

.ad-detail-item strong {
    color: #2c3e50;
    display: inline-block;
    margin-bottom: 3px;
}

@media (max-width: 600px) {
    .ad-modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 20px;
    }
    
    .ad-detail-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}
/* Expandable Lists */
.airplane-diary-list-data {
    box-sizing: border-box;
    padding: 10px;
}

.ad-top-list {
    background: white;
    border-radius: 8px;
    padding: 20px;
    border: 2px solid #e0e0e0;
    box-sizing: border-box;
}

.ad-top-list h3 {
    margin: 0 0 15px 0;
    font-size: 1.2em;
    font-weight: 600;
    color: #2c3e50;
}

.ad-expandable-list {
    list-style: none;
    padding: 0;
    margin: 0 0 15px 0;
    counter-reset: list-counter;
}

.ad-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    counter-increment: list-counter;
    position: relative;
    padding-left: 45px;
}

.ad-list-item:before {
    content: counter(list-counter);
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75em;
    font-weight: bold;
}

.ad-list-item:hover {
    background: #f8f9fa;
}

.ad-list-item.ad-collapsed {
    display: none;
}

.ad-list-label {
    flex: 1;
    font-size: 0.95em;
    color: #2c3e50;
}

.ad-list-label a {
    color: #667eea;
    text-decoration: none;
    transition: color 0.2s;
}

.ad-list-label a:hover {
    color: #764ba2;
    text-decoration: underline;
}

.ad-count-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
    min-width: 30px;
    text-align: center;
}

.ad-expand-button {
    width: 100%;
    padding: 10px 15px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 0.9em;
    font-weight: 500;
    color: #667eea;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.ad-expand-button:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.ad-expand-button:hover svg {
    color: white;
}

/* Sortable Table Columns */
.ad-flights-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.ad-flights-table th.sortable:hover {
    background: #34495e;
}

.ad-flights-table th .sort-arrow {
    margin-left: 5px;
    font-size: 0.8em;
    color: #95a5a6;
}

/* Aircraft and Registration Links */
.ad-aircraft-link,
.ad-registration-link {
    color: #3498db;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s;
}

.ad-aircraft-link:hover,
.ad-registration-link:hover {
    color: #2980b9;
}
