/* Window-maximized layout for HiFiMeteors Meteor Database */

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

html, body {
    height: 100%;
    overflow: hidden; /* Prevent body scroll, table will handle scroll */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: var(--text-muted);
    background-color: #f5f5f5;
}

#app {
    height: 100vh;
    height: 100dvh; /* actual rendered viewport on mobile browsers, accounts for address bar chrome that 100vh ignores */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Top Header */
.app-header {
    background: var(--heading);
    color: white;
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0; /* Don't shrink */
    min-height: 50px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-left h1 {
    font-size: 1.4rem;
    margin: 0;
}

.status-badge {
    font-size: 0.8rem;
    background: rgba(255,255,255,0.2);
    padding: 2px 8px;
    border-radius: 12px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ========== NAVIGATION MENU - START ========== */

.nav-menu {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: 20px;
}

.nav-menu a {
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.nav-menu a:hover {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.nav-menu a.active {
    color: white;
    background: rgba(255, 255, 255, 0.2);
    font-weight: 500;
}

/* ========== NAVIGATION MENU - END ========== */

/* Controls Row */
.controls-section {
    background: white;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0; /* Don't shrink */
    min-height: 40px;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 15px;
}

.controls-left h3 {
    font-size: 1.1rem;
    color: var(--heading);
    margin: 0;
    white-space: nowrap;
    flex-shrink: 0;
}

.controls-right {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
    min-width: 0; /* Allow shrinking of container */
}

/* Filter controls styling */
.filter-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: max-content; /* Force minimum width based on content */
}

/* Mobile responsive */
@media (max-width: 768px) {
    /* Nav bar has more links + auth controls than fit on narrow screens.
       The whole header scrolls as one row (title, nav, login/logout) so
       nothing is reserved/fixed and eating space from the nav — reserving
       header-right made users scroll past the title just to see the first
       link. A right-edge fade hints that more content is off-screen. */
    .app-header {
        position: relative;
        justify-content: flex-start;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        gap: 8px;
    }

    .app-header::after {
        content: '';
        position: fixed;
        top: 0;
        right: 0;
        width: 24px;
        height: 50px;
        background: linear-gradient(to right, transparent, var(--heading));
        pointer-events: none;
    }

    .header-left {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .header-left h1 {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .nav-menu {
        flex-shrink: 0;
        margin-left: 10px;
        white-space: nowrap;
    }

    .nav-menu a {
        display: inline-block;
        white-space: nowrap;
    }

    .header-right {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .controls-section {
        padding: 8px 8px;
        gap: 10px;
        /* Enable smooth scrolling */
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        /* Force content to not shrink below natural size */
        flex-wrap: nowrap;
    }

    /* Panel heading (e.g. "Downloaded Minute Videos") is redundant with the
       page nav/title and was eating horizontal scroll space ahead of the
       actual controls (Filter/Clear/etc), forcing an extra scroll just to
       reach them. Hidden on mobile; the download-panel's own h3 (part of
       its always-visible collapsed toggle row, not a scroll-to-reach
       heading) is deliberately excluded. */
    .controls-section:not(.download-panel) .controls-left h3 {
        display: none;
    }

    .controls-right {
        gap: 8px;
    }

    .filter-controls {
        gap: 4px;
        padding: 4px 6px;
        /* Ensure controls maintain their minimum width */
        min-width: 600px; /* Force horizontal scroll by setting minimum width */
    }

    .filter-controls label {
        font-size: 0.8rem;
        white-space: nowrap;
    }

    /* Fixed width inputs to prevent shrinking */
    .date-input {
        width: 80px;
        font-size: 0.8rem;
        flex-shrink: 0;
    }

    .station-select,
    .status-select,
    .multi-station-select,
    .rating-select {
        font-size: 0.8rem;
        width: 60px;
        flex-shrink: 0;
    }

    .btn-small {
        font-size: 0.8rem;
        padding: 4px 8px;
        flex-shrink: 0;
        white-space: nowrap;
    }
}

.filter-controls label {
    font-size: 0.9rem;
    color: var(--heading);
    margin: 0;
}

/* Toolbar buttons responsive */
.toolbar-btn {
    display: flex;
    align-items: center;
    gap: 6px;
}

.toolbar-btn .icon {
    flex-shrink: 0;
}

.toolbar-btn .text {
    white-space: nowrap;
}

/* Simple responsive toolbar - use em units for font-size scaling */
@media (max-width: 30em) {
    .toolbar-btn .text {
        display: none;
    }

    .toolbar-btn {
        padding: 8px 10px;
        min-width: 44px;
        justify-content: center;
    }
}

.date-input {
    padding: 4px 6px;
    border: 1px solid var(--border-light);
    border-radius: 3px;
    font-size: 0.9rem;
    width: 90px;
}

.status-select {
    padding: 4px 6px;
    border: 1px solid var(--border-light);
    border-radius: 3px;
    font-size: 0.9rem;
    width: 70px;
    background: white;
}

.station-select {
    padding: 4px 6px;
    border: 1px solid var(--border-light);
    border-radius: 3px;
    font-size: 0.9rem;
    width: 70px;
    background: white;
}

.multi-station-select {
    padding: 4px 6px;
    border: 1px solid var(--border-light);
    border-radius: 3px;
    font-size: 0.9rem;
    width: 70px;
    background: white;
}

/* Table Container - takes remaining space */
.table-container {
    flex: 1; /* Take all remaining space */
    background: white;
    overflow: hidden; /* Let Tabulator handle scrolling */
    display: flex;
    flex-direction: column;
    min-width: 0; /* Allow shrinking below content width */
}

/* Ensure Tabulator table fits container properly */
#meteor-table {
    width: 100%;
    height: 100%;
}

/* Fix for Tabulator header/column sync issues */
.tabulator .tabulator-header {
    overflow: hidden;
}

.tabulator .tabulator-tableholder {
    overflow: auto;
}

/* Buttons */
button {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

button:hover {
    background: #2980b9;
}

.btn-small {
    padding: 4px 8px;
    font-size: 12px;
    border-radius: 3px;
}

.btn-active {
    background: #1a5276;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.3);
}

.device-filter-group {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: #f0f4f8;
    border: 1px solid #ced4da;
    border-radius: 4px;
    padding: 1px 4px 1px 2px;
}

.device-match-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 0.85rem;
    line-height: 1;
    cursor: pointer;
    user-select: none;
    border-radius: 2px;
    color: #adb5bd;
    flex-shrink: 0;
    transition: color 0.15s;
}

.device-match-toggle.is-and {
    color: #004085;
}


/* Inline Results */
.inline-result {
    font-size: 0.8rem;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.inline-result.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.inline-result.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Auth Status */
.auth-status {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.7);
}

.auth-status.authenticated {
    color: var(--success);
}

.auth-status.invalid {
    color: var(--danger);
}

/* Modal styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 8px;
    min-width: 300px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
    margin-top: 0;
    color: var(--heading);
}

.modal-content input {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid var(--border-light);
    border-radius: 4px;
    font-size: 16px;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 15px;
}

.modal-buttons button {
    padding: 8px 16px;
}

/* Meteor table container */
#meteor-table-container {
    margin: 20px 0;
}

#meteor-table-container h2 {
    color: var(--heading);
    margin-bottom: 15px;
}

/* Tabulator table customization */
.tabulator {
    border-radius: 6px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Make sortable column headers more prominent */
.tabulator .tabulator-header .tabulator-col.tabulator-sortable:hover {
    background-color: #d5d5d5 !important;
    cursor: pointer;
}

.tabulator .tabulator-header .tabulator-col.tabulator-sortable .tabulator-col-title {
    padding-right: 25px; /* Space for sort arrow */
}

/* 2x2 Action Column */
.action-column {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    align-items: center;
    height: 56px;
    justify-content: center;
}

/* Subtle Action Buttons */
.action-btn-subtle {
    padding: 2px 4px;
    border: none;
    border-radius: 2px;
    cursor: pointer;
    font-size: 10px;
    width: 24px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 1.0;
    background: #bdc3c750;
    color: #34495e;
}

.action-btn-subtle:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Hover colors for different button types */
.action-btn-subtle.btn-station:hover {
    background: #16a085;
    color: white;
}

.action-btn-subtle.btn-image:hover {
    background: #3498db;
    color: white;
}

.action-btn-subtle.btn-video:hover {
    background: #e74c3c;
    color: white;
}

.action-btn-subtle.btn-raw:hover {
    background: #95a5a6;
    color: white;
}

.action-btn-subtle.btn-meteors:hover {
    background: #9b59b6;
    color: white;
}

.action-btn-subtle.btn-minute-video:hover {
    background: #f39c12;
    color: white;
}

.action-btn-subtle.btn-trajectory:hover {
    background: #9b59b6;
    color: white;
}

/* Select2 Classification Control Styling */
.classification-select {
    padding: 4px 6px;
    border: 1px solid var(--border-light);
    border-radius: 3px;
    font-size: 0.9rem;
    width: 100px;
    background: white;
}

/* Hide native select until select2 initialises — avoids flash of unstyled control */
select.multi-select-filter {
    display: none;
}

/* Select2 Container - Clean single-line display */
.select2-container {
    max-width: 100px;
    min-width: 100px;
}

.select2-container .select2-selection--multiple {
    max-width: 100px;
    min-height: 28px;
    height: 28px;
    border: 1px solid var(--border-light);
    border-radius: 3px;
    padding: 4px 8px;
    box-sizing: border-box;
    overflow: hidden;
    display: flex;
    align-items: center;
}

/* Select2 dropdown (opened state) — must sit above Tabulator */
.select2-container--open .select2-dropdown {
    min-width: 200px;
    z-index: 9999;
    background: #fff;
    border: 1px solid #ccc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.select2-dropdown {
    background: #fff;
}

.select2-results {
    background: #fff;
}

.select2-search--dropdown .select2-search__field {
    background: #fff;
}

/* Selection summary styling */
.selection-summary {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: normal;
}

.selection-placeholder {
    color: #999;
    font-size: 0.9rem;
    font-style: italic;
}

/* Multi-checkboxes plugin styling */
.select2-results__option .wrap::before {
    content: "☐";
    color: #999;
    font-size: 14px;
    margin-right: 8px;
    width: 16px;
    display: inline-block;
}

.select2-results__option[aria-selected="true"] .wrap::before {
    content: "☑";
    color: var(--success);
}

/* Multi-station event badge on thumbnail */
.multi-station-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    backdrop-filter: blur(4px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

/* Badge for meteors in correlation pairs (higher correlation) */
.multi-station-badge.in-pair {
    background: rgba(255, 140, 0, 0.75); /* Orange - strong correlation */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.multi-station-badge.in-pair::before {
    content: "⚯"; /* Three lines with connection - represents correlation */
}

.multi-station-badge.in-pair:hover {
    transform: scale(1.15);
    background: rgba(255, 140, 0, 0.9);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
}

/* Badge for meteors in multi-station events only (no pair) */
.multi-station-badge.in-event {
    background: rgba(0, 120, 255, 0.75); /* Blue - general event */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.multi-station-badge.in-event::before {
    content: "○"; /* Circle - represents general grouping */
}

.multi-station-badge.in-event:hover {
    transform: scale(1.15);
    background: rgba(0, 120, 255, 0.9);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
}

/* Download panel specific styles */
.download-panel {
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
}

.download-panel .controls-left h3 {
    color: #495057;
    font-size: 1rem;
}

.download-panel-toggle {
    display: none;
}

.datetime-input {
    width: 140px;
    padding: 4px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.9rem;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .datetime-input {
        width: 120px;
        font-size: 0.8rem;
    }

    .download-panel {
        flex-wrap: wrap;
        flex-shrink: 0;
    }

    .download-panel .controls-left {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .download-panel-toggle {
        display: inline-block;
    }

    .download-panel .controls-right {
        display: none;
        flex-basis: 100%;
    }

    .download-panel.expanded .controls-right {
        display: flex;
    }

    .download-panel.expanded .filter-controls {
        flex-wrap: wrap;
        min-width: 0;
    }

    .download-panel.expanded #download-controls-container {
        flex-wrap: wrap;
        min-width: 0;
    }
}

/* Rating controls styling */
.rating-controls {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: 8px;
    padding: 4px 8px;
    background: #f0f7ff;
    border-radius: 4px;
    border: 1px solid #cce0ff;
}

.rating-controls label {
    font-size: 0.85rem;
    color: var(--heading);
    font-weight: 500;
}

.rating-select {
    padding: 4px 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.9rem;
    width: 50px;
}

/* Rating filter in filter bar - narrower display, wider dropdown */
#rating-filter {
    width: 55px;
}

/* Star rating display - vertical single column layout */
.rating-stars-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    user-select: none;
    background: #f8f9fa;
    padding: 2px 4px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.rating-star {
    display: block;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    transition: transform 0.1s ease;
}

.rating-star:hover {
    transform: scale(1.2);
}