/* --- FEELS FM: NEO-BRUTALIST THEME (FIXED V3) --- */

:root {
    --bg-color: #f4f4f0;
    --grid-color: #e0e0e0;
    --primary: #a3ffac;
    --accent: #ff90e8;
    --text: black;
    --border: 2px solid black;
    --shadow: 4px 4px 0px black;
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: inherit;
}

body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
    min-height: 100vh;
    background-color: var(--bg-color);
    color: var(--text);
    font-family: 'Courier New', Courier, monospace;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    background-image: 
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg,var(--grid-color) 1px, transparent 1px);
    background-size: 30px 30px;
}

.container {
    text-align: center;
    width: 90%;
    max-width: 1200px;
    position: relative;
    padding-bottom: 50px;
}

/* --- HEADER SECTION --- */
header {
    width: 100%;           
    max-width: 1000px;
    margin: 0 auto;
    position: relative;
    padding-top: 40px;
    margin-bottom: 60px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10;
}

header h1 {
    font-size: 3.5rem;
    font-weight: 900;
    text-transform: uppercase;
    margin-bottom: 5px;
    background: var(--text);
    color: white;
    display: inline-block;
    padding: 10px 20px;
    border: var(--border);
    box-shadow: var(--shadow);
    transform: rotate(-2deg);
}

/* Header Buttons */
#theme-btn, #logout-btn {
    position: absolute;
    top: 25px;
    z-index: 100;
    transition: all 0.3s ease;
    margin-top: 0;
}

#theme-btn { left: 10px; }
#logout-btn { right: 10px; }

/* --- MAIN LAYOUT ENGINE --- */
.workstation {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 40px;
    margin-top: 20px;
    width: 100%;
}

/* Left Column: Camera, Chart, History */
.col-left {
    flex: 2;
    min-width: 300px;      
    max-width: 800px;      
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* Right Column: Music Player */
.col-right {
    flex: 1;
    min-width: 280px;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* --- COMPONENT BOXES --- */
.camera-box, .chart-box, .player-box, #history-section {
    background: white;
    border: var(--border);
    box-shadow: var(--shadow);
    padding: 20px; /* Standard padding for all boxes */
    border-radius: 0;
    transition: transform 0.2s;
    width: 100%;
    box-sizing: border-box;
    position: relative; /* Ensure overflow hidden works correctly */
    overflow: hidden;   /* Clip content that hits edges */
}

.camera-box:hover, .player-box:hover, .chart-box:hover, #history-section:hover {
    transform: translate(-2px,-2px);
    box-shadow: 7px 7px 0px black;
}

/* Chart Box Specifics */
.chart-box {
    display: flex;
    flex-direction: column;
    height: 350px !important; 
    background: white;
    border: var(--border);
    box-shadow: var(--shadow);
    padding: 10px;
    box-sizing: border-box;
    overflow: hidden;
    position: relative;
}

.chart-box .window-bar {
    flex: 0 0 auto; 
    margin-bottom: 10px;
}

/* Camera Box Specifics */
.camera-box {
    padding: 10px; /* Slightly less padding for video */
}

/* Player Box Specifics - FIX FOR MISSING HEADER */
.player-box iframe {
    /* Use negative margins to pull iframe to edges, counteracting parent padding */
    margin: 0 -20px -20px -20px; 
    width: calc(100% + 40px) !important; 
    display: block;
}


/* WRAPPER FIXES */
.camera-wrapper {
    position: relative; 
    width: 100%;
    height: auto;
}
.video-wrapper {
    position: relative;
    width: 100%;
    height: auto;
    overflow: hidden;
    background: black;
    min-height: 240px;
}

#video {
    width: 100%;
    height: auto;
    display: block;
    transform: scaleX(-1); /* Mirror the video feed */
}

#face-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
    pointer-events: none; 
    z-index: 10;
}

#moodChart {
    pointer-events: auto !important;
    transform: none !important;
    width: 100% !important;
    height: 100% !important;
}

/* --- BUTTON STYLES --- */
button {
    font-family: inherit;
    font-weight: bold;
    text-transform: uppercase;
    background: var(--primary);
    color: var(--text);
    border: var(--border);
    box-shadow: var(--shadow);
    padding: 15px 30px;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.1s;
    margin-top: 15px;
}

button:hover {
    transform: translate(-2px,-2px);
    box-shadow: 7px 7px 0px black;
}

button:active {
    transform: translate(5px,5px);
    box-shadow: 0px 0px 0px black;
}

.logout-btn {
    background: #ff6b6b;
    font-size: 0.9rem;
    padding: 10px 15px;
}

/* Window Bars */
.window-bar {
    background: var(--text);
    color: white;
    padding: 8px 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    font-weight: bold;
    letter-spacing: 1px;
    /* Negative margins to pull bar into the padding area */
    margin: -20px -20px 20px -20px; 
}

/* Camera box has smaller padding, adjust its window bar margin */
.camera-box .window-bar {
    margin: -10px -10px 10px -10px;
}

/* History Section Styles */
#history-section:after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 15px;
    background: 
        linear-gradient(45deg,transparent 33.333%,white 33.333%,white 66.667%,transparent 66.667%),
        linear-gradient(-45deg,transparent 33.333%,white 33.333%,white 66.667%,transparent 66.667%);
    background-size: 20px 40px;
    border-top: var(--border);
}

#mood-list li {
    border-bottom: 1px dashed black;
    padding: 10px 0;
    margin: 0;
    background: transparent !important;
    border-radius: 0 !important;
    color: black !important;
    display: flex;
    justify-content: space-between;
}

#mood-list span {
    color: black !important;
    font-family: 'Courier New', monospace;
}


/* --- DARK MODE THEME --- */
body.dark-mode {
    --bg-color: #050505;
    --grid-color: #222;
    --text: #ffffff;
    --border: 3px solid white;
    --shadow: 5px 5px 0px white;
    --primary: #00ff41;
}

body.dark-mode .window-bar {
    background: white;
    color: black;
    border-bottom: 3px solid black;
}

body.dark-mode header h1 {
    background: white;
    color: black;
}

body.dark-mode .chart-box,
body.dark-mode #history-section,
body.dark-mode .camera-box,
body.dark-mode .player-box,
body.dark-mode .art-window,
body.dark-mode .system-terminal-box,
body.dark-mode .time-module,
body.dark-mode .graffiti-box {
    background: white; 
    color: black;
    border: 3px solid white;
    box-shadow: 5px 5px 0px #333;
}
body.dark-mode .graffiti-box .window-bar {
    background: black !important;
    color: white !important;
}
body.dark-mode .art-window .window-bar,
body.dark-mode .system-terminal-box .window-bar {
    background: black !important;
    color: white !important;
    border-bottom: 3px solid black !important;
}

/* Invert hover states for dark mode */
body.dark-mode .chart-box:hover,
body.dark-mode .camera-box:hover,
body.dark-mode .player-box:hover,
body.dark-mode #history-section:hover,
body.dark-mode .art-window:hover,
body.dark-mode .system-terminal-box:hover {
    box-shadow: 7px 7px 0px white !important;
    border-color: black !important;
}

body.dark-mode button {
    border: 3px solid black !important;
    box-shadow: 5px 5px 0px black !important;
    color: black !important;
}

/* Header Buttons in Dark Mode */
body.dark-mode #theme-btn, 
body.dark-mode #logout-btn {
    border: 3px solid white !important;
    box-shadow: 5px 5px 0px white !important;
    color: black !important;
}

body.dark-mode #theme-btn { background: white !important; border-color: #050505 !important; }
body.dark-mode #logout-btn { background: #ff6b6b !important; border-color: #050505 !important; }


/* --- MOBILE OPTIMIZATION PATCH --- */
@media screen and (max-width: 768px) {
    header {
        padding-top: 60px;
    }

    header h1 {
        font-size: 1.8rem;
    }

    header p {
        font-size: 0.8rem;
        padding: 0 10px;
        word-wrap: break-word; 
    }

    #theme-btn, #logout-btn {
        top: 15px;
        padding: 5px 10px;
        font-size: 0.8rem;
        z-index: 9999; 
    }
    #theme-btn { left: 15px; }
    #logout-btn { right: 15px; }

    .workstation {
        flex-direction: column;
        align-items: center;
        width: 100%;
        margin-top: 20px;
        gap: 20px;
    }

    .col-right {
        order: -1;
        width: 100%;
        max-width: 100%;
        margin-bottom: 0;
    }

    .col-left {
        order: 2;
        width: 100%;
        max-width: 100%;
    }

    .player-box iframe {
        width: calc(100% + 40px) !important;
        margin: 0 -20px -20px -20px;
        height: 150px !important;
        border: none !important;
        display: block;
    }

    .player-box {
        width: 100%;
        background: white;
        border: var(--border);
        box-shadow: var(--shadow);
    }
}

/* CLOSE BUTTON STYLING */
.window-controls span:last-child {
    color: black;
    background: #ff6b6b;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}
.window-controls span:last-child:hover {
    background: #ff6b6b;
    color: white;
}

/* --- EXTRA MODULES (Art & Terminal) --- */
.art-window, .system-terminal-box, .time-module {

    border: var(--border);
    box-shadow: var(--shadow);
    background: white;
    color: black;
    
    transition: all 0.2s ease-in-out;
    margin-top: 25px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* Hover Effect - Matches Global Button Hover */
.art-window:hover, .system-terminal-box:hover, .time-module:hover {
    transform: translate(-2px, -2px);
    box-shadow: 7px 7px 0px black;
}

/* Image Border */
.art-window img {
    border-bottom: var(--border);
    display: block;
}

/* Window Headers */
.art-window .window-bar, .system-terminal-box .window-bar {
    background: var(--text) !important;
    color: var(--bg-color) !important;
    padding: 8px 12px;
    margin: 0 !important;
    width: 100%;
    box-sizing: border-box;
}

.terminal-content {
    padding: 15px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: inherit;
    flex: 1;
    overflow: hidden;
    text-align: left;
}

.terminal-content p {
    margin: 0 0 5px 0;
}

/* The Blinking Cursor Animation */
.blinking-cursor {
    display: inline-block;
    color: var(--primary);
    animation: blink 1s step-end infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.laptop-only { display: none; }
@media (min-width: 1024px) {
    .laptop-only { display: flex; }
}

.time-module {
    border: var(--border);
    box-shadow: var(--shadow);
    background: white;
    margin-top: 25px;
    box-sizing: border-box;
}

.time-module .window-bar {
    background: black !important;
    color: white !important;
    padding: 8px 12px;
    margin: 0 !important;
    width: 100%;
    box-sizing: border-box;
}

body.dark-mode .time-module .window-bar {
    background: black !important;
    color: white !important;
}

body.dark-mode .time-module {
    background: white !important;
    color: black !important;

    border: 3px solid white !important;
    box-shadow: 5px 5px 0px #333 !important;
}

body.dark-mode #digital-clock,
body.dark-mode #date-display {
    color: black !important;
}

body.dark-mode .time-module .window-bar {
    background: black !important;
    color: white !important;
    border-bottom: none !important;
}

/* --- GRAFFITI IMAGE WINDOW --- */
.graffiti-window {
    /* Use standard theme variables */
    border: var(--border);
    box-shadow: var(--shadow);
    background: white; 
    margin-top: 25px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    transition: all 0.2s ease-in-out;
}

/* Hover Effect */
.graffiti-window:hover {
    transform: translate(-2px, -2px);
    box-shadow: 7px 7px 0px black;
}

/* Header Styling - Forces Black Header */
.graffiti-window .window-bar {
    background: black !important;
    color: white !important;
    padding: 8px 12px;
    margin: 0 !important;
    width: 100%;
    box-sizing: border-box;
}

/* --- DARK MODE RULES --- */
body.dark-mode .graffiti-window {
    background: white !important;
    color: black !important;
    border: 3px solid white !important;
    box-shadow: 5px 5px 0px #333 !important;
}

body.dark-mode .graffiti-window .window-bar {
    background: black !important;
    color: white !important;
}