/* ===== RESET & BASE ===== */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: #000000; /* True black pour éviter la lumière sur caméra */
    color: #ffffff;
    height: 100vh;
    overflow: hidden;
    user-select: none;
}

/* ===== VIRTUAL DESKTOP ===== */
.desktop {
    position: relative;
    width: 100vw;
    height: calc(100vh - 48px);
    background-color: #000000;
    overflow: hidden;
    padding: 20px;
}

/* Desktop Icons */
.desktop-icons {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 1;
}

.desktop-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 80px;
    cursor: pointer;
    border-radius: 4px;
    padding: 8px 4px;
    transition: background-color 0.2s;
}

.desktop-icon:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.desktop-icon .icon-img {
    font-size: 2em;
    margin-bottom: 6px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5));
}

.desktop-icon .icon-label {
    font-size: 0.75em;
    text-align: center;
    color: rgba(255, 255, 255, 0.85);
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    word-break: break-word;
}

/* ===== WINDOW FRAME ===== */
.window {
    position: absolute;
    background: rgba(12, 12, 12, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10;
    transition: transform 0.2s cubic-bezier(0.1, 0.9, 0.2, 1), opacity 0.2s ease, display 0.2s allow-discrete;
}

.window.minimized {
    transform: scale(0.8) translateY(100px);
    opacity: 0;
    pointer-events: none;
    z-index: 1 !important;
}

.window.maximized {
    top: 10px !important;
    left: 10px !important;
    width: calc(100% - 20px) !important;
    height: calc(100% - 20px) !important;
}

.window-titlebar {
    display: flex;
    align-items: center;
    background: rgba(22, 22, 22, 0.98);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 10px 14px;
    cursor: move;
    user-select: none;
}

.window-title-icon {
    margin-right: 10px;
    font-size: 1.1em;
}

.window-title {
    flex: 1;
    font-size: 0.85em;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.9);
}

.window-controls {
    display: flex;
    gap: 6px;
}

.window-control-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    font-family: inherit;
    font-size: 1.1em;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s, color 0.15s;
}

.window-control-btn:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.window-control-btn.btn-close:hover {
    background-color: #ff1744;
    color: #ffffff;
}

.window-body {
    flex: 1;
    overflow: hidden;
    position: relative;
    container-type: size; /* Enable container queries for scaling children */
}

/* ===== SANITY MONITOR WINDOW ===== */
.sanity-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: clamp(10px, 3.5cqw, 24px);
    gap: clamp(8px, 2.5cqh, 18px);
    justify-content: flex-start;
    overflow: hidden;
}

.team-average {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(6px, 2.2cqh, 20px) clamp(12px, 4cqw, 32px);
    border-radius: clamp(6px, 1.8cqw, 14px);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.04);
    margin-bottom: 0px;
}

.average-label {
    font-size: clamp(0.7em, 2.4cqw, 1.1em);
    font-weight: 600;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 2px;
}

.average-value-container {
    display: flex;
    align-items: baseline;
    color: #ffffff !important;
    text-shadow: 0 0 15px rgba(255, 255, 255, 0.5) !important;
}

.average-value {
    font-size: clamp(2.5em, 9cqw, 5.5em);
    font-weight: 700;
    line-height: 1;
}

.average-percent-sign {
    font-size: clamp(1.1em, 4cqw, 2.4em);
    font-weight: 400;
    margin-left: 2px;
    opacity: 0.8;
}

.players-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: clamp(8px, 2.5cqw, 20px);
    flex: 1;
    min-height: 0; /* Prevents container from overflowing grid height */
}

.player-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: clamp(6px, 1.8cqw, 14px);
    padding: clamp(8px, 2.5cqw, 20px);
    transition: border-color 0.2s, background-color 0.2s;
    min-height: 0; /* Ensures child grids shrink properly */
}

.player-card:hover {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
}

.player-name {
    font-size: clamp(0.75em, 2.8cqw, 1.4em);
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.65);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-sanity-bar {
    position: relative;
    height: clamp(8px, 2.2cqh, 20px);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: clamp(4px, 1.1cqh, 10px);
    overflow: hidden;
    margin: clamp(4px, 1.5cqh, 12px) 0;
}

.sanity-fill {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, #00b0ff, #00e5ff);
    transition: width 0.4s cubic-bezier(0.2, 0.8, 0.2, 1), background 0.4s ease;
    border-radius: 6px;
}

/* Oscillating indicator */
.sanity-oscillating-line {
    position: absolute;
    top: 0;
    right: 0;
    height: 100%;
    width: 4px;
    background-color: #ffffff;
    box-shadow: 0 0 8px #ffffff;
    opacity: 0.8;
    display: none; /* Can be enabled for glitch effects */
}

.player-percentage {
    align-self: flex-end;
    font-size: clamp(1.15em, 3.8cqw, 2.2em);
    font-weight: 700;
    color: #ffffff !important;
}

/* Card states */
.player-card.dead {
    border-color: rgba(255, 23, 68, 0.3);
    background: rgba(255, 23, 68, 0.02);
}

.player-card.dead .player-name {
    color: rgba(255, 23, 68, 0.7);
}

.player-card.dead .sanity-fill {
    width: 0% !important;
    background: #ff1744;
}

.player-card.dead .player-percentage {
    color: #ffffff !important;
    text-shadow: 0 0 10px rgba(255, 23, 68, 0.75) !important;
}

.player-card.disconnected {
    border-color: rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.01);
}

.player-card.disconnected .player-name {
    color: rgba(255, 255, 255, 0.35);
}

.player-card.disconnected .sanity-fill {
    width: 0% !important;
    background: #455a64;
}

.player-card.disconnected .player-percentage {
    color: rgba(255, 255, 255, 0.35) !important;
    text-shadow: none !important;
}

/* Card colors based on sanity level */
.sanity-mid .sanity-fill {
    background: linear-gradient(90deg, #ffa726, #ffb74d) !important;
}

.sanity-low .sanity-fill {
    background: linear-gradient(90deg, #ff1744, #ff5252) !important;
}


/* ===== PARANORMAL ACTIVITY WINDOW ===== */
.activity-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: clamp(10px, 3.5cqw, 24px);
}

.activity-header {
    margin-bottom: clamp(6px, 1.8cqh, 16px);
}

.activity-label {
    font-size: clamp(0.75em, 2.5cqw, 1.2em);
    font-weight: 600;
    letter-spacing: 3px;
    color: rgba(255, 255, 255, 0.4);
}

.chart-wrapper {
    display: flex;
    flex: 1;
    gap: clamp(8px, 2.2cqw, 18px);
}

.chart-y-axis {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    font-size: clamp(0.7em, 2.2cqw, 1.1em);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.3);
    text-align: right;
    width: clamp(20px, 5cqw, 40px);
    padding: 2px 0;
    user-select: none;
}

.chart-area {
    flex: 1;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    background: #020202;
    position: relative;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.9);
    min-height: 0; /* critical to allow shrinking in flex layouts */
}

#activity-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: block;
}

.chart-x-axis {
    display: flex;
    justify-content: space-between;
    font-size: clamp(0.7em, 2.2cqw, 1.1em);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.3);
    margin-top: 8px;
    padding-left: clamp(32px, 7cqw, 60px);
    user-select: none;
}

/* ===== TASKBAR ===== */
.taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 48px;
    background: rgba(10, 10, 10, 0.96);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 12px;
    z-index: 9999;
}

/* Start Menu Button */
.start-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 1.4em;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background-color 0.2s, transform 0.1s;
}

.start-btn:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.start-btn:active {
    transform: scale(0.95);
}

.start-icon {
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.2));
}

/* Fake Search bar */
.search-bar {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 20px;
    padding: 6px 12px;
    width: 150px;
    gap: 8px;
}

.search-icon {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.4);
}

.search-bar input {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 0.8em;
    font-family: inherit;
    width: 100%;
    outline: none;
    cursor: default;
}

/* Taskbar apps list */
.taskbar-apps {
    display: flex;
    gap: 8px;
    flex: 1;
}

.taskbar-app-btn {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.85);
    padding: 0;
    width: 38px;
    height: 38px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.taskbar-app-btn span {
    font-size: 1.25em;
}

.taskbar-app-btn:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}

.taskbar-app-btn.active {
    background-color: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    position: relative;
}

.taskbar-app-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 20%;
    width: 60%;
    height: 3px;
    background-color: #00e5ff;
    border-radius: 3px;
    box-shadow: 0 0 6px rgba(0, 229, 255, 0.6);
}

/* Notification Area (Systray) */
.systray {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    padding: 6px 12px;
    height: 34px;
}

.systray-icon {
    font-size: 0.85em;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: color 0.2s;
}

.systray-icon:hover {
    color: rgba(255, 255, 255, 0.9);
}

.systray-clock {
    font-size: 0.8em;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    margin-left: 4px;
    letter-spacing: 0.5px;
}

/* ===== RESIZE HANDLE ===== */
.window-resize-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: transparent;
    bottom: 0;
    right: 0;
    cursor: se-resize;
    z-index: 999;
}

.window-resize-handle::after {
    content: '';
    position: absolute;
    right: 3px;
    bottom: 3px;
    width: 5px;
    height: 5px;
    border-right: 1.5px solid rgba(255, 255, 255, 0.3);
    border-bottom: 1.5px solid rgba(255, 255, 255, 0.3);
}

/* ===== ACCENT COLOR OVERRIDES PER PLAYER ===== */
.player-card[data-player="1"]:not(.dead):not(.disconnected) .sanity-fill {
    background: linear-gradient(90deg, #0091ea, #00e5ff) !important;
}

.player-card[data-player="2"]:not(.dead):not(.disconnected) .sanity-fill {
    background: linear-gradient(90deg, #00c853, #69f0ae) !important;
}

.player-card[data-player="3"]:not(.dead):not(.disconnected) .sanity-fill {
    background: linear-gradient(90deg, #ff6d00, #ffc400) !important;
}

.player-card[data-player="4"]:not(.dead):not(.disconnected) .sanity-fill {
    background: linear-gradient(90deg, #d500f9, #ff4081) !important;
}

/* ===== DESKTOP WATERMARK ===== */
.desktop-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 5.5em;
    font-weight: 700;
    letter-spacing: 16px;
    color: rgba(255, 255, 255, 0.012); /* Subtly visible on camera */
    text-transform: uppercase;
    pointer-events: none;
    user-select: none;
    z-index: 0;
}
