/* Стили для всего тела */
body {
    background: #1e1e1e;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    color: #fff;
}

/* Основное окно терминала */
.mac-window {
    width: 95vw;
    max-width: 800px;
    height: 80vh;
    max-height: 600px;
    min-height: 400px;
    background: #121212;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #333;
}

/* Заголовок окна */
.window-header {
    height: 36px;
    background: #2e2e2e;
    display: flex;
    align-items: center;
    padding: 0 16px;
    position: relative;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    -webkit-user-select: none;
    user-select: none;
}

.buttons {
    display: flex;
    gap: 10px;
}

.buttons span {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
}

.close { background: #ff5f57; }
.minimize { background: #febc2e; }
.maximize { background: #28c940; }

.window-title {
    margin-left: 20px;
    font-size: 14px;
    color: #ccc;
    font-weight: 500;
}

/* Переключатель языка */
.language-switch {
    position: absolute;
    right: 16px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.language-switch button {
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    padding: 2px 6px;
    border-radius: 3px;
}

.language-switch button.active {
    font-weight: bold;
    color: #fff;
    background: #444;
}

/* Иконка помощи */
.help-trigger {
    display: inline-block;
    width: 20px;
    height: 20px;
    line-height: 20px;
    text-align: center;
    background: #444;
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background 0.2s;
}

.help-trigger:hover {
    background: #555;
}

/* Стили терминала */
.terminal {
    flex: 1;
    padding: 20px;
    color: #f8f8f8;
    font-family: 'JetBrains Mono', 'Fira Code', 'Monaco', 'Menlo', monospace;
    font-size: clamp(13px, 4vw, 15px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

.terminal-body {
    flex: 1;
    margin-bottom: 12px;
    overflow-wrap: break-word;
}

.terminal-input {
    display: flex;
    align-items: center;
    margin-top: auto;
    margin-bottom: env(safe-area-inset-bottom, 10px);
}

.prompt {
    color: #4cd137;
    white-space: nowrap;
    font-weight: 500;
    font-size: inherit;
}

#cmd-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #f8f8f8;
    font-family: inherit;
    font-size: inherit;
    outline: none;
    caret-color: #fff;
}

#cmd-input::placeholder {
    color: transparent;
}

/* === Matrix rain оверлей === */
#matrix-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 500;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.6s ease;
    background: #000;
}

#matrix-canvas.active {
    opacity: 0.92;
}

/* === Общие стили для модальных окон в стиле macOS === */
.mac-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.mac-modal.active {
    opacity: 1;
    pointer-events: all;
}

.mac-modal-content {
    width: 90%;
    max-width: 700px;
    height: 80%;
    max-height: 80vh;
    background: #121212;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    border: 1px solid #333;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.mac-modal.active .mac-modal-content {
    transform: scale(1);
}

/* Заголовок модального окна */
.mac-modal-header {
    height: 36px;
    background: #2e2e2e;
    display: flex;
    align-items: center;
    padding: 0 16px;
    position: relative;
    -webkit-user-select: none;
    user-select: none;
}

.mac-modal-header .buttons {
    display: flex;
    gap: 10px;
}

.mac-modal-header .buttons span {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: inline-block;
}

.mac-modal-header .close { background: #ff5f57; }
.mac-modal-header .minimize { background: #febc2e; }
.mac-modal-header .maximize { background: #28c940; }

.mac-modal-header .window-title {
    margin-left: 20px;
    font-size: 14px;
    color: #ccc;
    font-weight: 500;
}

/* Тело модального окна */
.mac-modal-body {
    flex: 1;
    padding: 24px;
    color: #f0f0f0;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: clamp(13px, 4vw, 15px);
    overflow-y: auto;
    line-height: 1.6;
}

.mac-modal-body h2,
.mac-modal-body h3 {
    color: #4cd137;
    margin-top: 0;
}

.mac-modal-body a {
    color: #4cd137;
    text-decoration: none;
}

.mac-modal-body a:hover {
    text-decoration: underline;
}

.mac-modal-body code {
    background: #333;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: inherit;
}

.mac-modal-body kbd {
    background: #444;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: inherit;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Специфика для справки */
#help-modal .mac-modal-body {
    white-space: pre-line;
}

/* === Адаптив под мобильные устройства === */
@media (max-width: 768px) {
    .window-header,
    .mac-modal-header {
        padding: 0 12px;
    }

    .window-title,
    .mac-modal-header .window-title {
        margin-left: 12px;
        font-size: 12px;
    }

    .buttons span {
        width: 12px;
        height: 12px;
    }

    .prompt,
    .language-switch {
        font-size: 12px;
    }

    .help-trigger {
        width: 18px;
        height: 18px;
        line-height: 18px;
        font-size: 12px;
    }

    .terminal,
    .mac-modal-body {
        padding: 16px;
    }

    .mac-modal-body {
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .mac-window {
        width: 98vw;
        height: 85vh;
        border-radius: 8px;
    }

    .mac-modal-content {
        border-radius: 8px;
    }

    .terminal-input {
        margin-bottom: env(safe-area-inset-bottom, 20px);
    }

    .language-switch {
        font-size: 12px;
        gap: 4px;
    }

    .help-trigger {
        width: 16px;
        height: 16px;
        line-height: 16px;
        font-size: 11px;
    }
}

/* === Touch-friendly кнопки для мобильных (опционально) === */
.mobile-buttons {
    display: none;
    padding: 10px 20px;
    text-align: center;
    gap: 10px;
}

@media (max-width: 600px) {
    .mobile-buttons {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
    }

    .mobile-buttons button {
        background: #333;
        color: #fff;
        border: 1px solid #444;
        border-radius: 6px;
        padding: 8px 12px;
        font-size: 14px;
        cursor: pointer;
        margin: 4px;
        flex: 1 1 auto;
        min-width: 100px;
    }

    .mobile-buttons button:hover {
        background: #444;
    }
}
