:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #000000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: #ffffff;
}

#app-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Fullscreen Video Stream */
#camera-preview {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

/* Top Control Dashboard */
.top-bar {
    position: relative;
    z-index: 10;
    width: 100%;
    padding: calc(15px + var(--safe-top)) calc(15px + var(--safe-right)) 15px calc(15px + var(--safe-left));
    background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-group {
    display: flex;
    align-items: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px 12px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 8px;
    transition: background-color 0.3s ease;
}

.status-dot.connected { background-color: #4caf50; box-shadow: 0 0 8px #4caf50; }
.status-dot.searching { background-color: #ffeb3b; box-shadow: 0 0 8px #ffeb3b; }
.status-dot.disconnected { background-color: #f44336; box-shadow: 0 0 8px #f44336; }

#gps-accuracy-text {
    font-size: 12px;
    font-weight: 500;
}

.action-group {
    display: flex;
    gap: 12px;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: background 0.2s ease;
}

.icon-btn:active {
    background: rgba(255, 255, 255, 0.3);
}

.hidden { display: none !important; }

/* Zoom Control Layer */
.zoom-controls {
    position: absolute;
    right: calc(15px + var(--safe-right));
    top: 45%;
    transform: translateY(-50%);
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(0, 0, 0, 0.5);
    padding: 6px;
    border-radius: 30px;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255,255,255,0.1);
}

.zoom-btn {
    background: transparent;
    border: none;
    color: #ffffff;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, color 0.2s ease;
}

.zoom-btn.active {
    background: #ffffff;
    color: #000000;
}

/* Real-Time Live Overlay Watermark */
.watermark-container {
    position: absolute;
    bottom: calc(110px + var(--safe-bottom));
    left: calc(15px + var(--safe-left));
    right: calc(15px + var(--safe-right));
    z-index: 5;
    display: flex;
    background: rgba(0, 0, 0, 0.72);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    overflow: hidden;
    max-width: 500px;
    margin: 0 auto;
    transition: all 0.3s ease;
}

.map-thumbnail-wrapper {
    width: 120px;
    height: 120px;
    flex-shrink: 0;
    background: #111;
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid rgba(255, 255, 255, 0.15);
}

#map-thumbnail-canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.info-box {
    flex-grow: 1;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0; 
}

.info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.app-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.6);
    text-transform: uppercase;
}

.country-flag {
    font-size: 16px;
}

.location-title {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 2px;
}

.full-address {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 6px;
}

.info-footer {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.7);
    font-family: monospace;
}

.coords {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.timestamp {
    text-align: right;
    white-space: nowrap;
}

/* Action Control Strip */
.bottom-bar {
    position: relative;
    z-index: 10;
    width: 100%;
    padding: 20px calc(20px + var(--safe-right)) calc(25px + var(--safe-bottom)) calc(20px + var(--safe-left));
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0) 100%);
    display: flex;
    justify-content: center;
    align-items: center;
}

.capture-btn {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 4px solid #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    outline: none;
    transition: transform 0.1s ease;
}

.capture-btn:active {
    transform: scale(0.92);
}

.capture-btn-inner {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #ffffff;
    transition: background-color 0.2s ease;
}

.capture-btn:disabled .capture-btn-inner {
    background: #555555;
}

/* Screen Processing Overlay Loader */
.loader-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 100;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 15px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: spin 1s infinite linear;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive Landscape Configurations */
@media (orientation: landscape) {
    .watermark-container {
        bottom: calc(20px + var(--safe-bottom));
        left: calc(20px + var(--safe-left));
        right: auto;
        width: 460px;
    }
    .bottom-bar {
        position: absolute;
        right: 0;
        bottom: 0;
        top: 0;
        width: calc(100px + var(--safe-right));
        height: 100%;
        background: linear-gradient(to left, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0) 100%);
        flex-direction: column;
        padding: calc(20px + var(--safe-top)) calc(20px + var(--safe-right)) calc(20px + var(--safe-bottom)) 20px;
    }
    .zoom-controls {
        right: calc(110px + var(--safe-right));
        top: 50%;
    }
}