:root {
    --primary: #2563eb;
    --dark: #0f172a;
    --light: #f8fafc;
    --border: #e2e8f0;
    --success: #22c55e;
    --danger: #ef4444;
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--light);
    color: var(--dark);
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: var(--dark);
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
}

.logo span {
    color: var(--primary);
}

#connection-status {
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    font-size: 0.875rem;
}

.status-online { background: var(--success); }
.status-offline { background: var(--danger); }

main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

aside {
    width: 350px;
    border-right: 1px solid var(--border);
    background: white;
    overflow-y: auto;
    padding: 1rem;
}

#agents-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

#agents-table th {
    text-align: left;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #64748b;
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
}

#agents-table td {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    font-size: 0.875rem;
}

#agents-table tr:hover {
    background: #f1f5f9;
}

.badge {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
}

section#agent-detail {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

.hidden { display: none !important; }

.detail-header {
    margin-bottom: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 0.5rem;
    cursor: pointer;
    font-weight: 600;
    transition: filter 0.2s;
}

.btn-primary:hover {
    filter: brightness(1.2);
}

.metrics-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-container, .activity-container {
    background: white;
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.chart-container h3, .activity-container h3 {
    margin-bottom: 1rem;
    font-size: 1rem;
    color: #64748b;
}

/* Compact Performance Panel */
.perf-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.perf-header h3 {
    margin: 0;
}

.btn-details {
    background: none;
    border: 1px solid var(--border);
    color: #64748b;
    padding: 0.35rem 0.75rem;
    border-radius: 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-details:hover {
    background: #f1f5f9;
    color: var(--dark);
    border-color: #cbd5e1;
}

.metrics-cards {
    display: flex;
    gap: 0.75rem;
}

.metric-card {
    flex: 1;
    text-align: center;
}

.metric-label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    color: #94a3b8;
    letter-spacing: 0.5px;
    margin-bottom: 0.25rem;
}

.metric-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.5rem;
    font-family: 'Consolas', 'Monaco', monospace;
}

.metric-bar {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.metric-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease, background 0.3s;
    width: 0%;
}

.cpu-bar { background: var(--primary); }
.ram-bar { background: #8b5cf6; }
.disk-bar { background: #06b6d4; }
.bar-warning { background: #f59e0b; }
.bar-danger { background: var(--danger); }

.chart-panel {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.video-placeholder {
    position: relative;
    background: #000;
    border-radius: 0.5rem;
    overflow: hidden;
    aspect-ratio: 16 / 9;
    display: flex;
    align-items: center;
    justify-content: center;
}

#latest-screenshot {
    max-width: 100%;
    max-height: 100%;
}

.video-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}

.live-badge {
    background: var(--danger);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: bold;
    animation: blink 1s infinite;
}

#screenshot-time {
    color: white;
    background: rgba(0,0,0,0.5);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
}

@keyframes blink {
    50% { opacity: 0.5; }
}

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

.modal-content {
    background: white;
    border-radius: 1rem;
    width: 500px;
    max-width: 90%;
    overflow: hidden;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-modal {
    cursor: pointer;
    font-size: 1.5rem;
}

/* Config Modal specifics */
.modal-sm {
    max-width: 400px;
}

.config-desc {
    color: rgba(255,255,255,0.6);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: bold;
    color: rgba(255,255,255,0.8);
}

.form-group input {
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

.btn-primary:hover {
    background: #2563eb; /* darker blue */
}

/* Agent Details Modal (already existing) */
.modal-body {
    padding: 1.5rem;
}

.info-row {
    padding: 0.75rem 0;
    border-bottom: 1px solid #f1f5f9;
}

.info-row:last-child {
    border-bottom: none;
}

.info-row strong {
    color: #64748b;
    width: 150px;
    display: inline-block;
}

.timeline {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 1rem 0;
}

.timeline img {
    height: 100px;
    border-radius: 0.25rem;
    cursor: pointer;
    border: 2px solid transparent;
}

.timeline img:hover {
    border-color: var(--primary);
}

/* ============================
   VIDEO PLAYER STYLES
   ============================ */

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.player-header h3 {
    margin: 0;
    font-size: 1rem;
    color: #64748b;
}

.player-mode-toggle {
    display: flex;
    gap: 0.25rem;
    background: #f1f5f9;
    border-radius: 0.5rem;
    padding: 3px;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0.35rem 0.75rem;
    border: none;
    border-radius: 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    background: transparent;
    color: #64748b;
    transition: all 0.2s ease;
    letter-spacing: 0.5px;
}

.mode-btn.active {
    background: white;
    color: var(--dark);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.mode-btn:hover:not(.active) {
    color: var(--dark);
}

.mode-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.live-dot {
    background: var(--danger);
}

.replay-dot {
    background: var(--primary);
}

.mode-btn.active .live-dot {
    animation: blink 1s infinite;
}

/* Playback Controls */
.playback-controls {
    margin-top: 0.75rem;
    background: var(--dark);
    border-radius: 0 0 0.75rem 0.75rem;
    padding: 0.5rem 1rem 0.75rem;
    margin: 0 -1.5rem -1.5rem;
}

.progress-container {
    position: relative;
    height: 6px;
    background: rgba(255,255,255,0.15);
    border-radius: 3px;
    cursor: pointer;
    margin-bottom: 0.75rem;
    transition: height 0.15s;
}

.progress-container:hover {
    height: 10px;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
    pointer-events: none;
}

.progress-thumb {
    position: absolute;
    top: 50%;
    left: 0%;
    width: 14px;
    height: 14px;
    background: white;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.15s;
    pointer-events: none;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.progress-container:hover .progress-thumb {
    opacity: 1;
}

.progress-tooltip {
    position: absolute;
    top: -25px;
    background: var(--dark);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-family: 'Consolas', monospace;
    transform: translateX(-50%);
    pointer-events: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.3);
    white-space: nowrap;
    border: 1px solid rgba(255,255,255,0.1);
}

.timeline-marks {
    position: relative;
    height: 12px;
    margin-top: -6px;
    margin-bottom: 0.5rem;
    pointer-events: none;
}

.timeline-mark {
    position: absolute;
    width: 2px;
    height: 4px;
    background: rgba(255,255,255,0.3);
    top: 0;
    transform: translateX(-50%);
    pointer-events: auto;
    cursor: pointer;
}

.timeline-mark:hover {
    background: white;
}

.timeline-mark-label {
    position: absolute;
    top: 6px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.6rem;
    color: rgba(255,255,255,0.5);
    font-family: 'Consolas', monospace;
}

.timeline-mark:hover .timeline-mark-label {
    color: white;
}

.controls-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.controls-left {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.ctrl-btn {
    background: none;
    border: none;
    color: rgba(255,255,255,0.85);
    font-size: 1rem;
    cursor: pointer;
    padding: 0.3rem 0.5rem;
    border-radius: 0.25rem;
    transition: all 0.15s;
    line-height: 1;
}

.ctrl-btn:hover {
    background: rgba(255,255,255,0.1);
    color: white;
}

.ctrl-play {
    font-size: 1.25rem;
    padding: 0.3rem 0.6rem;
}

.controls-center {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: rgba(255,255,255,0.7);
    font-size: 0.8rem;
    font-family: 'Consolas', 'Monaco', monospace;
}

.frame-time {
    color: white;
    font-weight: 600;
    font-size: 0.875rem;
}

.frame-counter {
    color: rgba(255,255,255,0.5);
}

.controls-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.time-jump {
    display: flex;
    align-items: center;
    background: rgba(255,255,255,0.1);
    border-radius: 0.3rem;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.2);
}

.time-jump-input {
    background: transparent;
    border: none;
    color: white;
    width: 45px;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-family: 'Consolas', monospace;
    outline: none;
    text-align: center;
}

.time-jump-input::placeholder {
    color: rgba(255,255,255,0.4);
}

.time-jump .ctrl-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    border-radius: 0;
    background: rgba(0,0,0,0.2);
}

.speed-select {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 0.3rem;
    font-size: 0.75rem;
    cursor: pointer;
    outline: none;
}

.speed-select:hover {
    background: rgba(255,255,255,0.15);
}

.speed-select option {
    background: var(--dark);
    color: white;
}

/* Fullscreen support */
.activity-container:fullscreen {
    background: #000;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.activity-container:fullscreen .video-placeholder {
    flex: 1;
    min-height: 0;
}

.activity-container:fullscreen .monitor-image,
.activity-container:fullscreen #latest-screenshot {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.activity-container:fullscreen .playback-controls {
    border-radius: 0;
    border-top: 1px solid rgba(255,255,255,0.1);
}
/* Player Loading */
.player-loading {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: white;
    font-size: 0.875rem;
    z-index: 5;
    border-radius: 0.5rem;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Replay badge */
.replay-badge {
    background: var(--primary) !important;
    animation: none !important;
    opacity: 1 !important;
}

/* Ensure video viewport has relative positioning for overlay */
.video-placeholder {
    position: relative;
}

/* Splash Screen Animado */
.splash-screen {
    position: fixed;
    inset: 0;
    background-color: #030712; /* Very dark background */
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.8s ease-out, visibility 0.8s;
}

.splash-screen.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.splash-content {
    position: relative;
    width: 420px;
    height: 420px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.splash-logo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    animation: tech-pulse 2s infinite alternate, glitch-anim 3s infinite linear;
    filter: drop-shadow(0 0 15px rgba(56, 189, 248, 0.6));
    position: relative;
    z-index: 2;
}

/* Scanline effect */
.cyber-scanline {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: rgba(56, 189, 248, 0.8);
    box-shadow: 0 0 10px rgba(56, 189, 248, 1);
    animation: scan 2s linear infinite;
    z-index: 3;
    opacity: 0.7;
}

@keyframes tech-pulse {
    0% { transform: scale(0.95); filter: drop-shadow(0 0 10px rgba(56, 189, 248, 0.4)); }
    100% { transform: scale(1.05); filter: drop-shadow(0 0 25px rgba(56, 189, 248, 0.9)); }
}

@keyframes scan {
    0% { top: -10%; opacity: 0; }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { top: 110%; opacity: 0; }
}

@keyframes glitch-anim {
    0%, 100% { clip-path: inset(0 0 0 0); transform: translate(0); }
    10% { clip-path: inset(10% 0 80% 0); transform: translate(-2px, 2px); }
    15% { clip-path: inset(0 0 0 0); transform: translate(0); }
    40% { clip-path: inset(80% 0 10% 0); transform: translate(2px, -2px); }
    45% { clip-path: inset(0 0 0 0); transform: translate(0); }
    70% { clip-path: inset(40% 0 40% 0); transform: translate(-2px, 0); }
    75% { clip-path: inset(0 0 0 0); transform: translate(0); }
}

/* Navbar Logo Update */
.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-logo {
    height: 65px;
    width: auto;
    object-fit: contain;
    animation: slow-pulse 4s infinite alternate;
}

@keyframes slow-pulse {
    0% { filter: drop-shadow(0 0 2px rgba(56, 189, 248, 0.2)); }
    100% { filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.6)); }
}

/* Config Modal specifics */
.modal-sm {
    max-width: 400px;
}

.config-desc {
    color: #64748b;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--dark);
}

.form-group input {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    color: var(--dark);
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-family: inherit;
    font-size: 1rem;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

.btn-primary:hover {
    background: #2563eb; /* darker blue */
}
