* { margin: 0; box-sizing: border-box; }

html {
    scroll-snap-type: y mandatory;
    overflow-y: scroll;
    height: 100%;
}

body { height: 100%; font-family: "Cairo", sans-serif; }

.detection-section {
    height: 100vh;
    scroll-snap-align: start;
    overflow: hidden;
    position: relative;
}

.scroll-nav {
    position: fixed;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 14px;
    z-index: 999;
}

.nav-dot {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.6);
    background: rgba(0, 0, 0, 0.35);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s, transform 0.2s;
    backdrop-filter: blur(4px);
}

.nav-dot:hover { transform: scale(1.15); }
.nav-dot.active { background: #37c9ef; border-color: #37c9ef; }
.nav-dot[data-section="pistol-section"].active { background: #e53935; border-color: #e53935; }
.nav-dot[data-section="analytics-section"].active { background: #43a047; border-color: #43a047; }

.scroll-hint {
    position: absolute;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    color: rgba(0, 0, 0, 0.4);
    font-size: 0.8rem;
    animation: bounce 2s infinite;
    pointer-events: none;
}

.scroll-hint-up {
    bottom: auto;
    top: 14px;
    flex-direction: column-reverse;
}

@keyframes bounce {
    0%, 100% { transform: translateX(-50%) translateY(0); }
    50% { transform: translateX(-50%) translateY(6px); }
}

.main-page {
    height: 100vh;
    display: flex;
}

.side-line {
    background-color: #37c9ef;
    height: 100%;
    width: 25px;
}

.side-bar {
    background-color: #f7f7f7;
    height: 100%;
    width: 15%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding-top: 150px;
    padding-bottom: 150px;
    box-shadow: 1px 1px 10px rgb(185, 185, 185);
}

.circle {
    height: 75px;
    width: 75px;
    background-color: #c7d0d8;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
}

.blue-circle { background-color: #37c9ef; }
.red-circle { background-color: #e53935; }
.green-circle { background-color: #43a047; }

.right-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

.header {
    background-color: #37c9ef;
    width: 100%;
    height: 75px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 1px 1px 10px rgb(185, 185, 185);
}

.logo-container { padding-right: 100px; }
.logo-container img { max-height: 52px; width: auto; object-fit: contain; }
.empty-side { padding-left: 100px; }

h1 {
    font-family: "Cairo", sans-serif;
    color: white;
    font-size: 1.5rem;
    letter-spacing: 0.2rem;
}

.tablet-container {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    position: relative;
}

#face-canvas,
#pistol-canvas,
#engagement-canvas {
    position: absolute;
    z-index: 1;
}

#face-info-panel,
#engagement-info-panel {
    position: absolute;
    top: 90px;
    right: 30px;
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    border-radius: 12px;
    padding: 14px 18px;
    min-width: 210px;
    max-width: 280px;
    font-size: 0.82rem;
    line-height: 1.7;
    z-index: 10;
    backdrop-filter: blur(4px);
    display: none;
}

#face-info-panel {
    border: 1px solid rgba(55, 201, 239, 0.4);
}

#engagement-info-panel {
    border: 1px solid rgba(67, 160, 71, 0.4);
}

.panel-title {
    font-size: 0.95rem;
    font-weight: bold;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    margin-bottom: 8px;
    padding-bottom: 4px;
}

#face-info-panel .panel-title { color: #37c9ef; }
#engagement-info-panel .panel-title { color: #81c784; }

.face-entry,
.engagement-entry {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.face-entry:last-child,
.engagement-entry:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.tag { font-weight: bold; }
#face-info-panel .tag { color: #37c9ef; }
#engagement-info-panel .tag { color: #81c784; }

.pistol-alert {
    position: absolute;
    top: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(229, 57, 53, 0.92);
    color: white;
    font-size: 1.6rem;
    font-weight: bold;
    padding: 14px 36px;
    border-radius: 10px;
    z-index: 20;
    letter-spacing: 0.1rem;
    box-shadow: 0 0 30px rgba(229, 57, 53, 0.7);
    animation: pulse-alert 0.8s infinite alternate;
}

.pistol-alert.hidden { display: none; }

.camera-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 24px;
}

.camera-overlay.hidden { display: none; }

.camera-card {
    background: #fff;
    border-radius: 16px;
    padding: 32px 36px;
    max-width: 420px;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.camera-card h2 {
    font-size: 1.4rem;
    color: #1a1a2e;
    margin-bottom: 12px;
}

.camera-card p {
    color: #555;
    line-height: 1.6;
    margin-bottom: 20px;
    font-size: 0.92rem;
}

.camera-start-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #37c9ef;
    color: white;
    border: none;
    border-radius: 10px;
    padding: 12px 24px;
    font-size: 1rem;
    font-family: Cairo, sans-serif;
    cursor: pointer;
    font-weight: 600;
}

.camera-start-btn:hover { background: #2bb8de; }

.camera-error {
    margin-top: 16px;
    color: #c62828;
    font-size: 0.85rem;
    line-height: 1.5;
    text-align: left;
    display: none;
}

.camera-error.visible { display: block; }

.hidden { display: none !important; visibility: hidden !important; pointer-events: none !important; }

#app-shell.hidden,
#auth-user-bar.hidden {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

.auth-overlay {
    position: fixed;
    inset: 0;
    background:
        linear-gradient(135deg, rgba(0, 15, 40, 0.78) 0%, rgba(0, 31, 63, 0.82) 45%, rgba(0, 80, 180, 0.55) 100%),
        url('/Resources/Template/auth-background.png') center / cover no-repeat;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    padding: 24px;
    overflow: hidden;
}

.auth-viewfinder {
    position: absolute;
    width: 72px;
    height: 72px;
    border: 2px solid rgba(0, 123, 255, 0.45);
    pointer-events: none;
}

.auth-viewfinder-tl { top: 28px; left: 28px; border-right: none; border-bottom: none; }
.auth-viewfinder-tr { top: 28px; right: 28px; border-left: none; border-bottom: none; }
.auth-viewfinder-bl { bottom: 28px; left: 28px; border-right: none; border-top: none; }
.auth-viewfinder-br { bottom: 28px; right: 28px; border-left: none; border-top: none; }

.auth-overlay.hidden { display: none; }

.auth-card {
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 18px;
    padding: 28px 36px 24px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
    text-align: center;
    position: relative;
    z-index: 100;
}

.auth-logo {
    margin-bottom: 6px;
    max-width: 100%;
    height: auto;
}

.auth-tagline {
    font-size: 0.62rem;
    letter-spacing: 0.14em;
    color: #1a1a2e;
    font-weight: 600;
    margin-bottom: 10px;
}

.auth-card h2 {
    font-size: 1.5rem;
    color: #1a1a2e;
    margin-bottom: 6px;
}

.auth-subtitle {
    color: #666;
    font-size: 0.88rem;
    margin-bottom: 20px;
    line-height: 1.5;
}

.auth-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    border: 1px solid #dde3ea;
    border-radius: 8px;
    background: #f4f6f8;
    font-family: Cairo, sans-serif;
    font-size: 0.9rem;
    cursor: pointer;
    color: #444;
    position: relative;
    z-index: 101;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.auth-tab.active {
    background: #007bff;
    border-color: #007bff;
    color: #fff;
    font-weight: 600;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
}

.auth-form label {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.auth-form label span {
    font-size: 0.78rem;
    color: #666;
    font-weight: 600;
}

.auth-form input {
    padding: 10px 12px;
    border: 1px solid #cfd8dc;
    border-radius: 8px;
    font-family: Cairo, sans-serif;
    font-size: 0.95rem;
}

.auth-form input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.auth-submit-btn {
    margin-top: 4px;
    padding: 12px;
    background: linear-gradient(135deg, #0056b3 0%, #007bff 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: Cairo, sans-serif;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

.auth-submit-btn:hover { background: linear-gradient(135deg, #004494 0%, #0069d9 100%); }
.auth-submit-btn:disabled { opacity: 0.6; cursor: wait; }

.auth-error {
    color: #c62828;
    font-size: 0.82rem;
    line-height: 1.4;
    margin-bottom: 10px;
    text-align: left;
    display: none;
}

.auth-error.visible { display: block; }

.auth-footnote {
    margin-top: 16px;
    font-size: 0.72rem;
    color: #999;
}

.auth-user-bar {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 2500;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    padding: 6px 12px 6px 8px;
    border-radius: 999px;
    font-size: 0.78rem;
    backdrop-filter: blur(6px);
    max-width: calc(100vw - 80px);
}

.auth-user-bar .material-icons { font-size: 20px; }

.auth-user-bar span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
}

.auth-user-bar button {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.35);
    color: #fff;
    border-radius: 999px;
    padding: 4px 10px;
    font-family: Cairo, sans-serif;
    font-size: 0.72rem;
    cursor: pointer;
    flex-shrink: 0;
}

.auth-user-bar button:hover { background: rgba(255, 255, 255, 0.25); }

@keyframes pulse-alert {
    from { box-shadow: 0 0 20px rgba(229, 57, 53, 0.6); }
    to { box-shadow: 0 0 45px rgba(229, 57, 53, 1); }
}

.analytics-shell {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f4f6f8;
}

.analytics-header-bar {
    background: #43a047;
    color: white;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.analytics-header-bar h1 {
    font-size: 1.35rem;
    letter-spacing: 0.08rem;
}

.analytics-header-bar span {
    font-size: 0.85rem;
    opacity: 0.9;
}

.analytics-header-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.engine-badge {
    font-size: 0.72rem;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
}

.engine-badge.yolo {
    background: rgba(156, 39, 176, 0.35);
}

.analytics-btn.yolo-btn {
    background: #7b1fa2;
}

.analytics-btn.yolo-btn:hover {
    background: #6a1b9a;
}

#analytics-yolo-stream {
    width: 100%;
    height: 100%;
    min-height: 320px;
    object-fit: contain;
    display: block;
    background: #000;
}

#analytics-canvas.hidden,
#analytics-video.hidden,
#analytics-yolo-stream.hidden {
    display: none;
}

.analytics-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.analytics-video-panel {
    width: 58%;
    padding: 16px;
    overflow-y: auto;
    border-right: 1px solid #dde3ea;
}

.analytics-dashboard {
    width: 42%;
    padding: 14px;
    overflow-y: auto;
    background: #fff;
}

.analytics-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.analytics-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #43a047;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 12px;
    font-family: Cairo, sans-serif;
    font-size: 0.82rem;
    cursor: pointer;
}

.analytics-btn.small { padding: 8px 10px; }
.analytics-btn:hover { background: #388e3c; }

.analytics-rtsp-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
    align-items: center;
}

.analytics-rtsp-row input {
    flex: 1 1 220px;
    min-width: 180px;
    border: 1px solid #cfd8dc;
    border-radius: 8px;
    padding: 8px 10px;
    font-family: Cairo, sans-serif;
    font-size: 0.82rem;
}

.analytics-note code {
    background: #e8f5e9;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.76rem;
}

.analytics-source,
.analytics-note {
    font-size: 0.78rem;
    color: #546e7a;
    margin-bottom: 6px;
    line-height: 1.4;
}

.analytics-viewport {
    position: relative;
    width: 100%;
    min-height: 320px;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 8px;
}

#analytics-video {
    display: none;
}

#analytics-canvas {
    width: 100%;
    height: auto;
    display: block;
}

.heatmap-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 0.85rem;
    color: #37474f;
}

.dash-block {
    margin-bottom: 16px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px;
}

.dash-block h3 {
    font-size: 0.95rem;
    color: #2e7d32;
    margin-bottom: 10px;
    border-bottom: 1px solid #e8f5e9;
    padding-bottom: 6px;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.metric-card {
    background: #f1f8e9;
    border-radius: 8px;
    padding: 8px;
    text-align: center;
}

.metric-card.wide { grid-column: span 3; }

.metric-card span {
    display: block;
    font-size: 0.72rem;
    color: #558b2f;
}

.metric-card strong {
    font-size: 1.1rem;
    color: #1b5e20;
}

.detect-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
}

.detect-chip {
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 6px 8px;
    font-size: 0.75rem;
    display: flex;
    justify-content: space-between;
}

.detect-chip.on {
    background: #e8f5e9;
    border-color: #81c784;
}

.person-log,
.clothing-list {
    max-height: 160px;
    overflow-y: auto;
    font-size: 0.78rem;
    line-height: 1.5;
}

.person-log-row,
.clothing-row {
    padding: 8px 0;
    border-bottom: 1px solid #eee;
}

.person-log-row.active { background: #f1f8e9; }

.analytics-chat-block h3 {
    display: flex;
    align-items: center;
    gap: 6px;
}

.chat-icon {
    font-size: 1.1rem !important;
    vertical-align: middle;
}

.chat-log {
    max-height: 140px;
    overflow-y: auto;
    background: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 8px;
    font-size: 0.78rem;
    line-height: 1.45;
}

.chat-msg {
    margin-bottom: 8px;
    padding: 6px 10px;
    border-radius: 10px;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-msg-user {
    background: #e8f5e9;
    color: #1b5e20;
    margin-left: 12px;
    border-bottom-right-radius: 2px;
}

.chat-msg-bot {
    background: #fff;
    border: 1px solid #e8f5e9;
    color: #37474f;
    margin-right: 12px;
    border-bottom-left-radius: 2px;
}

.chat-input-row {
    display: flex;
    gap: 6px;
}

.chat-input-row input {
    flex: 1;
    border: 1px solid #c8e6c9;
    border-radius: 8px;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 0.8rem;
}

.chat-input-row input:focus {
    outline: none;
    border-color: #43a047;
    box-shadow: 0 0 0 2px rgba(67, 160, 71, 0.15);
}

.chat-send-btn {
    background: #43a047;
    color: #fff;
    border: none;
    border-radius: 8px;
    width: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-send-btn:hover { background: #388e3c; }

.sv-chat-block h3 { color: #6a1b9a; }
.sv-chat-block .chat-msg-user { background: #f3e5f5; color: #4a148c; }
.sv-chat-block .chat-input-row input { border-color: #ce93d8; }
.sv-chat-block .chat-input-row input:focus { border-color: #8e24aa; box-shadow: 0 0 0 2px rgba(142, 36, 170, 0.15); }
.sv-chat-block .chat-send-btn { background: #7b1fa2; }
.sv-chat-block .chat-send-btn:hover { background: #6a1b9a; }


.log-empty {
    color: #90a4ae;
    font-size: 0.8rem;
    padding: 8px 0;
}

#analytics-section.detection-section {
    overflow-y: auto;
    height: 100vh;
}

.nav-dot[data-section="supervision-section"].active { background: #7b1fa2; border-color: #7b1fa2; }

.analytics-btn.secondary { background: #2e7d32; }
.analytics-btn.secondary:hover { background: #1b5e20; }

.sv-shell {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f3e5f5;
}

.sv-header-bar {
    background: linear-gradient(135deg, #7b1fa2, #4a148c);
    color: white;
    padding: 14px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 10px rgba(74, 20, 140, 0.35);
}

.sv-header-bar h1 { font-size: 1.35rem; letter-spacing: 0.06rem; }

.sv-subtitle { font-size: 0.78rem; opacity: 0.9; margin-top: 4px; }
.sv-subtitle a { color: #e1bee7; }

.sv-header-meta { text-align: right; font-size: 0.82rem; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }

.sv-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
}

.sv-badge.ok { background: rgba(129, 199, 132, 0.25); color: #c8e6c9; }
.sv-badge.warn { background: rgba(255, 183, 77, 0.25); color: #ffe0b2; }

.sv-btn { background: #7b1fa2; }
.sv-btn:hover { background: #6a1b9a; }

.sv-panel { background: #faf5fc; }
.sv-dashboard .dash-block h3 { color: #6a1b9a; }
.sv-card { background: #f3e5f5; }
.sv-card span { color: #7b1fa2; }
.sv-card strong { color: #4a148c; }

.sv-viewport {
    position: relative;
    width: 100%;
    min-height: 320px;
    background: #1a1a2e;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 8px;
}

.sv-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    color: #b39ddb;
    text-align: center;
    padding: 24px;
}

.sv-placeholder i { font-size: 48px; margin-bottom: 12px; }
.sv-placeholder code { margin-top: 12px; background: rgba(255,255,255,0.08); padding: 6px 10px; border-radius: 6px; color: #e1bee7; }

#sv-stream { width: 100%; display: block; }
#sv-stream.hidden, .hidden { display: none; }

.sv-features {
    margin-top: 12px;
    padding-left: 18px;
    color: #6a1b9a;
    font-size: 0.78rem;
    line-height: 1.7;
}

.sv-repo-box {
    margin-top: 14px;
    padding: 12px 14px;
    background: #ede7f6;
    border: 1px solid #ce93d8;
    border-radius: 10px;
    font-size: 0.78rem;
    color: #4a148c;
    line-height: 1.6;
}

.sv-repo-box strong { display: block; margin-bottom: 6px; font-size: 0.88rem; }
.sv-repo-box ul { padding-left: 18px; margin: 8px 0; }
.sv-repo-box code { background: rgba(255,255,255,0.6); padding: 1px 5px; border-radius: 4px; font-size: 0.72rem; }
.sv-repo-box a { color: #6a1b9a; }
.sv-repo-install { margin-top: 8px; font-size: 0.72rem; opacity: 0.9; }

.header-bar .sv-subtitle code,
.sv-subtitle code {
    background: rgba(255,255,255,0.15);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.72rem;
}

#supervision-section.detection-section {
    overflow-y: auto;
    height: 100vh;
}
