/* ==================== МОДАЛЬНОЕ ОКНО РЕДАКТИРОВАНИЯ БАЙТА ==================== */

.memory-edit-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10002;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 20px;
}

.memory-edit-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

body.light-theme .memory-edit-modal-overlay {
    background-color: rgba(255, 255, 255, 0.85);
}

body.modal-open-memory-edit {
    overflow: hidden !important;
}

.memory-edit-modal {
    width: 100%;
    max-width: 480px;
    background-color: #0a0a0a;
    border: 1px solid #333;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
    transform: translateY(30px) scale(0.95);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.5s ease, border-color 0.5s ease;
}

.memory-edit-modal-overlay.active .memory-edit-modal {
    transform: translateY(0) scale(1);
}

body.light-theme .memory-edit-modal {
    background-color: #ffffff;
    border: 1px solid #ddd;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
}

/* ===== Заголовок ===== */
.memory-edit-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
    transition: border-color 0.5s ease;
}

body.light-theme .memory-edit-modal-header {
    border-bottom: 1px solid #ddd;
}

.memory-edit-modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #FFFFFF;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: color 0.5s ease;
}

.memory-edit-modal-title svg {
    width: 20px;
    height: 20px;
    color: #B7FF69;
}

body.light-theme .memory-edit-modal-title {
    color: #000000;
}

body.light-theme .memory-edit-modal-title svg {
    color: #480096;
}

.memory-edit-modal-close {
    background: none;
    border: none;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.08);
    color: #FFFFFF;
    padding: 0;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.memory-edit-modal-close:hover {
    background-color: rgba(255, 255, 255, 0.18);
    transform: scale(1.1);
}

.memory-edit-modal-close svg {
    width: 18px;
    height: 18px;
}

body.light-theme .memory-edit-modal-close {
    background-color: rgba(0, 0, 0, 0.05);
    color: #000000;
}

body.light-theme .memory-edit-modal-close:hover {
    background-color: rgba(0, 0, 0, 0.1);
}

/* ===== Тело ===== */
.memory-edit-modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    overflow-y: auto;
}

/* ---- Информация о ячейке ---- */
.memory-edit-info {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px;
    background-color: #111;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    transition: background-color 0.5s ease, border-color 0.5s ease;
}

body.light-theme .memory-edit-info {
    background-color: #f5f5f5;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.memory-edit-info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'Source Code Pro', 'Consolas', monospace;
    font-size: 0.8rem;
}

.memory-edit-info-label {
    color: #888;
    font-weight: 500;
}

.memory-edit-info-value {
    color: #B7FF69;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

body.light-theme .memory-edit-info-label {
    color: #666;
}

body.light-theme .memory-edit-info-value {
    color: #480096;
}

/* ---- Поле ввода ---- */
.memory-edit-input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.memory-edit-input-label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #FFFFFF;
    opacity: 0.85;
    transition: color 0.5s ease;
}

body.light-theme .memory-edit-input-label {
    color: #000000;
}

.memory-edit-input {
    width: 100%;
    padding: 12px 14px;
    background-color: #151515;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    color: #FFFFFF;
    font-family: 'Source Code Pro', 'Consolas', monospace;
    font-size: 1.1rem;
    font-weight: 600;
    letter-spacing: 1px;
    outline: none;
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.5s ease;
    box-sizing: border-box;
    text-align: center;
}

.memory-edit-input:focus {
    border-color: #B7FF69;
    box-shadow: 0 0 0 3px rgba(183, 255, 105, 0.1);
}

.memory-edit-input::placeholder {
    color: #555;
    font-weight: 400;
    letter-spacing: 0;
}

body.light-theme .memory-edit-input {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    color: #000000;
}

body.light-theme .memory-edit-input:focus {
    border-color: #480096;
    box-shadow: 0 0 0 3px rgba(72, 0, 150, 0.1);
}

body.light-theme .memory-edit-input::placeholder {
    color: #999;
}

.memory-edit-hint {
    font-size: 0.7rem;
    color: #666;
    line-height: 1.4;
    font-family: 'Source Code Pro', 'Consolas', monospace;
}

body.light-theme .memory-edit-hint {
    color: #999;
}

/* ---- Быстрые кнопки ---- */
.memory-edit-quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.memory-edit-quick-label {
    font-size: 0.75rem;
    color: #888;
    margin-right: 4px;
    font-family: 'Source Code Pro', 'Consolas', monospace;
}

.memory-edit-quick-btn {
    padding: 6px 10px;
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #FFFFFF;
    font-family: 'Source Code Pro', 'Consolas', monospace;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    letter-spacing: 0.5px;
}

.memory-edit-quick-btn:hover {
    background-color: rgba(183, 255, 105, 0.12);
    border-color: rgba(183, 255, 105, 0.4);
    color: #B7FF69;
}

.memory-edit-quick-btn:active {
    transform: scale(0.95);
}

body.light-theme .memory-edit-quick-btn {
    background-color: rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #000000;
}

body.light-theme .memory-edit-quick-btn:hover {
    background-color: rgba(72, 0, 150, 0.08);
    border-color: rgba(72, 0, 150, 0.3);
    color: #480096;
}

/* ---- Превью ---- */
.memory-edit-preview {
    padding: 12px 14px;
    background-color: #0d0d0d;
    border: 1px solid rgba(183, 255, 105, 0.15);
    border-radius: 8px;
    transition: background-color 0.5s ease, border-color 0.5s ease;
}

body.light-theme .memory-edit-preview {
    background-color: #f9f9f9;
    border: 1px solid rgba(72, 0, 150, 0.15);
}

.memory-edit-preview-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    font-family: 'Source Code Pro', 'Consolas', monospace;
    font-size: 0.8rem;
}

.preview-label {
    color: #888;
    font-size: 0.75rem;
}

.preview-value {
    padding: 3px 8px;
    background-color: rgba(183, 255, 105, 0.1);
    border-radius: 4px;
    color: #B7FF69;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

body.light-theme .preview-value {
    background-color: rgba(72, 0, 150, 0.08);
    color: #480096;
}

/* ---- Ошибка ---- */
.memory-edit-error {
    padding: 10px 14px;
    background-color: rgba(255, 80, 80, 0.1);
    border: 1px solid rgba(255, 80, 80, 0.3);
    border-radius: 6px;
    color: #ff8080;
    font-size: 0.8rem;
    line-height: 1.4;
}

body.light-theme .memory-edit-error {
    background-color: rgba(200, 0, 0, 0.06);
    border: 1px solid rgba(200, 0, 0, 0.2);
    color: #c00;
}

/* ===== Кнопки ===== */
.memory-edit-modal-footer {
    display: flex;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #333;
    background-color: #0a0a0a;
    flex-shrink: 0;
    transition: background-color 0.5s ease, border-color 0.5s ease;
}

body.light-theme .memory-edit-modal-footer {
    background-color: #fafafa;
    border-top: 1px solid #ddd;
}

.memory-edit-btn {
    flex: 1;
    padding: 11px 18px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.memory-edit-btn-cancel {
    background-color: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.15);
    color: #FFFFFF;
}

.memory-edit-btn-cancel:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.memory-edit-btn-save {
    background-color: rgba(183, 255, 105, 0.15);
    border-color: rgba(183, 255, 105, 0.35);
    color: #B7FF69;
}

.memory-edit-btn-save:hover:not(:disabled) {
    background-color: rgba(183, 255, 105, 0.25);
    border-color: rgba(183, 255, 105, 0.55);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(183, 255, 105, 0.15);
}

.memory-edit-btn-save:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

body.light-theme .memory-edit-btn-cancel {
    background-color: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.1);
    color: #000000;
}

body.light-theme .memory-edit-btn-cancel:hover {
    background-color: rgba(0, 0, 0, 0.08);
    border-color: rgba(0, 0, 0, 0.2);
}

body.light-theme .memory-edit-btn-save {
    background-color: rgba(72, 0, 150, 0.08);
    border-color: rgba(72, 0, 150, 0.25);
    color: #480096;
}

body.light-theme .memory-edit-btn-save:hover:not(:disabled) {
    background-color: rgba(72, 0, 150, 0.15);
    border-color: rgba(72, 0, 150, 0.45);
    box-shadow: 0 6px 20px rgba(72, 0, 150, 0.12);
}

/* ===== Мобильная адаптация ===== */
@media (max-width: 575px) {
    .memory-edit-modal-overlay {
        padding: 10px;
    }

    .memory-edit-modal {
        max-width: 100%;
        border-radius: 10px;
    }

    .memory-edit-modal-header {
        padding: 12px 16px;
    }

    .memory-edit-modal-title {
        font-size: 1rem;
    }

    .memory-edit-modal-body {
        padding: 16px;
        gap: 12px;
    }

    .memory-edit-input {
        font-size: 1rem;
        padding: 10px 12px;
    }

    .memory-edit-quick-btn {
        padding: 5px 8px;
        font-size: 0.7rem;
    }

    .memory-edit-preview-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    .memory-edit-modal-footer {
        padding: 12px 16px;
        gap: 8px;
    }

    .memory-edit-btn {
        padding: 10px 14px;
        font-size: 0.85rem;
    }
}

/* ===== Поддержка safe area ===== */
@supports (padding: max(0px)) {
    @media (max-width: 575px) {
        .memory-edit-modal-header {
            padding-top: max(12px, env(safe-area-inset-top));
        }
        .memory-edit-modal-footer {
            padding-bottom: max(12px, env(safe-area-inset-bottom));
        }
    }
}