/* Field Watch — mobile-first remote monitoring panel */

.field-watch {
    display: none;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    background: var(--bg-color);
    color: var(--text-color);
    position: relative;
}

.main-content.has-field-watch .field-watch {
    display: flex;
}

/* Boot host: never participates in scroll flow; scoped splash (not viewport-fixed) */
.field-watch-loading {
    position: absolute;
    inset: 0;
    z-index: 40;
    background: var(--bg-color);
    overflow: hidden;
}

.field-watch-loading.hidden,
.field-watch-loading[hidden] {
    display: none !important;
    pointer-events: none !important;
}

/* Match device-viewer: keep Bob splash inside the panel, not position:fixed over the app */
.field-watch-loading #appLoadingScreen {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Hide live UI until heat + camera attempt settle */
.field-watch--booting .field-watch-body,
.field-watch--booting .field-watch-footer {
    visibility: hidden;
    pointer-events: none;
}

.field-watch-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    padding-top: calc(10px + env(safe-area-inset-top, 0));
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface);
    flex-shrink: 0;
    position: relative;
    z-index: 41;
}

.field-watch-back {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-color);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.field-watch-back svg {
    width: 22px;
    height: 22px;
}

.field-watch-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.field-watch-body {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding-bottom: 8px;
}

.field-watch-status {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-surface);
    flex-shrink: 0;
    position: relative;
    z-index: 41;
}

.field-watch-chip {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 4px 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    background: var(--bg-color);
}

.field-watch-chip.is-online { color: #6dce8a; border-color: rgba(109, 206, 138, 0.35); }
.field-watch-chip.is-offline { color: #f07178; border-color: rgba(240, 113, 120, 0.4); }
.field-watch-chip.is-paused { color: var(--warning-color, #e6b450); border-color: rgba(230, 180, 80, 0.4); }
.field-watch-chip.is-running { color: var(--primary); border-color: rgba(167, 78, 158, 0.4); }

.field-watch--offline .field-watch-temps,
.field-watch--offline .field-watch-spindle,
.field-watch--offline .field-watch-graph-wrap {
    opacity: 0.55;
}

.field-watch-camera {
    position: relative;
    width: 100%;
    height: 36dvh;
    min-height: 160px;
    max-height: 320px;
    background: #0a0a0f;
    overflow: hidden;
    border-bottom: none;
}

.field-watch-camera--collapsed {
    height: 72px;
    min-height: 72px;
    max-height: 72px;
}

.field-watch-camera-retry {
    position: absolute;
    left: 50%;
    bottom: 52px;
    transform: translateX(-50%);
    z-index: 3;
    min-height: 36px;
    padding: 6px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: rgba(22, 22, 27, 0.92);
    color: var(--text-color);
    font-size: 13px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.field-watch-camera--collapsed .field-watch-camera-retry {
    bottom: 8px;
}

.field-watch-camera-retry[hidden] {
    display: none !important;
}

.field-watch-camera img,
.field-watch-camera video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    background: #0a0a0f;
}

.field-watch-camera-msg {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 14px;
    background: rgba(0, 0, 0, 0.6);
    pointer-events: none;
}

/* Class display:flex must not beat the hidden attribute (Android WebView) */
.field-watch-camera-msg[hidden] {
    display: none !important;
}

.field-watch-camera--collapsed .field-watch-camera-msg {
    inset: auto;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
}

/* Icon toolbar overlaid on camera (Apollo-style compact) */
.field-watch-camera-controls {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 4;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0));
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
    pointer-events: none;
}

.field-watch-camera-controls:empty {
    display: none;
}

.field-watch-camera--collapsed .field-watch-camera-controls {
    display: none;
}

.fw-cam-bar {
    display: flex;
    flex-direction: column;
    gap: 6px;
    pointer-events: auto;
}

.fw-cam-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.fw-cam-actions {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    gap: 6px;
}

.fw-cam-chip {
    min-height: 28px;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(22, 22, 27, 0.72);
    color: #fff;
    font-size: 11px;
    cursor: pointer;
}

.fw-cam-action {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(22, 22, 27, 0.78);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.fw-cam-action svg {
    width: 20px;
    height: 20px;
}

.fw-cam-action.is-active {
    border-color: rgba(240, 113, 120, 0.8);
    color: #f07178;
}

.fw-cam-rec-time {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    font-family: var(--font-mono);
    color: #f07178;
}

.fw-cam-action {
    position: relative;
}

.fw-cam-sheet {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 56px;
    z-index: 5;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: rgba(22, 22, 27, 0.96);
    max-height: 200px;
    overflow: auto;
    pointer-events: auto;
}

.fw-cam-sheet[hidden] {
    display: none !important;
}

.fw-cam-rec-row {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-color);
}

.fw-cam-rec-close {
    margin-top: 8px;
    min-height: 40px;
    width: 100%;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-surface);
    color: var(--text-color);
    cursor: pointer;
}

.field-watch-section {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
}

.field-watch-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    margin: 0 0 10px;
}

.field-watch-temps {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.field-watch-temp-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    padding: 8px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 13px;
}

.field-watch-temp-label {
    color: var(--text-secondary);
}

.field-watch-temp-value {
    font-family: var(--font-mono);
    font-weight: 500;
}

.field-watch-spindle {
    margin-top: 8px;
    padding: 8px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 13px;
    display: flex;
    justify-content: space-between;
}

.field-watch-spindle[hidden] {
    display: none !important;
}

.field-watch-graph-wrap {
    padding: 0 14px 12px;
}

.field-watch-graph-wrap[hidden] {
    display: none !important;
}

.field-watch-graph {
    width: 100%;
    height: 80px;
    display: block;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.field-watch-footer {
    flex-shrink: 0;
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 5;
}

.field-watch-footer-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 28px;
    padding: 4px 0;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.field-watch-footer-chevron {
    display: inline-flex;
    line-height: 0;
    transition: transform 0.2s ease;
}

.field-watch-footer-chevron svg {
    width: 22px;
    height: 22px;
}

/* Expanded: chevron points down (collapse). Collapsed: points up (expand). */
.field-watch--footer-collapsed .field-watch-footer-chevron {
    transform: rotate(180deg);
}

.field-watch-footer-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 14px 12px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0));
    overflow: hidden;
    max-height: 280px;
    opacity: 1;
    transition: max-height 0.22s ease, opacity 0.18s ease, padding 0.22s ease;
}

.field-watch--footer-collapsed .field-watch-footer-body {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    pointer-events: none;
}

.field-watch--footer-collapsed .field-watch-footer {
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.field-watch-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.field-watch-controls .btn {
    min-height: 48px;
    width: 100%;
    font-size: 15px;
}

.field-watch-view-only {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    padding: 8px 0;
}

.field-watch-resume-note {
    text-align: center;
    color: var(--warning-color);
    font-size: 13px;
    padding: 2px 0 0;
    border: none;
}

@media (min-width: 769px) {
    .field-watch {
        border-radius: var(--radius-lg);
        border: 1px solid var(--border-color);
        overflow: hidden;
    }

    .field-watch-header {
        padding-top: 10px;
    }

    .field-watch-controls {
        flex-direction: row;
    }

    .field-watch-controls .btn {
        flex: 1;
    }
}
