/* Windows 3.1 Theme with Post-Apocalyptic Glitch Effects */
:root {
    --win31-bg: #008080;
    --win31-grey: #c0c0c0;
    --win31-dark-grey: #808080;
    --win31-light-grey: #dfdfdf;
    --win31-black: #000000;
    --win31-white: #ffffff;
    --win31-blue: #000080;
    --glitch-red: #ff0000;
    --glitch-cyan: #00ffff;
    --glitch-green: #00ff00;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'MS Sans Serif', 'Microsoft Sans Serif', sans-serif;
    background: var(--win31-bg);
    overflow: hidden;
    height: 100vh;
    cursor: default;
    user-select: none;
    position: relative;
}

/* Scanline overlay effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15),
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 9998;
    animation: scanlineMove 8s linear infinite;
}

@keyframes scanlineMove {
    0% { transform: translateY(0); }
    100% { transform: translateY(4px); }
}

/* CRT screen curvature effect */
body::after {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at center, transparent 0%, rgba(0,0,0,0.3) 100%);
    pointer-events: none;
    z-index: 9999;
}

/* Boot Screen */
#boot-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    font-family: 'Courier New', monospace;
    animation: screenFlicker 0.3s infinite alternate;
}

@keyframes screenFlicker {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.97; }
}

.boot-content {
    text-align: center;
    max-width: 600px;
    width: 90%;
    animation: glitchShake 5s infinite;
}

@keyframes glitchShake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-2px, 1px); }
    20% { transform: translate(2px, -1px); }
    30% { transform: translate(0, 0); }
    40% { transform: translate(1px, -2px); }
    50% { transform: translate(-1px, 2px); }
    60% { transform: translate(0, 0); }
}

.boot-logo {
    margin-bottom: 40px;
    position: relative;
}

.boot-logo h1 {
    font-size: 36px;
    margin: 0 0 10px 0;
    color: #0f0;
    text-shadow: 0 0 10px #0f0, 0 0 20px #0f0;
    animation: textGlitch 3s infinite;
    position: relative;
}

@keyframes textGlitch {
    0%, 90%, 100% {
        text-shadow: 0 0 10px #0f0;
    }
    92% {
        text-shadow: 2px 0 10px var(--glitch-red), -2px 0 10px var(--glitch-cyan);
        transform: translate(-2px, 0);
    }
    94% {
        text-shadow: -2px 0 10px var(--glitch-red), 2px 0 10px var(--glitch-cyan);
        transform: translate(2px, 0);
    }
    96% {
        text-shadow: 0 0 10px #0f0;
        transform: translate(0, 0);
    }
}

.boot-logo p {
    font-size: 14px;
    margin: 0;
    color: #888;
}

.boot-messages {
    text-align: left;
    margin: 30px 0;
    min-height: 120px;
}

.boot-line {
    opacity: 0;
    margin: 5px 0;
    font-size: 12px;
    animation: fadeIn 0.5s forwards, lineGlitch 8s infinite;
}

@keyframes lineGlitch {
    0%, 95%, 100% { 
        transform: translateX(0);
        opacity: 1;
    }
    96% { 
        transform: translateX(-3px);
        opacity: 0.8;
    }
    97% { 
        transform: translateX(3px);
        opacity: 0.9;
    }
    98% { 
        transform: translateX(0);
        opacity: 1;
    }
}

.boot-line:nth-child(1) { animation-delay: 0.3s; }
.boot-line:nth-child(2) { animation-delay: 0.8s; }
.boot-line:nth-child(3) { animation-delay: 1.3s; }
.boot-line:nth-child(4) { animation-delay: 1.8s; }
.boot-line:nth-child(5) { animation-delay: 2.3s; }
.boot-line:nth-child(6) { animation-delay: 2.8s; }

@keyframes fadeIn {
    to { opacity: 1; }
}

.boot-progress {
    width: 100%;
    height: 20px;
    background: #333;
    border: 1px solid #666;
    margin-top: 20px;
    overflow: hidden;
}

.boot-progress-bar {
    height: 100%;
    background: #0f0;
    width: 0;
    animation: bootProgress 3.5s ease-in-out forwards;
}

@keyframes bootProgress {
    0% { width: 0%; }
    100% { width: 100%; }
}

/* Login Screen */
#login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--win31-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: loginGlitch 12s infinite;
}

@keyframes loginGlitch {
    0%, 96%, 100% { 
        filter: none;
        background: var(--win31-bg);
    }
    97% { 
        filter: hue-rotate(10deg) contrast(1.1);
        background: #007070;
    }
    98% { 
        filter: hue-rotate(-10deg) brightness(1.1);
        background: #009090;
    }
    99% { 
        filter: none;
        background: var(--win31-bg);
    }
}

.login-dialog {
    background: var(--win31-grey);
    border: 2px outset var(--win31-grey);
    width: 450px;
    box-shadow: 3px 3px 0 rgba(0,0,0,0.5);
    animation: loginDialogShake 20s infinite;
}

@keyframes loginDialogShake {
    0%, 98%, 100% { 
        transform: translate(0, 0);
    }
    98.5% { 
        transform: translate(-2px, 1px);
    }
    99% { 
        transform: translate(2px, -1px);
    }
    99.5% { 
        transform: translate(0, 0);
    }
}

.login-header {
    background: var(--win31-blue);
    color: var(--win31-white);
    padding: 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.login-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 0, 0, 0.3), transparent);
    animation: headerScanGlitch 4s linear infinite;
}

@keyframes headerScanGlitch {
    0% { left: -100%; }
    100% { left: 100%; }
}

.login-icon {
    font-size: 48px;
    margin-bottom: 10px;
    animation: iconPulseGlitch 3s infinite;
    filter: drop-shadow(0 0 10px rgba(255, 0, 0, 0.5));
}

@keyframes iconPulseGlitch {
    0%, 90%, 100% { 
        transform: scale(1);
        filter: drop-shadow(0 0 10px rgba(255, 0, 0, 0.5));
    }
    92% { 
        transform: scale(1.1) rotate(5deg);
        filter: drop-shadow(0 0 20px rgba(0, 255, 255, 0.8));
    }
    94% { 
        transform: scale(0.95) rotate(-5deg);
        filter: drop-shadow(0 0 15px rgba(255, 0, 0, 0.8));
    }
    96% { 
        transform: scale(1.05);
        filter: drop-shadow(0 0 10px rgba(255, 0, 0, 0.5));
    }
}

.login-header h2 {
    margin: 0 0 5px 0;
    font-size: 16px;
}

.login-header p {
    margin: 0;
    font-size: 11px;
    opacity: 0.9;
}

.login-body {
    padding: 20px;
}

.login-form {
    margin-bottom: 15px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 11px;
    font-weight: bold;
}

.form-group input {
    width: 100%;
    transition: all 0.1s;
}

.form-group input:focus {
    animation: inputFocusGlitch 0.3s;
}

@keyframes inputFocusGlitch {
    0% { 
        transform: translateX(0);
        border-color: var(--win31-dark-grey);
    }
    25% { 
        transform: translateX(-2px);
        border-color: #ff0000;
    }
    50% { 
        transform: translateX(2px);
        border-color: #00ffff;
    }
    75% { 
        transform: translateX(-1px);
        border-color: #00ff00;
    }
    100% { 
        transform: translateX(0);
        border-color: var(--win31-dark-grey);
    }
}

.login-error {
    background: #ffcccc;
    border: 2px inset var(--win31-grey);
    padding: 8px;
    margin-bottom: 15px;
    color: #cc0000;
    font-size: 11px;
}

.login-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.login-buttons .win-button {
    flex: 1;
}

.login-info {
    background: #ffffcc;
    border: 2px groove var(--win31-grey);
    padding: 10px;
    font-size: 10px;
    text-align: center;
    position: relative;
    animation: infoPanelGlitch 8s infinite;
}

@keyframes infoPanelGlitch {
    0%, 94%, 100% { 
        background: #ffffcc;
        transform: translate(0, 0);
    }
    95% { 
        background: #ffcccc;
        transform: translate(-1px, 1px);
    }
    96% { 
        background: #ccffcc;
        transform: translate(1px, -1px);
    }
    97% { 
        background: #ccccff;
        transform: translate(-1px, -1px);
    }
    98% { 
        background: #ffffcc;
        transform: translate(0, 0);
    }
}

.login-info small {
    display: block;
    margin-top: 5px;
    line-height: 1.4;
}

/* Desktop */
#desktop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 40px;
    background: var(--win31-bg);
    animation: desktopGlitch 15s infinite;
}

@keyframes desktopGlitch {
    0%, 97%, 100% { 
        filter: none;
    }
    98% { 
        filter: hue-rotate(20deg) contrast(1.2);
    }
    99% { 
        filter: hue-rotate(-20deg) brightness(1.1);
    }
}

/* Desktop Icons */
.desktop-icon {
    position: absolute;
    width: 80px;
    text-align: center;
    cursor: pointer;
    padding: 5px;
    transition: transform 0.1s;
}

.desktop-icon:hover {
    background: rgba(0, 0, 128, 0.3);
    outline: 1px dotted var(--win31-white);
    animation: iconGlitch 0.5s;
}

@keyframes iconGlitch {
    0%, 100% { transform: translate(0, 0); }
    25% { transform: translate(-1px, 1px); }
    50% { transform: translate(1px, -1px); }
    75% { transform: translate(-1px, -1px); }
}

.icon-image {
    font-size: 32px;
    margin-bottom: 5px;
    filter: drop-shadow(1px 1px 0px rgba(0,0,0,0.5));
    animation: iconFlicker 7s infinite;
}

@keyframes iconFlicker {
    0%, 96%, 100% { opacity: 1; }
    97% { opacity: 0.7; }
    98% { opacity: 1; }
    99% { opacity: 0.8; }
}

.icon-label {
    color: var(--win31-white);
    font-size: 11px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.8);
    word-wrap: break-word;
}

/* Taskbar */
#taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: var(--win31-grey);
    border-top: 2px solid var(--win31-white);
    display: flex;
    align-items: center;
    z-index: 9999;
    animation: taskbarGlitch 25s infinite;
}

@keyframes taskbarGlitch {
    0%, 99%, 100% { 
        transform: translateY(0);
        filter: none;
    }
    99.3% { 
        transform: translateY(-2px);
        filter: brightness(1.3);
    }
    99.6% { 
        transform: translateY(1px);
        filter: brightness(0.9);
    }
}

#start-button {
    height: 32px;
    margin: 4px;
    padding: 0 15px;
    background: var(--win31-grey);
    border: 2px outset var(--win31-grey);
    display: flex;
    align-items: center;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
}

#start-button:active {
    border-style: inset;
}

#taskbar-windows {
    flex: 1;
    height: 32px;
    margin: 4px 4px 4px 0;
    display: flex;
    gap: 4px;
    overflow-x: auto;
}

.taskbar-item {
    height: 100%;
    padding: 0 10px;
    background: var(--win31-grey);
    border: 2px outset var(--win31-grey);
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 11px;
    min-width: 120px;
    max-width: 200px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.taskbar-item.active {
    border-style: inset;
}

#system-tray {
    height: 32px;
    margin: 4px;
    padding: 0 10px;
    border: 2px inset var(--win31-grey);
    display: flex;
    align-items: center;
    font-size: 11px;
}

#clock {
    animation: clockFlicker 10s infinite;
}

@keyframes clockFlicker {
    0%, 97%, 100% { opacity: 1; }
    98% { opacity: 0.6; }
    99% { opacity: 1; }
}

/* Start Menu */
#start-menu {
    position: fixed;
    bottom: 40px;
    left: 4px;
    width: 200px;
    background: var(--win31-grey);
    border: 2px outset var(--win31-grey);
    z-index: 10000;
    box-shadow: 3px 3px 0 rgba(0,0,0,0.3);
}

#start-menu.hidden {
    display: none;
}

.start-menu-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 11px;
}

.start-menu-item:hover {
    background: var(--win31-blue);
    color: var(--win31-white);
}

.start-menu-separator {
    height: 2px;
    background: var(--win31-dark-grey);
    margin: 2px 0;
    border-top: 1px solid var(--win31-light-grey);
}

/* Window Styles */
.window {
    position: absolute;
    min-width: 300px;
    min-height: 200px;
    background: var(--win31-grey);
    border: 2px outset var(--win31-grey);
    box-shadow: 2px 2px 0 rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    animation: windowAppear 0.3s ease-out, windowGlitch 20s infinite;
}

@keyframes windowAppear {
    0% {
        transform: scale(0.9);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes windowGlitch {
    0%, 98%, 100% { 
        filter: none;
    }
    98.5% { 
        filter: contrast(1.3) brightness(1.2);
    }
    99% { 
        filter: hue-rotate(5deg);
    }
    99.5% { 
        filter: none;
    }
}

.window.maximized {
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: calc(100vh - 40px) !important;
}

.window-titlebar {
    background: var(--win31-blue);
    color: var(--win31-white);
    padding: 3px 5px;
    display: flex;
    align-items: center;
    cursor: move;
    font-size: 11px;
    font-weight: bold;
    position: relative;
}

.window-titlebar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255,0,0,0.1) 50%, transparent 100%);
    animation: titlebarScan 3s linear infinite;
    pointer-events: none;
}

@keyframes titlebarScan {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.window-titlebar.inactive {
    background: var(--win31-dark-grey);
}

.window-title {
    flex: 1;
    padding-left: 5px;
}

.window-button {
    width: 18px;
    height: 18px;
    background: var(--win31-grey);
    border: 2px outset var(--win31-grey);
    margin-left: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    color: var(--win31-black);
}

.window-button:active {
    border-style: inset;
}

.window-content {
    flex: 1;
    background: var(--win31-white);
    border: 2px inset var(--win31-grey);
    margin: 2px;
    overflow: auto;
    padding: 10px;
}

/* Button styles */
.win-button {
    background: var(--win31-grey);
    border: 2px outset var(--win31-grey);
    padding: 5px 15px;
    font-size: 11px;
    cursor: pointer;
    font-family: 'MS Sans Serif', sans-serif;
}

.win-button:active {
    border-style: inset;
}

.win-button:disabled {
    color: var(--win31-dark-grey);
    cursor: default;
}

/* Input styles */
.win-input {
    background: var(--win31-white);
    border: 2px inset var(--win31-grey);
    padding: 4px;
    font-size: 11px;
    font-family: 'MS Sans Serif', sans-serif;
}

/* Panel styles */
.win-panel {
    background: var(--win31-grey);
    border: 2px groove var(--win31-grey);
    padding: 10px;
    margin: 5px 0;
}

/* Utility classes */
.hidden {
    display: none !important;
}

.flex-row {
    display: flex;
    gap: 5px;
}

.flex-col {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Glitch effect overlay for corrupted data messages */
.corruption-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #000;
    color: #ff0000;
    border: 3px solid #ff0000;
    padding: 20px 40px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    text-align: center;
    z-index: 10002;
    animation: corruptionFlash 0.2s infinite;
    box-shadow: 0 0 20px rgba(255, 0, 0, 0.8),
                inset 0 0 20px rgba(255, 0, 0, 0.3);
}

@keyframes corruptionFlash {
    0%, 100% { 
        opacity: 1;
        color: #ff0000;
    }
    50% { 
        opacity: 0.7;
        color: #00ff00;
    }
}

.corruption-message::before {
    content: '⚠ WARNING ⚠';
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    animation: colorCycle 0.5s infinite;
}

@keyframes colorCycle {
    0% { color: #ff0000; }
    33% { color: #00ff00; }
    66% { color: #0000ff; }
    100% { color: #ff0000; }
}

/* Scrollbar styling (approximate Windows 3.1) */
::-webkit-scrollbar {
    width: 16px;
    height: 16px;
}

::-webkit-scrollbar-track {
    background: var(--win31-grey);
}

::-webkit-scrollbar-thumb {
    background: var(--win31-grey);
    border: 2px outset var(--win31-grey);
}

::-webkit-scrollbar-button {
    background: var(--win31-grey);
    border: 2px outset var(--win31-grey);
}

/* Loading indicator */
.loading {
    text-align: center;
    padding: 20px;
    color: var(--win31-dark-grey);
}

/* Status bar */
.status-bar {
    background: var(--win31-grey);
    border-top: 2px groove var(--win31-grey);
    padding: 4px 8px;
    font-size: 11px;
    display: flex;
    gap: 10px;
}

.status-item {
    border: 2px inset var(--win31-grey);
    padding: 2px 8px;
}
