/* Schriftart */
@font-face {
    font-family: 'OpenDyslexic';
    src: url('fonts/OpenDyslexic-Regular.otf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

/* --- BASIS-LAYOUT --- */
html, body {
    background-color: #000000;
    margin: 0;
    padding: 0;
    height: 100dvh; 
    display: flex;
    justify-content: center;
    align-items: center; 
    overflow: hidden;
}

/* --- DER UNVERRÜCKBARE MONITOR --- */
#terminal-wrapper {
    background-color: #030303;
    color: #00ff00;
    font-family: 'Courier New', Courier, monospace;
    font-size: 16px; 
    width: 100%;
    height: 100%;
    padding: 15px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    position: relative;
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.7); 
    box-shadow: 0 0 40px rgba(0, 255, 0, 0.05);
    transition: background-color 0.5s ease, color 0.5s ease; 
    overflow: hidden; 
}

@media (min-width: 768px) {
    #terminal-wrapper {
        width: 800px;         
        height: 600px;        
        max-width: 95vw;      
        max-height: 95vh;     
        border: 2px solid #222; 
        border-radius: 8px;
        flex-shrink: 0;       
    }
}

/* --- CRT LINES --- */
#terminal-wrapper::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        0deg, rgba(0, 0, 0, 0.2), rgba(0, 0, 0, 0.2) 1px, transparent 1px, transparent 2px
    );
    pointer-events: none; 
    z-index: 50; 
}

/* --- NEU: DROPDOWN MENÜS --- */
/* --- NEU: SYSTEM MENÜ (In den Fluss integriert) --- */
#sys-controls {
    display: flex;
    justify-content: flex-end; /* Schiebt die Menüpunkte nach rechts */
    gap: 15px;
    padding: 10px;
    border-bottom: 1px dashed #004400; /* Optionale Trennlinie zum Text */
    z-index: 100;
    flex-shrink: 0; /* Verhindert, dass das Menü gequetscht wird */
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none; /* Standardmäßig versteckt */
    position: absolute;
    top: 100%; /* Direkt unter den Button */
    right: 0;  /* Rechtsbündig anheften */
    background-color: #030303;
    min-width: 180px;
    border: 1px solid #00ff00;
    box-shadow: 0 5px 15px rgba(0,0,0,0.8);
    z-index: 101;
    flex-direction: column;
}

/* Wird per JS gesteuert, um das Menü zu öffnen */
.dropdown-content.show {
    display: flex; 
}

.dropdown-content .sys-btn {
    border: none;
    border-bottom: 1px dotted #004400;
    width: 100%; /* Button füllt Dropdown aus */
    border-radius: 0;
}

.dropdown-content .sys-btn:last-child {
    border-bottom: none;
}

/* --- MENÜ GRUPPIERUNG --- */
.menu-spacer {
    height: 10px; /* Bestimmt die Größe der Lücke */
    width: 100%;
    background-color: currentColor; /* Nimmt automatisch das Grün, Schwarz oder Weiß des Themes an */
    opacity: 0.2; /* Macht die Linie sehr dezent */
}

/* --- ALLE BUTTONS --- */
.sys-btn, .terminal-btn {
    background: transparent;
    color: #00ff00;
    border: 1px solid #00ff00;
    padding: 8px 12px;
    font-family: inherit; 
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    text-shadow: inherit;
    outline: none; 
    max-width: 100%;
    white-space: nowrap;
}

.terminal-btn {
    font-size: 16px;
    box-shadow: 0 0 5px rgba(0, 255, 0, 0.2);
}

.sys-btn:hover, .terminal-btn:hover,
.sys-btn:focus, .terminal-btn:focus {
    background-color: #00ff00;
    color: #030303;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.6);
    outline: none; 
}

/* --- TEXT BEREICH --- */
#terminal-output {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 5px;
    -webkit-overflow-scrolling: touch; 
    text-align: left; 
}

#terminal-output::-webkit-scrollbar { width: 6px; }
#terminal-output::-webkit-scrollbar-thumb { background-color: #004400; border-radius: 3px; }

.line {
    min-height: 1.2em; 
    margin: 4px 0;
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
    word-break: break-word;
    width: 100%; 
    text-align: left;
}

.user-input { color: #ffffff; text-shadow: 0 0 3px rgba(255, 255, 0, 0.5); }
.ai-text { color: inherit; }

#options-container {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-top: 15px;
    padding-bottom: 20px;
}

/* --- CURSOR --- */
.cursor {
    display: inline-block;
    width: 10px;
    height: 1.2em;
    background-color: currentColor;
    vertical-align: text-bottom;
    animation: blink 1s infinite; 
}
.cursor-line { margin-top: 10px; }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* --- SHUTDOWN EFFEKT --- */
body.power-off #terminal-wrapper {
    animation: crtOff 0.6s cubic-bezier(0.23, 1, 0.32, 1) forwards;
    pointer-events: none; 
}
@keyframes crtOff {
    0% { transform: scale(1, 1); opacity: 1; filter: brightness(1); }
    40% { transform: scale(1, 0.005); opacity: 1; filter: brightness(5); }
    70% { transform: scale(0.005, 0.005); opacity: 1; }
    100% { transform: scale(0, 0); opacity: 0; filter: brightness(0); }
}


/* =========================================
   THEMES: LIGHT MODE & DARK MODE
   ========================================= */

/* Gemeinsame Regeln für Light UND Dark Mode (Killt CRT-Effekte) */
body.theme-light #terminal-wrapper, 
body.theme-dark #terminal-wrapper {
    font-family: 'OpenDyslexic', 'Georgia', serif; 
    text-shadow: none !important;
    box-shadow: none;
}
body.theme-light * { text-shadow: none !important; }
body.theme-dark * { text-shadow: none !important; }

body.theme-light #terminal-wrapper::before,
body.theme-dark #terminal-wrapper::before { display: none; } /* Scanlines weg */
body.theme-light .cursor, 
body.theme-dark .cursor { display: none; } /* Cursor weg */


/* Spezifische Light Mode Farben */
body.theme-light #terminal-wrapper {
    background-color: #f4ebd8; 
    color: #2b2b2b; 
    border-color: #ccc;
}
body.theme-light #sys-controls {
    border-bottom-color: #ccc; /* Ein dezentes Hellgrau für die gestrichelte Linie */
}
body.theme-light .sys-btn, body.theme-light .terminal-btn, body.theme-light .user-input {
    color: #2b2b2b;
    border-color: #2b2b2b;
    box-shadow: none;
}
body.theme-light .dropdown-content { background-color: #f4ebd8; border-color: #2b2b2b; }
body.theme-light .dropdown-content .sys-btn { border-bottom-color: #ccc; }
body.theme-light .sys-btn:hover, body.theme-light .sys-btn:focus,
body.theme-light .terminal-btn:hover, body.theme-light .terminal-btn:focus {
    background-color: #2b2b2b;
    color: #f4ebd8;
}
body.theme-light #terminal-output::-webkit-scrollbar-thumb {
    background-color: #888888; 
}

/* Spezifische Dark Mode Farben */
body.theme-dark #terminal-wrapper {
    background-color: #1a1a1a;
    color: #e0e0e0;
    border-color: #333;
}
body.theme-dark #sys-controls {
    border-bottom-color: #444; /* Ein dezentes Dunkelgrau */
}
body.theme-dark .sys-btn, body.theme-dark .terminal-btn, body.theme-dark .user-input {
    color: #e0e0e0;
    border-color: #e0e0e0;
    box-shadow: none;
}
body.theme-dark .dropdown-content { background-color: #1a1a1a; border-color: #e0e0e0; }
body.theme-dark .dropdown-content .sys-btn { border-bottom-color: #444; }
body.theme-dark .sys-btn:hover, body.theme-dark .sys-btn:focus,
body.theme-dark .terminal-btn:hover, body.theme-dark .terminal-btn:focus {
    background-color: #e0e0e0;
    color: #1a1a1a;
}
body.theme-dark #terminal-output::-webkit-scrollbar-thumb {
    background-color: #555555; 
}

/* --- SCHRIFTSTILE FÜR LIGHT & DARK MODE TRENNEN --- */

/* Die Eingaben des Nutzers sind normal (regular) */
body.theme-light .user-input,
body.theme-dark .user-input {
    font-style: normal;
    opacity: 0.42; /* Nimmt die Farbe zurück, für einen Kontrast */
}

/* Die Texte der KI sind kursiv (italic) */
body.theme-light .ai-text,
body.theme-dark .ai-text {
    font-style: italic;
}
/* =========================================
   MOBILE MENU (HAMBURGER)
   ========================================= */

#mobile-menu-btn {
    display: none; /* Am PC unsichtbar */
    position: fixed; 
    top: 15px;
    right: 15px;
    z-index: 105;
}

@media (max-width: 767px) {
    #mobile-menu-btn {
        display: block; 
    }

    #terminal-wrapper {
        width: 100vw !important;
        min-width: 100vw !important;
        flex-shrink: 0;
    }
    
    #sys-controls {
        display: none; 
        flex-direction: column;
        position: fixed;
        top: 55px; 
        right: 15px;
        background-color: #030303;
        border: 1px solid #00ff00;
        padding: 10px;
        box-shadow: 0 5px 15px rgba(0,0,0,0.9);
        z-index: 104;
        gap: 5px;
    }

    #sys-controls.open {
        display: flex !important; 
    }
    
    .dropbtn {
        display: none !important;
    }
    
    #sys-controls.open .dropdown-content {
        display: flex !important; 
        flex-direction: column;
        position: relative;
        border: none;          
        margin: 0;             
        padding: 0;
        box-shadow: none;
        background: transparent;
        gap: 5px;              
    }

    /* Der Text bekommt oben einen Puffer, damit der fixierte Button nichts verdeckt */
    #terminal-output {
        margin-top: 45px; 
    }
}

/* Theme-Anpassungen für die Handy-Menü-Box */
body.theme-light #sys-controls.open { background-color: #f4ebd8; border-color: #2b2b2b; }
body.theme-dark #sys-controls.open { background-color: #1a1a1a; border-color: #e0e0e0; }
body.theme-light .dropdown-content { border-left-color: #ccc; }
body.theme-dark .dropdown-content { border-left-color: #555; }

/* --- MENÜ KLEINER & UNAUFFÄLLIGER MACHEN --- */

/* Betrifft nur das Top-Menü und den Hamburger-Button */
#sys-controls .sys-btn,
#mobile-menu-btn {
    font-size: 12px;        /* Etwas kleinere Schrift (vorher 14px) */
    padding: 4px 8px;       /* Weniger wuchtig (vorher 8px 12px) */
    opacity: 0.5;           /* Macht das Menü halbtransparent und unauffällig */
    transition: opacity 0.3s ease, background-color 0.2s ease; 
}

/* Dropdown-Fenster etwas verschlanken */
.dropdown-content {
    min-width: 140px;       /* Schmaler als vorher */
}

/* Volle Leuchtkraft zurückgeben, wenn man darüberfährt oder darauf klickt */
#sys-controls .sys-btn:hover,
#sys-controls .sys-btn:focus,
#mobile-menu-btn:hover,
#mobile-menu-btn:focus,
#sys-controls.open {
    opacity: 1;
}

/* --- HACKER MATRIX (GRID MODE) --- */
#options-container.grid-mode {
    display: grid;
    grid-template-columns: repeat(5, 1fr); /* 5 Spalten nebeneinander */
    gap: 10px; /* Abstand zwischen den Knöpfen */
    margin-top: 20px;
}

#options-container.grid-mode .terminal-btn {
    margin: 0; /* Entfernt den normalen Abstand, das Grid übernimmt das */
    font-size: 0.9em; /* Schrift minimal kleiner für die Übersicht */
    padding: 8px 5px; /* Etwas kompakter */
    text-align: center;
}

/* Auf kleinen Handys machen wir aus den 5 Spalten lieber 2, sonst wird es zu eng */
@media (max-width: 600px) {
    #options-container.grid-mode {
        grid-template-columns: repeat(2, 1fr); 
    }
}

/* --- SYSTEM FEHLERMELDUNGEN (AUTH-CODES) --- */

/* Normale Warnung (Versuch 1 & 2) */
.line.sys-warning {
    color: #ff3333 !important;
    font-weight: bold !important;
}

/* Kritischer Lockout (Versuch 3) */
.line.sys-critical {
    color: #ff3333 !important;
    font-weight: bold !important;
}

/* --- SYSTEM BRANDING (Oben Links) --- */
#sys-brand {
    position: absolute;
    top: 15px;
    left: 15px;
    font-size: 11px;
    line-height: 1.4;
    opacity: 0.4;
    pointer-events: none; /* Verhindert, dass man aus Versehen darauf klickt */
    z-index: 90;
    white-space: pre-wrap; /* Wichtig, damit der Zeilenumbruch funktioniert */
}