:root {
    /* Couleurs principales */
    --color-primary: #22d3ee;
    --color-secondary: #a855f7;
    --color-danger: #ef4444;
    --color-success: #22c55e;
    --color-warning: #f59e0b;
    
    /* Couleurs de fond */
    --bg-dark: #0a0a0f;
    --bg-darker: #050508;
    --bg-gray: #1a1a2e;
    --bg-gray-light: #2d2d44;
    
    /* Couleurs de texte */
    --text-primary: #22d3ee;
    --text-secondary: #a855f7;
    --text-muted: #6b7280;
    --text-light: #e5e7eb;
    
    /* Bordures et ombres */
    --border-primary: 2px solid var(--color-primary);
    --border-secondary: 2px solid var(--color-secondary);
    --border-danger: 2px solid var(--color-danger);
    --border-success: 2px solid var(--color-success);
    
    --shadow-primary: 0 0 20px rgba(34, 211, 238, 0.4);
    --shadow-secondary: 0 0 20px rgba(168, 85, 247, 0.4);
    --shadow-danger: 0 0 20px rgba(239, 68, 68, 0.4);
    
    /* Animations */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
}

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

body {
    font-family: 'Courier New', monospace;
    background: var(--bg-dark);
    color: var(--text-light);
    overflow: hidden;
}

/* Effets CRT */
.scanlines {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg,
        rgba(0, 0, 0, 0.15) 0px,
        rgba(0, 0, 0, 0.15) 1px,
        transparent 1px,
        transparent 2px
    );
    pointer-events: none;
    z-index: 9999;
    animation: flicker 0.15s infinite;
    opacity: 0.2;
}

.vignette {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: 9998;
}

@keyframes flicker {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 0.25; }
}

@keyframes glow {
    from { box-shadow: var(--shadow-primary); }
    to { box-shadow: 0 0 60px rgba(168, 85, 247, 0.6); }
}

/* Écrans */
.screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.screen.active {
    display: block;
}

/* Écran de connexion */
#login-screen {
    background: linear-gradient(135deg, #581c87 0%, #1e3a8a 50%, #0e7490 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-box {
    background: var(--bg-darker);
    border: 4px solid var(--color-primary);
    border-radius: 8px;
    padding: 2rem;
    max-width: 400px;
    width: 90%;
    box-shadow: var(--shadow-primary);
    animation: glow 2s ease-in-out infinite alternate;
    position: relative;
    z-index: 10;
}

.login-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

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

.login-header h1 {
    font-size: 1.5rem;
    color: var(--color-primary);
    text-shadow: 0 0 10px rgba(34, 211, 238, 0.8);
}

.version {
    color: var(--color-secondary);
    font-size: 0.875rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.form-group label {
    color: var(--text-primary);
    font-size: 0.875rem;
}

.form-group input {
    background: var(--bg-gray);
    border: 2px solid #0891b2;
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    box-shadow: 0 0 10px rgba(34, 211, 238, 0.3);
    transition: var(--transition-normal);
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-secondary);
}

.btn-primary {
    background: linear-gradient(90deg, #9333ea 0%, #0891b2 100%);
    color: white;
    border: none;
    padding: 0.875rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.5);
    transition: var(--transition-normal);
}

.btn-primary:hover {
    background: linear-gradient(90deg, #7c3aed 0%, #0e7490 100%);
    transform: translateY(-2px);
}

.error-message {
    color: var(--color-danger);
    font-size: 0.875rem;
    text-align: center;
    animation: pulse 1s infinite;
    min-height: 1.25rem;
}

.copyright {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 1.5rem;
}

/* Bureau */
#desktop {
    background: linear-gradient(135deg, #1f2937 0%, #1e3a8a 50%, #581c87 100%);
    padding-bottom: 50px;
}

.taskbar {
    background: linear-gradient(90deg, #7c3aed 0%, #0891b2 100%);
    color: white;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 100;
}

.taskbar-left, .taskbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.taskbar-icon {
    color: white;
}

.taskbar-title {
    font-weight: bold;
}

.separator {
    color: rgba(255, 255, 255, 0.5);
}

.taskbar-right {
    font-size: 0.875rem;
}

/* Barre des tâches du bas */
.bottom-taskbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(90deg, #7c3aed 0%, #0891b2 100%);
    padding: 0.5rem 1rem;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow-x: auto;
}

.taskbar-windows {
    display: flex;
    gap: 0.5rem;
    flex: 1;
}

.taskbar-window-item {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    padding: 0.5rem 1rem;
    color: white;
    font-size: 0.875rem;
    cursor: pointer;
    white-space: nowrap;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.taskbar-window-item:hover {
    background: rgba(255, 255, 255, 0.2);
}

.taskbar-window-item.active {
    background: rgba(255, 255, 255, 0.3);
    border-color: white;
}

/* Icônes du bureau */
.desktop-icons {
    padding: 2rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 1.5rem;
    max-width: 1200px;
}

.desktop-icon {
    background: rgba(26, 26, 46, 0.8);
    border: var(--border-primary);
    border-radius: 8px;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: var(--transition-normal);
    box-shadow: var(--shadow-primary);
}

.desktop-icon:hover {
    background: rgba(26, 26, 46, 1);
    transform: scale(1.05);
}

.desktop-icon:nth-child(2) {
    border: var(--border-secondary);
    box-shadow: var(--shadow-secondary);
}

.desktop-icon:nth-child(3) {
    border: var(--border-danger);
    box-shadow: var(--shadow-danger);
}

.desktop-icon:nth-child(4) {
    border: var(--border-success);
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.4);
}

.desktop-icon .icon {
    width: 40px;
    height: 40px;
    stroke: var(--color-primary);
    transition: var(--transition-fast);
}

.desktop-icon:nth-child(2) .icon {
    stroke: var(--color-secondary);
}

.desktop-icon:nth-child(3) .icon {
    stroke: var(--color-danger);
}

.desktop-icon:nth-child(4) .icon {
    stroke: var(--color-success);
}

.desktop-icon:hover .icon {
    transform: scale(1.1);
}

.desktop-icon span {
    color: var(--text-primary);
    font-size: 0.875rem;
    text-align: center;
}

.desktop-icon:nth-child(2) span {
    color: var(--color-secondary);
}

.desktop-icon:nth-child(3) span {
    color: var(--color-danger);
}

.desktop-icon:nth-child(4) span {
    color: var(--color-success);
}

.badge {
    background: var(--color-danger);
    color: white;
    padding: 0.125rem 0.375rem;
    border-radius: 10px;
    font-size: 0.75rem;
}

/* Fenêtres */
#windows-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.window {
    position: absolute;
    background: var(--bg-darker);
    border: var(--border-primary);
    border-radius: 8px;
    box-shadow: 0 0 30px rgba(34, 211, 238, 0.5);
    width: 600px;
    max-width: 90vw;
    max-height: 70vh;
    pointer-events: all;
    z-index: 50;
}

.window-header {
    background: linear-gradient(90deg, #9333ea 0%, #0891b2 100%);
    color: white;
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: 6px 6px 0 0;
    cursor: move;
}

.window-title {
    font-weight: bold;
}

.window-controls {
    display: flex;
    gap: 0.5rem;
}

.window-btn {
    background: transparent;
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.25rem;
    transition: var(--transition-fast);
}

.window-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.window-btn.close:hover {
    background: var(--color-danger);
}

.window-content {
    padding: 1rem;
    overflow-y: auto;
    max-height: calc(70vh - 50px);
}

/* Liste de fichiers */
.file-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-item {
    background: var(--bg-gray);
    border: 1px solid var(--color-primary);
    border-radius: 4px;
    padding: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.file-item:hover {
    background: var(--bg-gray-light);
}

.file-item svg {
    width: 24px;
    height: 24px;
    stroke: var(--color-primary);
}

.file-item.trash svg {
    stroke: var(--color-danger);
}

.file-item.trash {
    border-color: var(--color-danger);
}

.file-item span {
    color: var(--text-primary);
}

.file-item.trash span {
    color: var(--color-danger);
}

/* Contenu de fichier */
.file-content {
    background: var(--bg-gray);
    border: 1px solid var(--color-primary);
    border-radius: 4px;
    padding: 1rem;
}

.file-content h3 {
    color: var(--color-primary);
    margin-bottom: 1rem;
}

.file-content pre {
    color: var(--text-primary);
    font-size: 0.875rem;
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.5;
}

.file-content img {
    width: 100%;
    border: 2px solid var(--color-secondary);
    border-radius: 4px;
}

/* Emails */
.email-container {
    display: flex;
    height: 500px;
    gap: 0;
}

.email-sidebar {
    width: 250px;
    border-right: 2px solid var(--color-secondary);
    display: flex;
    flex-direction: column;
}

.email-tabs {
    display: flex;
    border-bottom: 2px solid var(--color-secondary);
}

.email-tab {
    flex: 1;
    padding: 0.75rem;
    background: var(--bg-gray);
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    transition: var(--transition-fast);
    border-right: 1px solid var(--color-secondary);
}

.email-tab:last-child {
    border-right: none;
}

.email-tab.active {
    background: var(--bg-gray-light);
    color: var(--color-secondary);
    font-weight: bold;
}

.email-tab:hover:not(.active) {
    background: rgba(168, 85, 247, 0.1);
}

.email-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.email-content-area {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: var(--bg-gray);
}

.email-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-style: italic;
}

.email-item {
    background: var(--bg-gray);
    border: 1px solid var(--color-secondary);
    border-radius: 4px;
    padding: 0.75rem;
    cursor: pointer;
    transition: var(--transition-fast);
    margin-bottom: 0.5rem;
}

.email-item:hover {
    background: var(--bg-gray-light);
}

.email-item.selected {
    background: var(--bg-gray-light);
    border-color: var(--color-primary);
}

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

.email-from {
    color: var(--color-secondary);
    font-weight: bold;
    font-size: 0.75rem;
}

.email-date {
    color: var(--text-muted);
    font-size: 0.625rem;
}

.email-subject {
    color: var(--text-primary);
    font-weight: bold;
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.email-preview {
    color: var(--text-muted);
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-attachment {
    color: var(--color-secondary);
    font-size: 0.75rem;
    margin-top: 0.25rem;
    display: inline-block;
}

.email-content {
    background: var(--bg-gray);
    border: 1px solid var(--color-secondary);
    border-radius: 4px;
    padding: 1rem;
    height: auto;
}

.email-back {
    color: var(--color-primary);
    background: transparent;
    border: none;
    cursor: pointer;
    margin-bottom: 1rem;
    font-family: 'Courier New', monospace;
    font-size: 1rem;
}

.email-back:hover {
    text-decoration: underline;
}

.email-detail-header {
    border-bottom: 1px solid var(--text-muted);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.email-detail-row {
    margin-bottom: 0.5rem;
}

.email-label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.email-value {
    color: var(--text-primary);
}

.email-value.from {
    color: var(--color-secondary);
}

.email-value.subject {
    color: var(--text-primary);
    font-weight: bold;
}

.email-body {
    color: var(--text-primary);
    white-space: pre-wrap;
    font-size: 0.875rem;
    line-height: 1.5;
    border-top: 1px solid var(--text-muted);
    padding-top: 1rem;
}

.email-attachment-section {
    margin-top: 1rem;
    border-top: 1px solid var(--text-muted);
    padding-top: 1rem;
}

.email-attachment-section p {
    color: var(--color-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.email-attachment-section img {
    width: 100%;
    border: 2px solid var(--color-secondary);
    border-radius: 4px;
}

/* Terminal */
.terminal {
    background: #000;
    border: 1px solid var(--color-success);
    border-radius: 4px;
    padding: 1rem;
    height: 400px;
    display: flex;
    flex-direction: column;
}

.terminal-output {
    flex: 1;
    overflow-y: auto;
    color: var(--color-success);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.terminal-output div {
    margin-bottom: 0.25rem;
}

.terminal-input-line {
    display: flex;
    align-items: center;
    border-top: 1px solid var(--color-success);
    padding-top: 0.5rem;
}

.terminal-prompt {
    color: var(--color-success);
    margin-right: 0.5rem;
}

.terminal-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--color-success);
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    outline: none;
}

/* Responsive */
@media (max-width: 768px) {
    .desktop-icons {
        grid-template-columns: repeat(2, 1fr);
        padding: 1rem;
    }
    
    .window {
        width: 95vw !important;
        max-height: 80vh !important;
    }
    
    .taskbar-right span:not(.separator):not(#current-user) {
        display: none;
    }

    .email-container {
        flex-direction: column;
        height: auto;
    }

    .email-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 2px solid var(--color-secondary);
    }
}