/*
 * OpenStreamView - Frontend Styles
 * Plugin version 1.0.0
 */

/* ── Wrapper ────────────────────────────────────────────────────────── */
.gpm-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    margin: 1.5rem 0;
    box-sizing: border-box;
}
.gpm-wrapper *,
.gpm-wrapper *::before,
.gpm-wrapper *::after {
    box-sizing: inherit;
}

/* ── Map container ──────────────────────────────────────────────────── */
#gpm-map {
    width: 100%;
    border-radius: 10px;
    border: 1px solid #cbd5e1;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
    /* Leaflet needs an explicit z-index context */
    z-index: 0;
    position: relative;
}

.gpm-map-tools {
    margin: 0 0 0.7rem;
    padding: 0.65rem 0.8rem;
    border: 1px solid #dbeafe;
    background: #f8fbff;
    border-radius: 8px;
    display: flex;
    gap: 0.55rem 0.8rem;
    align-items: center;
    flex-wrap: wrap;
}
.gpm-map-tool-checkbox {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #1e3a8a;
    font-size: 0.86rem;
    font-weight: 600;
}
.gpm-map-tool-range {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #1e3a8a;
    font-size: 0.86rem;
    font-weight: 600;
}
.gpm-map-tool-range input {
    width: 70px;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 0.25rem 0.35rem;
    background: #fff;
}
.gpm-map-tool-range select {
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 0.25rem 0.35rem;
    background: #fff;
    color: #1e3a8a;
}
.gpm-map-tool-btn {
    border: 1px solid #2563eb;
    background: #fff;
    color: #1d4ed8;
    border-radius: 7px;
    padding: 0.35rem 0.6rem;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}
.gpm-map-tool-btn:hover,
.gpm-map-tool-btn:focus-visible {
    background: #eff6ff;
    outline: 3px solid #bfdbfe;
    outline-offset: 1px;
}

.gpm-initial-loader {
    margin: 0 0 0.7rem;
    padding: 0.7rem 0.85rem;
    border: 1px solid #bfdbfe;
    border-radius: 8px;
    background: linear-gradient(180deg, #f8fbff 0%, #eff6ff 100%);
}
.gpm-initial-loader-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #1e3a8a;
    margin-bottom: 0.2rem;
}
.gpm-initial-loader-status {
    font-size: 0.8rem;
    color: #475569;
    margin-bottom: 0.45rem;
}
.gpm-initial-loader-track {
    width: 100%;
    height: 9px;
    border-radius: 999px;
    background: #dbeafe;
    overflow: hidden;
}
.gpm-initial-loader-bar {
    width: 0%;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #0ea5e9 0%, #2563eb 100%);
    transition: width 0.25s ease;
}

/* ── Upload panel ───────────────────────────────────────────────────── */
.gpm-upload-panel {
    margin-bottom: 1rem;
}

.gpm-toggle-btn {
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 7px;
    padding: 0.5rem 1.1rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    line-height: 1.5;
}
.gpm-toggle-btn:hover,
.gpm-toggle-btn:focus-visible {
    background: #1d4ed8;
    outline: 3px solid #93c5fd;
    outline-offset: 2px;
}

.gpm-upload-form-wrapper {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1.25rem 1.5rem 1.5rem;
    margin-top: 0.75rem;
}

/* ── Drop zone ──────────────────────────────────────────────────────── */
.gpm-drop-zone {
    border: 2px dashed #94a3b8;
    border-radius: 8px;
    padding: 2.25rem 1rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    position: relative;
    background: #fff;
}
.gpm-drop-zone:hover,
.gpm-drop-zone.gpm-drag-over {
    border-color: #2563eb;
    background: #eff6ff;
}
.gpm-drop-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}
.gpm-drop-icon {
    font-size: 2.4rem;
    display: block;
    margin-bottom: 0.5rem;
    line-height: 1;
}
.gpm-drop-zone p {
    margin: 0;
    color: #64748b;
    font-size: 0.9rem;
}

.gpm-batch-tools {
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}
.gpm-folder-btn {
    border: 1px solid #2563eb;
    background: #fff;
    color: #2563eb;
    border-radius: 7px;
    padding: 0.44rem 0.9rem;
    font-size: 0.86rem;
    font-weight: 600;
    cursor: pointer;
}
.gpm-folder-btn:hover,
.gpm-folder-btn:focus-visible {
    background: #eff6ff;
    outline: 3px solid #bfdbfe;
    outline-offset: 2px;
}
.gpm-selected-count {
    font-size: 0.86rem;
    color: #475569;
}

/* ── Image preview ──────────────────────────────────────────────────── */
.gpm-preview-wrapper {
    margin-top: 0.85rem;
    text-align: center;
}
.gpm-preview-wrapper img {
    max-height: 180px;
    max-width: 100%;
    border-radius: 7px;
    border: 1px solid #e2e8f0;
    object-fit: cover;
}

/* ── Metadata fields ────────────────────────────────────────────────── */
.gpm-fields {
    margin-top: 1.1rem;
    display: grid;
    gap: 0.35rem 0;
}
.gpm-fields label {
    font-weight: 600;
    font-size: 0.875rem;
    color: #374151;
    margin-top: 0.65rem;
}
.gpm-fields label:first-child {
    margin-top: 0;
}
.gpm-fields input[type="text"],
.gpm-fields select,
.gpm-fields textarea {
    display: block;
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0.45rem 0.7rem;
    font-size: 0.9rem;
    color: #1e293b;
    background: #fff;
    transition: border-color 0.15s;
}
.gpm-fields input[type="text"]:focus,
.gpm-fields select:focus,
.gpm-fields textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.gpm-fields textarea {
    resize: vertical;
    min-height: 70px;
}
.gpm-field-help {
    margin: 0.3rem 0 0;
    font-size: 0.82rem;
    color: #64748b;
}

/* ── Manual coordinate section ──────────────────────────────────────── */
.gpm-manual-coords {
    background: #fefce8;
    border: 1px solid #fde047;
    border-radius: 7px;
    padding: 0.9rem 1rem;
    margin-top: 1rem;
}
.gpm-manual-coords .gpm-notice {
    margin: 0 0 0.65rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #713f12;
}
.gpm-coords-row {
    display: grid;
    grid-template-columns: max-content 1fr max-content 1fr;
    gap: 0.5rem;
    align-items: center;
}
.gpm-coords-row label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}
.gpm-coords-row input[type="number"] {
    border: 1px solid #d1d5db;
    border-radius: 5px;
    padding: 0.38rem 0.55rem;
    font-size: 0.88rem;
    background: #fff;
}
.gpm-coords-row input[type="number"]:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
.gpm-tip {
    font-size: 0.8rem;
    color: #78716c;
    margin: 0.55rem 0 0;
}

/* ── Form footer ────────────────────────────────────────────────────── */
.gpm-form-footer {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.1rem;
}
.gpm-submit-btn {
    background: #16a34a;
    color: #fff;
    border: none;
    border-radius: 7px;
    padding: 0.52rem 1.4rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    line-height: 1.5;
}
.gpm-submit-btn:hover,
.gpm-submit-btn:focus-visible {
    background: #15803d;
    outline: 3px solid #86efac;
    outline-offset: 2px;
}
.gpm-submit-btn:disabled {
    background: #86efac;
    cursor: not-allowed;
}
.gpm-spinner {
    font-size: 0.88rem;
    color: #64748b;
}

.gpm-progress {
    margin-top: 0.75rem;
    font-size: 0.86rem;
    color: #334155;
}

/* ── Status messages ────────────────────────────────────────────────── */
.gpm-message {
    margin-top: 0.85rem;
    font-size: 0.9rem;
    border-radius: 6px;
    padding: 0.55rem 0.85rem;
    line-height: 1.45;
}
.gpm-message.gpm-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.gpm-message.gpm-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.gpm-message:empty        { display: none; }

/* ── Login notice ───────────────────────────────────────────────────── */
.gpm-login-notice {
    font-size: 0.95rem;
    color: #374151;
    margin-bottom: 0.75rem;
}
.gpm-login-notice a { color: #2563eb; }

/* ── Leaflet popup ──────────────────────────────────────────────────── */
.gpm-popup {
    max-width: 230px;
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.gpm-popup img {
    width: 100%;
    max-width: 210px;
    max-height: 150px;
    object-fit: cover;
    border-radius: 5px;
    margin-bottom: 0.45rem;
    display: block;
}
.gpm-popup h4 {
    margin: 0 0 0.3rem;
    font-size: 0.93rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.35;
}
.gpm-popup p {
    margin: 0 0 0.35rem;
    font-size: 0.82rem;
    color: #475569;
    line-height: 1.4;
}
.gpm-popup .gpm-popup-location {
    font-size: 0.78rem;
    color: #64748b;
    margin: -0.1rem 0 0.35rem;
    font-style: italic;
}
.gpm-popup .gpm-popup-meta {
    font-size: 0.78rem;
    color: #94a3b8;
    margin-bottom: 0.45rem;
}
.gpm-popup a {
    font-size: 0.82rem;
    color: #2563eb;
    text-decoration: none;
}
.gpm-popup a:hover {
    text-decoration: underline;
}
.gpm-view-360-btn {
    display: inline-block;
    margin: 0.15rem 0 0.5rem;
    border: 1px solid #0f766e;
    background: #f0fdfa;
    color: #115e59;
    border-radius: 5px;
    padding: 0.26rem 0.6rem;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}
.gpm-view-360-btn:hover,
.gpm-view-360-btn:focus-visible {
    background: #ccfbf1;
    outline: 2px solid #5eead4;
    outline-offset: 1px;
}

.gpm-panorama-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
}
.gpm-panorama-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.78);
}
.gpm-panorama-dialog {
    position: relative;
    width: min(1100px, calc(100vw - 2rem));
    height: min(720px, calc(100vh - 2rem));
    margin: 1rem auto;
    background: #0f172a;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 18px 45px rgba(2, 6, 23, 0.45);
}
.gpm-panorama-close {
    position: absolute;
    top: 0.5rem;
    right: 0.6rem;
    z-index: 4;
    width: 36px;
    height: 36px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(15, 23, 42, 0.58);
    color: #fff;
    border-radius: 999px;
    font-size: 1.3rem;
    line-height: 1;
    cursor: pointer;
}
.gpm-panorama-viewer {
    width: 100%;
    height: 100%;
}

/* ── Series / Dataset Browser ───────────────────────────────────────── */
.gpm-series-browser {
    border: 1px solid #dbeafe;
    background: #f8fbff;
    border-radius: 8px;
    margin-bottom: 0.7rem;
    overflow: hidden;
}
.gpm-series-browser-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 0.9rem;
    background: #eff6ff;
    border-bottom: 1px solid #dbeafe;
}
.gpm-series-browser-title {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 700;
    color: #1e3a8a;
}
.gpm-series-browser-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
    padding: 0 0.15rem;
}
.gpm-series-browser-close:hover {
    color: #1e293b;
}
.gpm-series-filters {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.55rem 0.9rem;
    background: #f1f5f9;
    border-bottom: 1px solid #dbeafe;
}
.gpm-series-filter-select {
    width: 100%;
    box-sizing: border-box;
    padding: 0.32rem 0.55rem;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    font-size: 0.82rem;
    color: #1e293b;
    background: #fff;
    outline: none;
    cursor: pointer;
    transition: border-color 0.15s;
    appearance: auto;
}
.gpm-series-filter-select:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px #bfdbfe;
}
.gpm-series-filter-select:disabled {
    background: #f1f5f9;
    color: #94a3b8;
    cursor: default;
}
.gpm-series-filter-select[hidden] {
    display: none;
}
.gpm-filter-clear-btn {
    align-self: flex-end;
    background: none;
    border: none;
    font-size: 0.78rem;
    color: #2563eb;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}
.gpm-filter-clear-btn:hover {
    color: #1d4ed8;
}
.gpm-series-empty {
    padding: 0.75rem 0.9rem;
    font-size: 0.83rem;
    color: #64748b;
    font-style: italic;
    list-style: none;
}
#gpm-series-list.gpm-series-list {
    margin: 0;
    padding: 0.4rem 0;
    list-style: none !important;
    padding-left: 0 !important;
    max-height: 220px;
    overflow-y: auto;
    border-bottom: 1px solid #e2e8f0;
}
#gpm-series-list .gpm-series-item {
    list-style: none !important;
    display: grid;
    grid-template-columns: auto auto minmax(0, 1fr);
    align-items: center;
    column-gap: 0.55rem;
    padding: 0.45rem 0.9rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: #1e293b;
    border-left: 3px solid transparent;
    transition: background 0.12s;
}
.gpm-series-item:hover {
    background: #eff6ff;
}
.gpm-series-item.is-active {
    background: #dbeafe;
    border-left-color: #2563eb;
    font-weight: 600;
}
.gpm-series-item-swatch {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    flex-shrink: 0;
}
.gpm-series-item-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.gpm-series-item-count {
    font-size: 0.78rem;
    color: #64748b;
    flex-shrink: 0;
    white-space: nowrap;
}
#gpm-series-list .gpm-series-toggle-points {
    width: 1.1rem;
    height: 1.1rem;
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
    display: inline-block;
    vertical-align: middle;
}
#gpm-series-list .gpm-series-color-input {
    width: 1.35rem;
    height: 1.1rem;
    padding: 0;
    margin: 0;
    border: 1px solid #cbd5e1;
    border-radius: 3px;
    background: #fff;
    cursor: pointer;
}
.gpm-series-color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}
.gpm-series-color-input::-webkit-color-swatch {
    border: none;
    border-radius: 2px;
}
#gpm-series-list .gpm-series-item-checkbox-label {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.55rem;
    min-width: 0;
    width: 100%;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}
.gpm-series-detail {
    padding: 0.7rem 0.9rem 0.85rem;
}
.gpm-series-detail-name {
    margin: 0 0 0.5rem;
    font-size: 0.92rem;
    font-weight: 700;
    color: #1e3a8a;
}
.gpm-series-detail-meta {
    margin: 0 0 0.5rem;
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.1rem 0.6rem;
    font-size: 0.82rem;
}
.gpm-series-detail-meta dt {
    color: #64748b;
    font-weight: 600;
}
.gpm-series-detail-meta dd {
    margin: 0;
    color: #1e293b;
}
.gpm-series-detail-desc {
    font-size: 0.84rem;
    color: #475569;
    margin: 0 0 0.65rem;
    line-height: 1.5;
    border-left: 2px solid #bfdbfe;
    padding-left: 0.55rem;
    white-space: pre-line;
    overflow-wrap: anywhere;
}
.gpm-series-detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

/* ── Series Image Viewer ───────────────────────────────────────────── */
.gpm-series-viewer {
    margin-top: 0.7rem;
    border: 1px solid #dbeafe;
    border-radius: 10px;
    background: #f8fbff;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.gpm-series-viewer-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem;
    background: #eff6ff;
    border-bottom: 1px solid #dbeafe;
}
.gpm-series-viewer-name {
    margin: 0;
    font-size: 0.98rem;
    color: #1e3a8a;
}
.gpm-series-viewer-count {
    margin: 0;
    font-size: 0.8rem;
    color: #64748b;
}
.gpm-series-viewer-canvas {
    height: 420px;
    min-height: 420px;
    max-height: 420px;
    background: #0f172a;
    border-bottom: 1px solid #dbeafe;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}
.gpm-series-viewport {
    position: relative;
    width: 100%;
    height: 100%;
    display: block;
    cursor: grab;
    touch-action: none;
    overflow: auto;
}
.gpm-series-viewport.is-panning {
    cursor: grabbing;
}
.gpm-series-image {
    display: block;
    width: 100%;
    max-width: none;
    max-height: none;
    flex: 0 0 auto;
    height: auto;
    margin: 0;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}
.gpm-series-caption {
    padding: 0.55rem 0.75rem;
    font-size: 0.82rem;
    color: #334155;
    line-height: 1.45;
    border-bottom: 1px solid #dbeafe;
}
.gpm-series-viewer-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.55rem 0.75rem;
    background: #f8fbff;
    flex-wrap: wrap;
}
.gpm-series-nav-btn {
    width: 40px;
    height: 40px;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    background: #ffffff;
    color: #1e3a8a;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}
.gpm-series-nav-btn:hover:not(:disabled) {
    border-color: #93c5fd;
    background: #eff6ff;
}
.gpm-series-nav-btn:disabled {
    cursor: default;
    color: #94a3b8;
    background: #f1f5f9;
}
.gpm-series-control-btn {
    padding: 0.4rem 0.7rem;
    border: 1px solid #cbd5e1;
    border-radius: 5px;
    background: #ffffff;
    color: #1e3a8a;
    font-size: 0.8rem;
    cursor: pointer;
    flex-shrink: 0;
    white-space: nowrap;
}
.gpm-series-control-btn:hover {
    border-color: #93c5fd;
    background: #eff6ff;
}
.gpm-series-control-link {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.gpm-series-control-btn[hidden] {
    display: none;
}
.gpm-series-zoom-level {
    font-size: 0.8rem;
    color: #64748b;
    padding: 0 0.4rem;
    flex-shrink: 0;
}

.gpm-series-viewer:fullscreen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    margin: 0;
    border-radius: 0;
    border: none;
    display: flex;
    flex-direction: column;
}

.gpm-series-viewer:fullscreen .gpm-series-viewer-header {
    flex: 0 0 auto;
}

.gpm-series-viewer:fullscreen .gpm-series-viewer-canvas {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    max-height: none;
}

.gpm-series-viewer:fullscreen .gpm-series-caption {
    flex: 0 0 auto;
}

.gpm-series-viewer:fullscreen .gpm-series-viewer-controls {
    flex: 0 0 auto;
}

/* ── Responsive adjustments ─────────────────────────────────────────── */
@media (max-width: 600px) {
    .gpm-coords-row {
        grid-template-columns: 1fr 1fr;
    }
    .gpm-coords-row label:nth-child(3) {
        grid-column: 1;
    }
    .gpm-upload-form-wrapper {
        padding: 1rem;
    }
    .gpm-panorama-dialog {
        width: calc(100vw - 1rem);
        height: calc(100vh - 1rem);
        margin: 0.5rem auto;
    }
    .gpm-series-viewer-canvas {
        height: 280px;
        min-height: 280px;
        max-height: 280px;
    }
    .gpm-series-nav-btn {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
}
